繁体   English   中英

AWS CloudFormation:如何使用参数来形成字符串?

[英]AWS CloudFormation: how can I use parameters to form strings?

我想要实现的是:

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

我想定义 2 个参数: ProductNameEnvName ,然后这些变量将出现在整个模板中以自动形成字符串,例如'TG-${ ProductName}-${ EnvName}''NLB-${ ProductName}-${ EnvName}' ,这样一周后部署新栈时,只需要修改ProductNameEnvName

我尝试了几件事,但无法达到上述目标。

现在使用 CloudFormation 可以吗?

不,这是不可能的,您必须使用嵌套堆栈或 Aws CDK 来组合变量。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM