Getting Cloudformation error: Embedded stack was not successfully created

Question:

I’ve made a parent (nested) stack template that references 4 child templates. When I launch the stack through aws cloudformation create-stack, I get the following error for the parent stack:

Embedded stack AlignmentLambdaFunction was not successfully created: The following resource(s) failed to create: [CloudspanLambdaFunction, HaploLambdaExecutionRole, AlignmentLambdaExecutionRole].

And I get this error within one of the nested stacks that was getting created from the parent: Policy contains a statement with one or more invalid principals (for MasterGCPStorageKey (which is a resource in the Lambda child above)

I don’t understand the source of the error. I thought maybe it was because of needing a DependsOn for the ExecutionRoles, but that didn’t resolve the error.

Parent Stack:


Lambda Child Stack (relevant for error):

Answer:

I also was getting the following error after re-deploying a CloudFormation stack I had removed (via Serverless):

In my case, the original role which was assigned to my KMS encryption key was removed. KMS still keeps a reference to the removed role, and apparently adding a newly created role of the same type creates this error.

I solved this by simply removing the old reference to the removed role, under IAM > Encryption Keys > YOUR_KEY_NAME > Key Policy > Key Users

Leave a Reply