How to prevent troposphere generated Cloudformation from creating all new ASG

29 views
Skip to first unread message

Philip Caviness

unread,
May 6, 2022, 12:02:58 PM5/6/22
to cloudtools-dev
I have a python project that uses Troposphere to generate a CF template stack that contains an ASG and Launch Template. The stack is deployed successfully using an integration with boto3. One thing that Im still struggling to solve is that any change set created after the initial creation of the stack, even without any changes to the template or params, always will create a new ASG and LC which when deployed to CloudFormation, creates an all new version of the ASG resulting in the termination of all ec2 instances and standup of all new ec2 instances. Im sure there is a way to make the code smarter to be able to check for actual changes and only generate the template for changes since last stack creation or last change set but I havent run across it yet. Since troposphere doesnt have a state machine like Terraform, I'd like to know if there is any built in functions or supporting libraries that can use CloudFormation latest state for a stack to compare with the generated CF template from Troposphere. Thanks

Trent Nielsen

unread,
Nov 21, 2022, 7:57:11 PM11/21/22
to cloudtools-dev
If you are sending a CloudFormation update and your ASG and Launch templates are re-deploying, there is either some kind of dependency upstream that is being changed, and therefore your ASG and LC is getting changed, OR you are changing an attribute of your CF resource that results in a redeployment. 

CloudFormation/Troposphere is declarative. If there is a linked Ref/GetAtt in your LC or ASG it likely has to be redeployed whenever the Ref/GetAtt dependency changes. There is already logic built into detect these CF changes when you do a change-set operation against your stack. 
Reply all
Reply to author
Forward
0 new messages