Is CloudFormation idempotent?

In many places on the Internet I read that CloudFormation is not idempotent, but I can not find a single example that confirms this fact.

Could you provide me with an example that runs a resource to prove that CloudFormation is not idempotent?

+6
source share
3 answers

The definition of idempotent according to Wikipedia is as follows:

In computer science, the term idempotent is used more comprehensively to describe an operation that will give the same results if it is performed one or more times.

CloudFormation is considered not idempotent in several aspects of its behavior:

  • Calling the create API for an existing stack will result in an error
  • Calling the update API with the CloudFormation stack unchanged results in an error
  • Creating and deleting the same stack will lead to the creation of resources with different ARNs for IAM users, security group identifiers, EC2 instance identifiers, VPC identifiers, etc.
  • Resources modified outside of CloudFormation will not be reverted to their original values ​​if the existing stack is updated with existing content

However, from a high level, one of the main reasons for using CloudFormation is that you present your infrastructure as code so that you can use it to recreate the same infrastructure. This is almost identical to the original definition of an idempotent, but the difference here is multiple. As stated above when using the same stack and applying it on top of it or deleting the stack and re-creating it, you technically do not get exact exact results, but from a practical point of view this is quite understandable and often quite acceptable.

+10
source

I am not sure if this answer will be useful since the question was posted 2 years ago. Better late than never.

AWS CloudFormation has changed a lot during these two years. Right now, I can safely say that these API calls are idempotent.

Look at these API calls:

You will see that there is an optional ClientRequestToken parameter. This ensures the idempotency of API calls. This is the token that the client provides in order to inform the CloudFormation service that it is not making a new API call. As long as you use the same token and continue to make a call with the rest of the parameters, CloudFormation knows that you only re-call.

+1
source

Cloud information is idempotent, if you did not make updates to an already completed stack, if there are changes, then they will be updated, now updating a resource may require its removal and creation or updating without creating a new resource

To learn more about the cfn-hup process, this will help you.

0
source

All Articles