简体   繁体   中英

AWS CloudFormation Template to Create EC2 - List IAM Roles

I'm trying to get a AWS CloudFormation template to provide a drop down list of IAM roles as part of a EC2 creation template. I have this working for subnet ID, VPC and security group but stuck on getting it to work for IAM role.

In the code snippet below my template prompts for a VpcName from a drop down list but it fails when trying to generate the list for InstanceProfile. I've tried a number of different combinations such as:

"Type" : "AWS::IAM::Role"
"Type" : "AWS::IAM::ROLE"
"Type" : "AWS::IAM::Role:Id"
"Type" : "AWS::IAM::ROLE:ID"


    },
    "InstanceProfile": {
      "Description": "Select the role for this EC2 instance",
      "Type" : "AWS::IAM::InstanceProfile"
    },
    "VpcName" : {
      "Description" : "Select the VPC for this EC2 Instances",
      "Type" : "AWS::EC2::VPC::Id"
    },

What you're using for the mentioned parameters are a special kind of CloudFormation parameter types: AWS-Specific Parameter Types . With these parameters you get the mentioned dropdowns and additional validation of the specified values, but they have to be explicitly supported by CloudFormation for each resource type. The types of the parameters you have working are supported by CloudFormation (subnet ID by AWS::EC2::Subnet::Id , VPC by AWS::EC2::VPC::Id and security group by AWS::EC2::SecurityGroup::GroupName or AWS::EC2::SecurityGroup::Id ), while there is no such type for IAM roles as of now.

Therefore there is unfortunately no way to get such a dropdown for IAM roles, until AWS implements an AWS-specific parameter type for IAM roles. I suggest you open an AWS support case as feature request for such a parameter type as more of such requests make it more likely that this gets prioritized by AWS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM