I manually deleted a resource that was created by one of my AWS CloudFormation stacks, and now my stack won't update. How can I avoid deleting my stack, and then creating a new stack to replace my deleted stack? 

If you delete a resource from an AWS CloudFormation stack, then you must remove the resource from your AWS CloudFormation template. Otherwise, your stack fails to update, and you get an error message. 

Update a resource that you created manually

You can get your stack to update by replacing a manually created resource that you deleted with a new resource. The new resource, however, must have the same name as the deleted resource. For example, AWS Identity and Access Management (IAM) roles are tracked by name. If you accidentally delete an IAM role, you can manually recreate that role with the same name.

To update an IAM role or other resource that you created manually, complete the following steps:

  1. Open the AWS CloudFormation console.
  2. Select your stack, and then choose the Resources view.
  3. In the Physical ID column, look for the physical ID of the IAM role that you want to replace with a new IAM role that you're creating.
    Note: The physical ID is the name of the resource.
  4. Create a new IAM role, and then give the new role the same physical ID that you found in step 3.
  5. Update your stack.
    Note: For more information on how to update a stack, see Modifying a Stack Template.

Update a resource with a unique ID

You can't manually recreate a resource, such as a route table, with a unique ID. Instead, you have to remove the resource and any references to that resource from your AWS CloudFormation template.

To allow AWS CloudFormation to recreate a route table or other resource with a unique ID, complete the following steps:

  1. In your AWS CloudFormation template, remove the route table and any references to the route table.
  2. Update the stack that does not contain your route table.
  3. Add the route table and any additional resources or references that you require back to your AWS CloudFormation template.
    Note: AWS CloudFormation recreates the deleted resource.
  4. Update your stack again.

Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2016-09-22

Updated: 2019-02-11