Update cfndsl requirement from < 1.0 to ~> 1#356
Conversation
Allows us to test the output via Cucumber
pretty_generate wasn't creating formatted JSON during the test suite. Dumping the template to a hash before generating fixes this issue.
|
|
||
| def perform | ||
| puts(proposed_stack.template_body) | ||
| StackMaster.stdout.puts(proposed_stack.template_body) |
There was a problem hiding this comment.
Print the compiled template to the StackMaster configured STDOUT.
This allows the printed content to be captured during Cucumber tests, so we can write assertions for it.
| end | ||
|
|
||
| def self.compile(template_dir, template, compile_time_parameters, _compiler_options = {}) | ||
| CfnDsl.disable_binding |
There was a problem hiding this comment.
This option has been removed in later versions of cfndsl.
| ::CfnDsl.eval_file_with_extras(template_file_path).to_json | ||
| json_hash = ::CfnDsl.eval_file_with_extras(template_file_path).as_json | ||
| JSON.pretty_generate(json_hash) |
There was a problem hiding this comment.
Use a pretty format for the compiled template. This is consistent with how we compile Sparkle Formation templates.
| end | ||
|
|
||
| JSON.pretty_generate(sparkle_template) | ||
| JSON.pretty_generate(sparkle_template.dump) |
There was a problem hiding this comment.
I noticed the compiled SparkleFormation template wasn't always pretty formatted during Cucumber tests.
We avoid this problem by dumping the template to a hash before converting it to a JSON string.
|
|
||
| EC2_Instance(:MyInstance) { | ||
| DisableApiTermination external_parameters["DisableApiTermination"] | ||
| DisableApiTermination external_parameters.fetch(:DisableApiTermination, "false") |
There was a problem hiding this comment.
In V1, cfndsl doesn't allow compile time parameters to be missing. We need to provide a default.
| expect { | ||
| compile_time_parameters.delete("DisableApiTermination") | ||
| }.to change { JSON.parse(compile)["Resources"]["MyInstance"]["Properties"]["DisableApiTermination"] }.from('true').to(nil) | ||
| }.to change { JSON.parse(compile)["Resources"]["MyInstance"]["Properties"]["DisableApiTermination"] }.from('true').to('false') |
There was a problem hiding this comment.
Test the default is used, when the compile time parameter is not provided.
|
@redterror are you still using |
patrobinson
left a comment
There was a problem hiding this comment.
Approved on the proviso we at least make an attempt to let users know this potentially breaking change is coming.
|
@orien I skimmed, it seems reasonable to me. Thanks for flagging, I'll update my repos using cfndsl once this is merged and report back if I hit any snags. |
|
Thanks @redterror. I appreciate it. |
|
@patrobinson I've updated the change log entry to warn that |
|
|
Context
I notice we're not allowing
cfndsl1.0 or later. It would be good to rely on the latest stable release.While exploring an upgrade I found that we're missing Cucumber tests for the
compilecommand.Change
compilecommand. Cover Sparkle Formation and CFN DSL templates.cfndslrequirement from< 1.0to~> 1