schedule to update all autoscaling groups in my account using cloudformation

0

I using ServiceInstanceSchedule for switch off all of EC2 instances at 8 pm, i would like to know if i can update values of the MinSize,MaxSize e DesiredCapacity using cloudformation of all autoscaling group in my account without lambda

1 Answer
0

Hello,

Greetings of the day !

Updating the values of MinSize, MaxSize, or DesiredCapacity for all Auto Scaling groups in your AWS account directly through AWS CloudFormation without using Lambda functions is not straightforward because CloudFormation itself does not provide a direct mechanism to perform operations across multiple existing resources like Auto Scaling groups. While CloudFormation offers automation, it's crucial to look out for some limitations as well. Here I am mentioning the approach


Targeted Updates with CloudFormation :

  • This approach provides the most control and minimizes security risks.
  • Identify ASGs: Use the AWS CLI or SDK to list your ASGs and identify the specific ones you want to modify based on tags, names, or other criteria.
  • Create Separate CloudFormation Templates: For each ASG you want to update, create a separate CloudFormation template that defines the AWS::AutoScaling::AutoScalingGroup resource.
  • Update Each Stack: Use the aws cloudformation update-stack command to update each CloudFormation stack representing an ASG.
 Note : Updating an Auto Scaling group's properties like MinSize, MaxSize, or DesiredCapacity directly using CloudFormation's update-stack command is feasible only if you're targeting a single stack managing that specific Auto Scaling group. It doesn't provide a mechanism to iterate over and update properties for Auto Scaling groups across all stacks or accounts.

Scripted CloudFormation for Multiple ASGs :

  • If updating a limited number of ASGs is necessary for efficiency, consider scripting the CloudFormation update process. However, this requires strict adherence to security best practices:

  • IAM Permissions: Use IAM roles or users with the least privilege principle, granting access only to update specific ASGs.

  • Thorough Testing: Rigorously test scripts and CloudFormation templates in a separate, non-production environment before deployment.

  • Change Sets: Always leverage CloudFormation change sets for previewing updates and identifying potential issues before applying them.

You'll need to choose the one that best fits your requirements and test the approach if it is working fine and as expected for you.

AWS
SUPPORT ENGINEER
Kush_C
answered 2 months ago
profile picture
EXPERT
reviewed 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions