aws-doc-sdk-examples icon indicating copy to clipboard operation
aws-doc-sdk-examples copied to clipboard

Epic: MVP Auto-scaling

Open brmur opened this issue 2 years ago • 0 comments

Implement the scenario and service action calls to create examples for each SDK.

Note that there are several similarly-named services this MVP is for the "AutoScaling" client, which is also called "EC2 Auto Scaling". Here's the user guide.

Service actions

Service actions can either be pulled out as individual functions or can be incorporated into the scenario, but each service action must be included as an excerpt in the SOS output.

Actions

CreateAutoScalingGroup UpdateAutoScalingGroup DeleteAutoScalingGroup DescribeAutoScalingGroups TerminateInstanceInAutoScalingGroup

SetDesiredCapacity DescribeAutoScalingInstances DescribeScalingActivities

EnableMetricsCollection DisableMetricsCollection

Scenario

  1. Create an EC2 launch template that you'll use to create an auto scaling group. Bonus: use SDK with EC2.CreateLaunchTemplate to create the launch template.
    • Recommended: InstanceType='t1.micro', ImageId='ami-0ca285d4c2cda3300'
  2. CreateAutoScalingGroup: pass it the launch template you created in step 0. Give it min/max of 1 instance.
    • You can use EC2.describe_availability_zones() to get a list of AZs (you have to specify an AZ when you create the group).
    • Wait for instance to launch. Use a waiter if you have one, otherwise DescribeAutoScalingInstances until LifecycleState='InService'
  3. DescribeAutoScalingInstances: show that one instance has launched.
  4. EnableMetricsCollection: enable all metrics or a subset.
    • If a subset, this list makes the most sense: 'GroupMinSize', 'GroupMaxSize', 'GroupDesiredCapacity', 'GroupInServiceInstances', 'GroupTotalInstances'.
  5. UpdateAutoScalingGroup: update max size to 3.
  6. DescribeAutoScalingGroups: show the current state of the group.
  7. SetDesiredCapacity: set desired capacity to 2.
    • Wait for a second instance to launch.
  8. DescribeAutoScalingInstances: show that two instances are launched.
  9. TerminateInstanceInAutoScalingGroup: terminate one of the instances in the group.
    • Wait for the old instance to stop and a new instance to launch to bring the capacity back to 2.
  10. DescribeScalingActivities: list the scaling activities that have occurred for the group so far.
  11. Bonus: use CloudWatch API to get and show some metrics collected for the group.
    • CW.ListMetrics with Namespace='AWS/AutoScaling' and Dimensions=[{'Name': 'AutoScalingGroupName', 'Value': }]
    • CW.GetMetricStatistics with Statistics='Sum'. Start and End times must be in UTC!
  12. DisableMetricsCollection
  13. DeleteAutoScalingGroup (to delete the group you must stop all instances):
    • UpdateAutoScalingGroup with MinSize=0
    • TerminateInstanceInAutoScalingGroup for each instance, specify ShouldDecrementDesiredCapacity=True. Wait for instances to stop.
    • Now you can delete the group.
  14. If you created a launch template in step 0, delete it now!

SDKs

  • [x] #3303
  • [ ] C++ AutoScaling MVP
  • [ ] Go AutoScaling MVP
  • [x] #3132
  • [ ] JavaScript AutoScaling MVP
  • [x] #3148
  • [x] #3222
  • [ ] #3478
  • [ ] Ruby AutoScaling MVP
  • [ ] Rust AutoScaling MVP
  • [ ] Swift AutoScaling MVP

Exit criteria:

  • [ ] Runnable scenario code.
  • [ ] Service action code (may be same as scenario code).
  • [ ] Integration or unit tests.
  • [ ] Scenario and API examples tagged for SOS.
  • [ ] README

brmur avatar Apr 21 '22 16:04 brmur