[英]AWS CloudFormation: how can I use parameters to form strings?
What I want to achieve is this:我想要实现的是:
AWSTemplateFormatVersion: "2010-09-09"
Description: deploy a full stack
Parameters:
# Product Name:
ProductName:
Type: String
Default: 'Docloud'
Description: This is the string that will appear in the names of most resources.
# Environment Name:
EnvName:
Type: String
Default: 'test-2'
Description: This is the string that will appear in the names of most resources.
# EC2 instance:
InstanceName:
Type: String
# Default: 'Earth-test-1'
Default: 'Earth-${!ProductName}-${!EnvName}'
# load balancing
NLBName:
Type: String
Default: 'NLB-${!ProductName}-${!EnvName}'
Description: the name for Network Load Balancer
TargetGroupName:
Type: String
Default: 'TG-${!ProductName}-${!EnvName}'
Description: the name of the Target Group to which the traffic from the NLB goes
I want to define 2 parameters: ProductName
and EnvName
, and then these variables will appear throughout the template to automatically form strings such as 'TG-${ ProductName}-${ EnvName}'
or 'NLB-${ ProductName}-${ EnvName}'
, so that when I deploy a new stack one week later, I only need to modify ProductName
and EnvName
.我想定义 2 个参数:
ProductName
和EnvName
,然后这些变量将出现在整个模板中以自动形成字符串,例如'TG-${ ProductName}-${ EnvName}'
或'NLB-${ ProductName}-${ EnvName}'
,这样一周后部署新栈时,只需要修改ProductName
和EnvName
。
I have tried a couple things, but the above goal cannot be reached.我尝试了几件事,但无法达到上述目标。
Is this possible with CloudFormation now?现在使用 CloudFormation 可以吗?
No its not possible, you have to use a nested stack or Aws CDK to have composed variables.不,这是不可能的,您必须使用嵌套堆栈或 Aws CDK 来组合变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.