Skip to content

Instantly share code, notes, and snippets.

@ritesh
Created October 9, 2019 13:53
Show Gist options
  • Save ritesh/6e15ac033b5bd57555053c76a9f49bd6 to your computer and use it in GitHub Desktop.
Save ritesh/6e15ac033b5bd57555053c76a9f49bd6 to your computer and use it in GitHub Desktop.
ParamSelection
AWSTemplateFormatVersion: 2010-09-09
Description: |
Creates an IAM role with a fixed set of parameters
Parameters:
RoleName:
Type: String
Description: Name of the role you want to create
EC2Policy:
Type: String
Default: No
AllowedValues:
- yes
- no
LambdaPolicy:
Type: String
Default: No
AllowedValues:
- yes
- no
RDSPolicy:
Type: String
Default: No
AllowedValues:
- yes
- no
S3Policy:
Type: String
Default: No
AllowedValues:
- yes
- no
Policies:
Type: AWS::SSM::Parameter::Value<CommaDelimitedList>
Description: Get a list of policies
Default: PolicyList
Resources:
MyRole:
Type: "AWS::IAM::Role"
Properties:
RoleName: !Ref RoleName
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action: "sts:AssumeRole"
Principal:
AWS: !Sub "arn:aws:iam::${AWS::AccountId}:root"
ManagedPolicyArns:
- !Select ["0", !Ref Policies]
- !Select ["1", !Ref Policies]
- !Select ["2", !Ref Policies]
- !Select ["3", !Ref Policies]
- !Select ["4", !Ref Policies]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment