How do I change DeletionPolicy of imported resources so that subsequent imports work?

Viewed 574

I'm currently in the process of importing our existing resources into a CloudFormation stack. To import a resource Foo, I describe its current state in the template, set the DeletionPolicy to Retain, then import the existing resource. So far, so good.

Now I want to remove the DeletionPolicy of the imported resource, so I remove it in the template and deploy it. This results in "No changes to deploy. Stack MyStack is up to date".

If I now try to import another resource, again following the above process, it fails with this error:

There was an error creating this change set You have modified resources [Foo] in your template that are not being imported. Update, create or delete operations cannot be executed during import operations.

To me, this looks like the earlier deploy does not apply the DeletionPolicy change. If I keep the DeletionPolicy of Foo as Retain, the import of later resources works as expected.

1 Answers

I was able to update the DeletionPolicy by doing a "direct update" through the CLI, as described here, i.e. using update-stack instead of deploy.

It seems updating methods that work with change sets, such as deploy or the Update function of the Console don't work because DeletionPolicy apparently doesn't constitute a "real" change?

Related