- Newest
- Most votes
- Most comments
CloudFormation happily created the log group with that literal name, but the console and stack cleanup then struggle because the name contains characters that weren’t intended to be static.
A few important clarifications:
• This is a known edge case with CloudFormation + CloudWatch Logs
• The resource is valid, but hard to reference and delete cleanly
• Deleting the stack fails because CloudFormation can’t reconcile the logical ID ↔ physical name mapping anymore
Why “Force delete” worked
Force delete bypasses CloudFormation’s dependency tracking and deletes the physical log group directly. That’s safe here because log groups are not stateful resources.
How to prevent this next time
• Always wrap dynamic names with !Sub explicitly:
LogGroupName: !Sub "/aws/ec2/instance/${AppName}"
Add a default value for parameters used in names
• Avoid putting unresolved parameters in resource names that CloudFormation must later delete
• For logs created implicitly (Lambda, ALB, etc.), consider RetentionInDays instead of managing the name yourself
Force delete is the correct escape hatch.
answered 9 months ago
Relevant content
asked 4 years ago
