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

Joann
質問済み 2ヶ月前601ビュー
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
回答済み 1ヶ月前
profile picture
エキスパート
レビュー済み 1ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ