DEV Community

Discussion on: CloudFormation Example for Auto Scaling Fargate Service

Collapse
 
andrewdmay profile image
Andrew May

You may be able to achieve a very similar effect, with significantly less configuration by using Target Tracking. When you use target tracking, AWS generates the alarms from that trigger the scaling up or down.

Also (because I can't help myself from doing code reviews), there's an easier way to substitute attributes into values:

AlarmDescription: !Sub
  - 'Scale Up Alarm based on requests for ${FargateServiceName}'
  - FargateServiceName: !GetAtt FargateService.Name
Enter fullscreen mode Exit fullscreen mode

can be

AlarmDescription: !Sub Scale Up Alarm based on requests for ${FargateService.Name}
Enter fullscreen mode Exit fullscreen mode

i.e. you can use ${<logicalresourceid>.<attributename>} within !Sub

(also I removed the single quotes, because there are actually very few places you need to quote yaml)

Collapse
 
thomasstep profile image
Thomas Step

As far as Target Tracking goes, I chose to manually create the alarms to bring more control in. I believe there are opinionated metrics and thresholds for Target Tracking. I personally have no problem about siding with AWS's opinion, but sometimes there are reasons to deviate. It took me a while to figure out how to handle auto scaling without Target Tracking which is why I wanted to give that knowledge to the interwebs.

As far as the "code review", thanks for pointing that out! I had since figured out that we can call attributes in a !Sub, but it's good to point out.