157

When I deploy using cloudformation aws cloudformation deploy --region $region --stack-name ABC

I get the error:

An error occurred (ValidationError) when calling the CreateChangeSet operation: Stack:arn:aws:cloudformation:stack/service/7e1d8c70-d60f-11e9-9728-0a4501e4ce4c is in ROLLBACK_COMPLETE state and can not be updated.

Michael Wheeler
  • 849
  • 1
  • 10
  • 29
Thanh Nguyen Van
  • 10,292
  • 6
  • 35
  • 53
  • Some stack is in Rollback, and I think it has to be finished first. – Lamanus Sep 14 '19 at 05:38
  • 1
    so I have to create maually stack first ? or I can update on another existed stack ? – Thanh Nguyen Van Sep 14 '19 at 05:41
  • You can provide more information like what is the error because of which it got rolled back, It will help to community to better understand the problem and provide solution. You could get more information from the AWS console – Vinoth A Sep 14 '19 at 10:23

4 Answers4

215

This happens when stack creation fails. By default the stack will remain in place with a status of ROLLBACK_COMPLETE. This means it's successfully rolled back (deleted) all the resources which the stack had created. The only thing remaining is the empty stack itself. You cannot update this stack; you must manually delete it, after which you can attempt to deploy it again.


If you set "Rollback on failure" to disabled in the console (or set --on-failure to DO_NOTHING in the CLI command, if using create-stack), stack creation failure will instead result in a status of CREATE_FAILED. Any resources created before the point of failure won't have been rolled back.

If instead you were deploying updates to an existing (successfully created) stack, and the updates failed but were successfully rolled back, it will go back into its previous valid state (with a status of UPDATE_ROLLBACK_COMPLETE), allowing you to reattempt updates.


As @SteffenOpel points out, you can now specify that a stack should be deleted on failure by setting the --on-failure option (for create-stack only, not deploy) to DELETE in the CLI. This option is not yet available in the console at the time of writing (13/11/20).

404
  • 8,022
  • 2
  • 27
  • 47
  • 3
    how to specify that it should be deleted on failure? – Jun Mar 19 '20 at 23:39
  • 1
    @Jun711 I don't believe that's possible with the built-in functionality. You can specify whether it should roll back or not on failure in the "Stack creation options" section, but I don't believe you can tell it to automatically delete on failure. What you *could* do is create a custom resource which you add to your CF template, which monitors the stack's status and will delete it if it fails. But usually you'd want to investigate the failure reason, so I don't think it's a good idea to auto-delete it. – 404 Mar 20 '20 at 13:52
  • 4
    It is possible to automatically delete the stack on failure by specifying `DELETE` with the resp. `--on-failure` option (which semantically supersedes `--disable-rollback`) - this newer and more flexible option still does not seem to be exposed in the console though, but it is available via the [CreateStack](https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_CreateStack.html) API action and also the AWS CLI [create-stack](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-stack.html) action. – Steffen Opel Nov 09 '20 at 19:40
  • 3
    Just a heads up that OP is using `aws cloudformation deploy`, not `aws cloudformation create-stack`. `deploy` does not allow you to set `--on-failure` so you have to manually delete the stack if it fails to create. https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html – John Breen Dec 30 '20 at 16:08
  • @JohnBreen did you mean vice-versa? That OP is using create-stack? –  May 01 '21 at 13:10
  • 1
    Shame to AWS. I have only one advice.Do not use CloudFormation. Use terraform – Vlad Nov 23 '22 at 21:17
80

Run the following AWS CLI command to delete your stack:

aws cloudformation delete-stack --stack-name <<stack-name>>

It may take less than a minute to delete your stack, and then try re-deploying it.

tuomastik
  • 4,559
  • 5
  • 36
  • 48
SRi
  • 1,046
  • 7
  • 10
  • 4
    this works only if your region is coincides with the CLI command - in case you get some kind of empty list from using this, don't worry - just login into to web console, go to the correct region, and delete from there. of course, this is not optimal way to accomplish this but it at least fixes the issue in case the input above does not solve the issue – nate Oct 25 '20 at 02:32
  • This worked for me. My initial call to node deploy failed, due to insufficient permissions The empty stalk was not deleted automatically and the consecutive deployment were failing with the above error. – Nafsin Vk Aug 02 '22 at 05:53
  • Solution does not work – Julius Goddard Dec 16 '22 at 11:57
1

2 solutions 1.you have to manually delete all the objects in the s3 (if still th error occurs ,Stack:arn:aws:cloudformation:eu-west-3:624140032431:stack/as*****cbucket/f57c54f0-618a-11ec-afd7-06fc90426f3e is in ROLLBACK_COMPLETE state and can not be updated., move to second solution) 2.create a new bucket to continue

ashique
  • 935
  • 2
  • 8
  • 26
1

the case is that the S3 bucket is unique globally, same happened to me I was getting the same error while I was using the CloudFormation.

in my case, S3 bucket name was not unique in my case, it was already created, i change then name of the bucket and it worked.

user727412
  • 11
  • 1