Amazon web services 在特定子网中放置EC2实例时出现CloudFormation模板错误
正在处理CF示例模板,我正在尝试将EC2实例放入由同一模板创建的子网中。按原样做事时,我会出现以下错误:Amazon web services 在特定子网中放置EC2实例时出现CloudFormation模板错误,amazon-web-services,yaml,amazon-cloudformation,Amazon Web Services,Yaml,Amazon Cloudformation,正在处理CF示例模板,我正在尝试将EC2实例放入由同一模板创建的子网中。按原样做事时,我会出现以下错误: The parameter groupName cannot be used with the parameter subnet 以下是模板的一个子集: Resources: VPC: Type: AWS::EC2::VPC Properties: CidrBlock: 172.34.0.0/16
The parameter groupName cannot be used with the parameter subnet
以下是模板的一个子集:
Resources:
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 172.34.0.0/16
EnableDnsHostnames: False
Tags:
Subnet1:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: us-west-1a
CidrBlock: 172.34.0.0/24
VpcId:
Ref: VPC
MapPublicIpOnLaunch: False
WebServer1:
Type: AWS::EC2::Instance
Properties:
ImageId: !FindInMap [RegionMap, !Ref "AWS::Region", AMI]
InstanceType: t2.micro
SubnetId:
Ref: Subnet1
SecurityGroups:
- Ref: ServerSecurityGroup
Tags:
- Key: "Name"
Value: "Tyler-Cloudformation"
在创建
WebServer1
时,如何引用子网1,并将其放置在该子网中?我错过了什么?提前谢谢 错误可能是因为您使用的是SecurityGroups
,而不是。前一个参数仅用于默认VPC,而对于非默认VPC,必须使用后一个参数
因此,您不应该使用SecurityGroups
,而应该:
SecurityGroupIds:
- !GetAtt ServerSecurityGroup.GroupId