【问题标题】:Why cant we use AllowedValues for key pair as String using the Parameter in CloudFormation?为什么我们不能使用 CloudFormation 中的参数将 AllowedValues 用作字符串?
【发布时间】:2023-03-17 09:22:03
【问题描述】:

最近我开始使用 YAML 学习 Cloud Formation。我的密钥对为 CFNkey、Newkey1、Newkey2。 Here is an image。所以我怀疑我是否尝试将类型作为字符串用于密钥对,我得到this error message。我使用的YAML代码如下:-

AWSTemplateFormatVersion: 2010-09-09
Description: Parameter using the Dynamic KeyName
Parameters: 
  MyKeyName:
    Description: Select the key Name from the below 
    Type: String
    Default: Newkey1
    AllowedValues:
     - CFNkey
     - Newkey2
Resources:
 DevEC2Instance:
  Type: AWS::EC2::Instance
  Properties:
   InstanceType: t2.micro
   ImageId: ami-04aa88aebb9fefd83
   KeyName: !Ref MyKeyName 
   SecurityGroup:
    - !Ref SSHSecurityGroup
 SSHSecurityGroup:
  Type: AWS::EC2::SecurityGroup 
  Properties: 
  GroupDescription: My Sg
  SecurityIngress:
    IpProtocol: tcp
    ToPort: 22
    FromPort: 22
    Cidr: 0.0.0.0/0
  SecurityEgress:
    IpProtocol: tcp 
    ToPort: 8080
    FromPort: 8080
    Cidr: 0.0.0.0/0

【问题讨论】:

    标签: amazon-web-services amazon-ec2 amazon-elastic-beanstalk amazon-cloudformation amazon-ecs


    【解决方案1】:

    您的Newkey1 必须在AllowedValues 中列出:

      MyKeyName:
        Description: Select the key Name from the below 
        Type: String
        Default: Newkey1
        AllowedValues:
         - Newkey1
         - CFNkey
         - Newkey2
    

    【讨论】:

    • @Deepak 没问题。如果答案有帮助,我们将不胜感激。
    猜你喜欢
    • 2013-09-20
    • 2012-06-03
    • 1970-01-01
    • 2015-11-21
    • 1970-01-01
    • 1970-01-01
    • 2021-08-03
    • 2016-07-12
    • 1970-01-01
    相关资源
    最近更新 更多