Passing in template parameters

本小妞迷上赌 提交于 2019-12-10 23:37:25

问题


We are looking into using aws-cdk in our CI/CD pipeline. We need to be able to pass parameters into the the template during the build so it can generate an artifact to use during deploy. I see we can use the cdk.json file to specify context properties, but this doesn't actually put the values into the CloudFormation template itself. Just gives you access to them in the code.

I have tried something like this:

const servicenameprop = new PipelinePrerequisitesProps();
servicenameprop.default = 'hello';
servicenameprop.type = 'String';

const serviceNameParameter = new Parameter(this, 'servicename', servicenameprop);
serviceNameParameter.value = new Token(servicename, 'servicename');

This results in parameters appearing in the CloudFormation dashboard tab, but there are no values set, just the defaults. Is this supported currently? If not, is it planned for the future?


回答1:


The CDK does not currently support passing parameters in as part of cdk deploy. If you're leveraging parameters in your stacks, you'll have to manage the CloudFormation submission yourself, at least now. You could for example use the AWS CLI together with the result of running cdk synth (you can use cdk synth -o <directory>).

Generally speaking, we encourage the creation of CDK Stacks that are as concrete as possible. Passing context to your App directly at "synth" time will allow you code to reason over them and produce simpler, more predictable templates (for example, you can not put a resource in a template instead of adding a condition and a resource with a condition).



来源:https://stackoverflow.com/questions/53660503/passing-in-template-parameters

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!