如何在Cloudformation模板参数中创建IAM角色下拉列表

Ada*_*ott 3 amazon-web-services aws-cloudformation

我正在寻找一种方法来列出Cloudformation模板中的现有IAM角色,其方式与列出EC2密钥对相似.下面是我正在尝试使用EC2密钥对和IAM角色的示例,但是Cloudformation会抛出错误,指出"RoleName"不存在.

"KeyName": {
  "Description" : "Choose a Key Pair that is available in this region",
  "Type": "AWS::EC2::KeyPair::KeyName",
  "ConstraintDescription": "Must be the name of an existing EC2 Key Pair"
},
"ServiceRole": {
  "Description" : "Choose an IAM Role that is available in this region",
  "Type": "AWS::IAM::Role::RoleName",
  "ConstraintDescription": "Must be the name of an existing IAM Role"
},
Run Code Online (Sandbox Code Playgroud)

Cloudformation Interface的屏幕截图 如果有可能实现这个想法吗?

Mat*_*ser 7

下拉列表中并不支持所有类型,并且IAM角色不是受支持的类型.因此,您无法获得IAM角色的下拉列表.相反,您将不得不使用一个简单的文本框.

以下是支持的参数类型的当前列表:

  • String
  • Number
  • List<Number>
  • CommaDelimitedList
  • AWS::EC2::AvailabilityZone::Name
  • AWS::EC2::Image::Id
  • AWS::EC2::Instance::Id
  • AWS::EC2::KeyPair::KeyName
  • AWS::EC2::SecurityGroup::GroupName
  • AWS::EC2::SecurityGroup::Id
  • AWS::EC2::Subnet::Id
  • AWS::EC2::Volume::Id
  • AWS::EC2::VPC::Id
  • AWS::Route53::HostedZone::Id
  • List<AWS::EC2::AvailabilityZone::Name>
  • List<AWS::EC2::Image::Id>
  • List<AWS::EC2::Instance::Id>
  • List<AWS::EC2::SecurityGroup::GroupName>
  • List<AWS::EC2::SecurityGroup::Id>
  • List<AWS::EC2::Subnet::Id>
  • List<AWS::EC2::Volume::Id>
  • List<AWS::EC2::VPC::Id>
  • List<AWS::Route53::HostedZone::Id>

资料来源:http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html