Skip to content

Instantly share code, notes, and snippets.

@eulersson
Created February 20, 2019 00:07
Show Gist options
  • Save eulersson/8b167facecd3af202a3d2b738f3fbb81 to your computer and use it in GitHub Desktop.
Save eulersson/8b167facecd3af202a3d2b738f3fbb81 to your computer and use it in GitHub Desktop.
# Specifies a resource that Application Auto Scaling can scale. In our case
# it's just the backend.
AutoScalingTarget:
Type: AWS::ApplicationAutoScaling::ScalableTarget
Properties:
MinCapacity: 1
MaxCapacity: 3
ResourceId: !Join ['/', [service, !Ref ECSCluster, !GetAtt BackendService.Name]]
ScalableDimension: ecs:service:DesiredCount
ServiceNamespace: ecs
RoleARN: !GetAtt AutoScalingRole.Arn
# Describes the rules for ECS to check and decide when it should scale up or
# down a service. In our application we just scale the backend.
AutoScalingPolicy:
Type: AWS::ApplicationAutoScaling::ScalingPolicy
Properties:
PolicyName: BackendAutoScalingPolicy
PolicyType: TargetTrackingScaling
ScalingTargetId: !Ref AutoScalingTarget
TargetTrackingScalingPolicyConfiguration:
PredefinedMetricSpecification:
PredefinedMetricType: ECSServiceAverageCPUUtilization
ScaleInCooldown: 10
ScaleOutCooldown: 10
TargetValue: 50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment