- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Use an AWS CloudFormation Parameter AWS CDK 的部分提到了如何自定义您的 AWS CloudFormation 模板。指的是云形成模板 .我想将参数添加到我的 CDK 堆栈并获取合成 CF 模板的参数部分。
我是否正确理解文档建议将参数部分添加到合成模板?如果是,它将在每次运行 cdk synth
时被覆盖。 .
任何其他方式来定义参数部分?
最佳答案
编辑:这是一个从上下文中读取存储桶名称的 typescript 示例:https://github.com/cloudshiftstrategies/aws-cdk-examples/tree/master/context-example-typescript-app
您可以使用 CfnParameter 类型向 CDK 添加参数,如下所示:
new cdk.CfnParameter(this, 'MyParameter', {
type: 'String',
default: 'Blah',
noEcho: true,
});
但是 CDK 通常不鼓励这样做。设计是拥有完全可部署的堆栈,并使用代码/配置作为应该为给定帐户创建的条件。这是来自他们的
documentation :
When you run the cdk synth command for an app with multiple stacks, the cloud assembly includes a separate template for each stack instance. Even if the two stacks are instances of the same class, the AWS CDK emits them as two individual templates.
You can synthesize each template by specifying the stack name in the cdk synth command. The following example synthesizes the template for stack1.
This approach is conceptually different from how AWS CloudFormation templates are normally used, where a template can be deployed multiple times and parameterized through AWS CloudFormation parameters. Although AWS CloudFormation parameters can be defined in the AWS CDK, they are generally discouraged because AWS CloudFormation parameters are resolved only during deployment. This means that you cannot determine their value in your code. For example, to conditionally include a resource in your app based on the value of a parameter, you must set up an AWS CloudFormation condition and tag the resource with this condition. Because the AWS CDK takes an approach where concrete templates are resolved at synthesis time, you can use an if statement to check the value to determine whether a resource should be defined or some behavior should be applied.
关于aws-cdk - 如何在 CDK 堆栈中指定参数定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58138536/
我是一名优秀的程序员,十分优秀!