Interview Prep/AWS/CloudFormation, CloudWatch, KMS, Secrets and Cost

Deleting or updating a stack fails: `Export network-VpcId cannot be deleted as it is in use by app-stack`.

IntermediateTroubleshootingCloudFormation, CloudWatch, KMS, Secrets and Cost
Answer

Likely causes → Another stack imports the output through Fn::ImportValue. CloudFormation will not let you change or remove an export while it is imported.

Diagnose →

aws cloudformation list-imports --export-name network-VpcId
aws cloudformation list-exports --query "Exports[?Name=='network-VpcId']"

Fix →

  1. In the importing stacks, replace ImportValue with a hard-coded value or an SSM parameter and deploy them
  2. Then change or remove the export in the producer stack

Prevent → For loose coupling, share values between stacks through SSM Parameter Store ({{resolve:ssm:/network/vpc-id}}) rather than exports.

aws All AWS questions Roadmap: Cloud cost & architecture

More on CloudFormation, CloudWatch, KMS, Secrets and Cost