Painlessly create or update a CloudFormation stack in an idempotent way

Michael Wittig – 16 Mar 2017

When integrating CloudFormation into your CI/CD pipeline you are faced with the challenge of creating a CloudFormation stack on the first run of the pipeline, while you need to update the stack for all following pipeline runs. If you use the AWS CLI this is painful.


You may also have your code and template in the same repository. Therefore code changes without the template. But the AWS CLI threats an update without changes to a stack as an error which is not the behavior that you need in your pipeline.

cfn-create-or-update can create or update a CloudFormation stack. If no updates are to be performed, no error is thrown. cfn-create-or-update behaves exactly as the AWS CLI regarding input values, output will be different.


To install the CLI tool cfn-create-or-update, run:

npm install -g cfn-create-or-update

To create or update a stack, run:

cfn-create-or-update --stack-name test --template-body file://template.yml

The first time you run this command, a stack will be created. The second time an update will be performed but only if the template has changes.

Looking for a new challenge?


    Senior Lead Cloud Solutions Architect AWS

    DEMICON • AWS Advanced Consulting Partner • Remote (Europe)
    GitLab Terraform K8s EKS Lambda Python Go
  • tecRacer

    Cloud Consultant • Machine Learning & Data Analytics

    tecRacer • Premier AWS Consulting Partner • Germany, Austria, Portugal, and Switzerland
    SageMaker Airflow Athena Redshift

CLI parameters

cfn-create-or-update behaves exactly as the AWS CLI regarding input values. Supported parameters (as documented in the AWS CLI create-stack or update-stack):


Global parameters (as documented in the AWS CLI


Only used during create, otherwise ignored (as documented in the AWS CLI create-stack):

--disable-rollback | --no-disable-rollback

Only used during update, otherwise ignored (as documented in the AWS CLI update-stack):

--use-previous-template | --no-use-previous-template]

Additional parameter, to wait for create complete / update complete.


cfn-create-or-update is available on GitHub for free (MIT license).

Other solutions to this problem:

Become a cloudonaut supporter

Michael Wittig

Michael Wittig ( Email Twitter LinkedIn Mastodon )

We launched the cloudonaut blog in 2015. Since then, we have published 366 articles, 60 podcast episodes, and 58 videos. It's all free and means a lot of work in our spare time. We enjoy sharing our AWS knowledge with you.

Please support us

Have you learned something new by reading, listening, or watching our content? With your help, we can spend enough time to keep publishing great content in the future. Learn more

Amount must be a multriply of 5. E.g, 5, 10, 15.

Thanks to Alan Leech, Alex DeBrie, ANTHONY RAITI, Christopher Hipwell, e9e4e5f0faef, Jason Yorty, Jeff Finley, jhoadley, Johannes Grumböck, Johannes Konings, John Culkin, Jonas Mellquist, Jonathan Deamer, Juraj Martinka, Ken Snyder, Markus Ellers, Oriol Rodriguez, Ross Mohan, Ross Mohan, sam onaga, Satyendra Sharma, Simon Devlin, Thorsten Hoeger, Todd Valentine, Victor Grenu, waldensystems, and all anonymous supporters for your help! We also want to thank all supporters who purchased a cloudonaut t-shirt.