2

Given an AWS template that contains calls to instrinsic functions, and potential references parameters, is there a CLI tool that allows to pass values for the parameters, and generate the corresponding Template file ?

Eg, from

{
  "Resource" : { "Fn::Join" : [ "", [ "xxx-" , { "Ref": "SomeParam" }, "-zzz" ] ] } 
}

Supplying that SomeParam has value bar, you should get a readable text file with :

{
 "Resource" : "xxx-bar-yyy"
}

I looked at the various aws cloudformation subcommands (I had hopes for verify-template, but to no avail...

(Rationale : creating / updating stack takes ages, and I don't have the brainpower to get a cloudformation file right the first time. Or the first n times, for that matter, for a shamefully too high value of n.)

2 Answers 2

1

CloudFormation itself doesn't have the feature you describe currently. Amazon has acknowledged something similar to a --dry-run feature for the create-stack command would be useful, e.g. this thread:

https://forums.aws.amazon.com/thread.jspa?threadID=122514

Suggested workarounds:

  1. Split up stacks into smaller chunks (nesting) and then run them independently for faster test iterations. This doesn't work for all use cases, and is still subject to the sluggish performance of the CloudFormation API / engine.

  2. Try moto - a Python library that mimics the AWS API specifically for testing - it appears to have the core CloudFormation API implemented, although I have not actually used this lib for CFN specifically so YMMV.

    https://github.com/spulec/moto

  3. If you haven't checked out Terraform, it has the concept of execution plans, via the terraform plan command that does essentially what you describe, but for Terraform stacks instead.

    https://www.terraform.io/intro/vs/cloudformation.html

0

create-change-set is probably the closest you will get: the problem is that functions like Ref and Fn::GetAttr can be called on resources that will only exist once the stack is run (i.e. how does it tell you what instance id it will create your instance with?)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .