Can CloudFormation show me what the invalid value *is*?
I haven't been working with CloudFormation long, but I think I get the idea, mostly. But now I'm having an issue where I'm trying to build out different names for resources depending on whether they're in a production environment or not, and the conditional logic is a bit tricky in JSON or YAML. So I'm getting a lot of errors when I run
aws cloudformation validate-template
or when I try to deploy a stack through the console.
The errors vary greatly, so I'm not looking for help on any particular one, but they all have in common that some parameter or other has invalid characters or an invalid value. Fair enough: I'm working out a syntax that's new to me. But the error message never shows what the invalid value that CloudFormation received *is*, so I can't tell what I did wrong.
I've tried digging through CloudTrail and CloudWatch Logs to see if the bad value shows up there, and jumped back and forth all through the CF documentation, so far without success. This seems like such a basic troubleshooting thing that I can't believe it's not in there somewhere, so I feel like I must be overlooking something easy or simple.
Anyone know what I'm missing? Failing that, anyone know a way to render a template offline so you can capture the values passed?
Thanks in advance for any insight.
11 comments · 71% upvoted · other discussions
Yeah CF is a pain to debug. Best friends are cfn-lint, yamllint, cfn-nag. I've never really liked the cloudformation validate template command but it can help. Look at the parameters that were passed to your stack and "manually" debug it.
If you go as far as to create a stack changeset, it's a good practice but I would advice to wait until you figure out most of the issues you have before having such a step in your pipeline.
Edit: oh and I forgot you could also think about using stuff like troposphere to work on CF with real dev tools.