When deploying CloudFormation stacks in a “Continuous Delivery” manner with CodePipeline, one might encounter the challenge to pass many parameters from the CloudFormation stack describing the pipeline to another stack describing the infrastructure to be deployed (in this example a stack named application
).
Consider a CloudFormation snippet describing CodePipeline which deploys another CloudFormation stack:
1 | # pipeline.yaml |
Now when you want to pass parameters from the pipeline stack to the application
stack, you could use the ParameterOverrides option offered by the CodePipeline CloudFormation integration, which might look like this:
1 | # pipeline.yaml |
This would pass the parameters ApplicationParameterA
and ApplicationParameterB
to the application
CloudFormation stack. For reference this is how the application
stack could look like:
1 | # application.yaml |
Alternative way of parameter passing with Template Configurations
Injecting parameters from the pipeline stack to the application stack can become awkward with the ParametersOverrides
method. Especially when there are many parameters and they are passed into the pipeline stack as parameters as well, the pipeline template could look like this:
1 | # pipeline.yaml |
An alternative way is to place a so called template configuration into the same artifact which contains the application.yaml
template, and reference it via the TemplateConfiguration
:
1 | # pipeline.yaml |
In our case, the template_configuration.json
file would look like this:
1 | { |
This might be much nicer to handle and maintain depending on your setup.
Btw you can also use the TemplateConfiguration
to protect your resources from being deleted or replaces with Stack policies.
Like what you read?
You can hire me or make a donation via PayPal!