Jochem Schulenklopper
Jochem Schulenklopper

Reputation: 6914

How to get AWS CloudFormation output / debug statements during provisioning?

Using AWS Cloudformation, my aws cloudformation create-stack fails for some yet-unclear reason. For this question the error and the explanation aren't relevant, but I think I'm passing a parameter with --parameters that's not correctly handled within the CloudFormation template, or there might be an error in evaluating expressions or referencing variables in the template.

Anyway, I really would like to be able to output some debug statements or expressions during evaluation of the template; the provisioning of the stack. What's the CloudFormation equivalent of logging.debug(some-expression) that gets the expression output to CloudWatch Logs or some other output channel?

The Events log in the CloudFormation Stacks shows the error (in my case), but unfortunately not the details that I need to fix the bug. It doesn't show the value of variables or CloudFormation expressions during execution / provisioning, and (by my knowledge) I can't create events that'll show the values of variables or expressions. CloudWatch Logs is empty, with respect to provisioning tasks. And aws cloudformation validate-template reveals no errors, so the CloudFormation template is syntactically correct.

Upvotes: 6

Views: 4984

Answers (1)

Marcin
Marcin

Reputation: 238249

What's the CloudFormation equivalent of logging.debug(some-expression) that gets the expression output to CloudWatch Logs or some other output channel?

Unfortunately, there is no such functionality provided by AWS. The only tool provided by AWS is aws cloudformation validate-template. General information on how to use template validation is described in a recent AWS blog:

However, some sort of debugging comes from creating a change set, but this only applies when you update existing stack.

You can also find some third party tools, such as yaml checkers or CloudFormation template linters, for checking your templates. Many of these tools are listed in this SO question.

Ultimately, to be sure your template will work you have to attempt to deploy it.

Upvotes: 2

Related Questions