gpt4 book ai didi

amazon-web-services - 如果选择开发环境,则使用cloudformation条件创建根卷

转载 作者:行者123 更新时间:2023-12-03 07:22:36 25 4
gpt4 key购买 nike

我正在尝试在生产环境中创建根卷。从参数中选择,工作正常,但如果选择 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

我做错了什么导致生产场景可以工作但开发抛出错误。

最佳答案

!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"

关于amazon-web-services - 如果选择开发环境,则使用cloudformation条件创建根卷,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72286342/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com