【发布时间】:2022-07-19 17:32:39
【问题描述】:
我是 CloudFormation 的新手,想使用 YAML 创建一个模板。我需要弄清楚是否有任何方法可以使用 UserInput 创建多个 VPC。 到目前为止,我已经使用了以下代码:
Parameters:
EnvironmentName:
Description: An environment name that is prefixed to resource names
Type: String
vpcCIDR1:
Description: Please enter the IP range (CIDR notation) for this VPC
Type: String
Default: 10.3.0.0/16
vpcCIDR2:
Description: Please enter the IP range (CIDR notation) for this VPC
Type: String
Default: 10.4.0.0/16
Resources:
VPC1:
Type: AWS::EC2::VPC
Properties:
CidrBlock: !Ref vpcCIDR1
EnableDnsSupport: true
EnableDnsHostnames: true
Tags:
- Key: Name
Value: !Ref EnvironmentName
VPC2:
Type: AWS::EC2::VPC
Properties:
CidrBlock: !Ref vpcCIDR2
EnableDnsSupport: true
EnableDnsHostnames: true
Tags:
- Key: Name
Value: !Ref EnvironmentName
我不需要再次编写相同的代码,而是需要代码来获取用户输入的 VPC 计数并根据用户输入创建 VPC。
【问题讨论】:
标签: amazon-web-services templates yaml amazon-cloudformation aws-cloudformation-custom-resource