I manually deleted a resource that was created by one of my AWS CloudFormation stacks, and now my stack won't update.
If you delete a resource that was created by a CloudFormation stack, then your stack fails to update, and you get an error message.
Choose one of the following resolutions based on your resource type:
- Update a resource with a unique name
- Update a resource with a unique ID
Update a resource with a unique name
If the deleted resource supports a unique name, you can get your stack to update by manually creating the resource. The new resource, however, must have the same name as the deleted resource. For example, you can impact how CloudFormation handles a resource when you change a resource name. This is because 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 any other resource with a unique name, complete the following steps:
- Open the AWS CloudFormation console.
- Select your stack, and then choose the Resources view.
- In the Physical ID column, find the Physical ID of the IAM role that you want to replace with your new IAM role.
Note: The Physical ID is the name of the resource.
- Create a new IAM role, and then give the new role the same Physical ID that you found in step 3.
- Update your stack.
Note: For more information, 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 must remove the resource and any references to that resource from your CloudFormation template.
Note: The following resolution also works for resources that don't support a unique name or a unique ID. For example, a record set in a hosted zone.
To allow CloudFormation to recreate a route table or any other resource with a unique ID, complete the following steps:
- In your CloudFormation template, remove the route table and any references to it.
- Update the stack.
Note: CloudFormation tries to delete the route table. Because the resource has already been deleted, CloudFormation considers the deletion a successful operation.
- Add the route table and any additional resources or references that you require back to your CloudFormation template.
- Update your stack again.
Note: CloudFormation recreates the deleted resource.
Troubleshooting AWS CloudFormation