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개 답변
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
지원 엔지니어
Kush_C
답변함 한 달 전
profile picture
전문가
검토됨 한 달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠