我正在嘗試創建一個根卷是生產環境。從引數中選擇,效果很好,但是如果選擇了 dev,則會引發錯誤。“屬性 BlockDeviceMappings 的值必須是 List 型別”
Parameters:
Enviornment:
Type: String
Description: Enter the enviornment where you want the instance deployed
AllowedValues:
- Production
- Development
Conditions:
isProduction: !Equals [!Ref Enviornment, Production]
Resources:
Ec2Instace:
Type: AWS::EC2::Instance
Properties:
AvailabilityZone: !Ref AvailabilityZone
ImageId: !Ref AmiId
InstanceType: !Ref InstanceType
KeyName: !Ref Ec2KeyPair
SecurityGroupIds:
- !GetAtt SecurityGp.GroupId
SubnetId: !Ref SubnetId
BlockDeviceMappings:
!If
- isProduction
-
- DeviceName: /dev/xvda
Ebs:
VolumeType: gp2
VolumeSize: 21
- !Ref Enviornment
我做錯了什么導致生產場景作業但開發拋出錯誤。
uj5u.com熱心網友回復:
!Ref Enviornment是不正確的。我想你想要以下內容:
Resources:
Ec2Instace:
Type: AWS::EC2::Instance
Properties:
AvailabilityZone: !Ref AvailabilityZone
ImageId: !Ref AmiId
InstanceType: !Ref InstanceType
KeyName: !Ref Ec2KeyPair
SecurityGroupIds:
- !GetAtt SecurityGp.GroupId
SubnetId: !Ref SubnetId
BlockDeviceMappings:
!If
- isProduction
-
- DeviceName: /dev/xvda
Ebs:
VolumeType: gp2
VolumeSize: 21
- !Ref "AWS::NoValue"
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/477297.html
