The Ops Community ⚙️

Alese Michael
Alese Michael

Posted on

Testing AWS cloudformation template

Good day lovely people. :)
I have a question.
Please how does one run/test their cloudformation template without actually deploying the resources?
I ask this because running the template would incur charges if one wanted to see if it passed.
Thanks.

Top comments (7)

Collapse
 
eriklz profile image
Erik Lundevall Zara

You can use tools like cfn-lint and cfn-nag to do some sanity checks. Also reviewing the change set before applying an update to a stack. But in the end there will be things that are only checked at runtime by cloudformation and you cannot avoid it completely to get charged,
That being said, work in small increments snd updates and do not put too many things in the same stack will help to avoid too msny repeated charges and wasted time during developmrnt.

Something like AWS CDK can also speed up development and avoid some low-level mistakes, as it tries to package many resouces in a way more easy to handle, assuming you are fsmiliar with any of the programming languages supported.

Collapse
 
nvsblmike profile image
Alese Michael

Hello thanks a lot for this. I was also thinking about running tests using cfnlint. I heard from someone that I could use localstack which would deploy locally, confirm if the template deployed all the resources properly and would not incur charges. True?

Collapse
 
eriklz profile image
Erik Lundevall Zara

Localstack may help to some extent for sure, although probably not catch all issues.
I would expect service limit issues and regional differences perhaps not getting caught, and any timing related issue as well.

But I have not used localstack recently, so not sure about the current quality of the emulation.
I think more of the value may come from faster feedback loop rather than resource cost.

I.e. it may reduce the cost of your time more than the cost of AWS resources -which is valuable.

Collapse
 
ellativity profile image
Ella (she/her/elle)

Thanks so much for jumping in here!

@nvsblmike was this helpful for you?

Collapse
 
techielass profile image
Sarah Lean

The AWS CloudFormation designer tool can help validate templates to a certain degree and help you understand if it's a valid or not.

As far as I understand it doesn't quite test deployment logic etc but it gives you some idea of what will happen if you run the template.

Collapse
 
ellativity profile image
Ella (she/her/elle)

I knew you knew more than I do!

Collapse
 
ellativity profile image
Ella (she/her/elle)

I don't have the answer to your question @nvsblmike but maybe @cloudyadvice @eriklz @techielass or @daknhh does?