Created
January 24, 2017 21:43
-
-
Save onema/79906942ce771644ded20b07a8990ae2 to your computer and use it in GitHub Desktop.
Revisions
-
onema created this gist
Jan 24, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ AWSTemplateFormatVersion: "2010-09-09" Description: > Tempalte to create a managed policy to lock down users to create instance of a specific type Parameters: InstanceTypes: Description: > Comma separated list of instance types that will be allowed by the policy e.g. "t1.*, t2.*, m3.*" Type: "CommaDelimitedList" Default: "t1.*, t2.*, m3.*" Resources: LockDownAccessToInstanceTypesPolicy: Type: "AWS::IAM::ManagedPolicy" Properties: Description: "Policy to enable users to manage specific instance types" Path: "/" PolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Action: - "ec2:*" Resource: "*" - # Deny access if the instance types are not the ones described below Effect: "Deny" Action: "ec2:RunInstances" Resource: !Sub "arn:aws:ec2:*:${AWS::AccountId}:instance/*" Condition: StringNotLikeIfExists: # Only apply this condition if this intance type key exists ec2:InstanceType: !Ref InstanceTypes Outputs: LockDownAccessToInstanceTypesPolicy: Description: Policy to enable users to manage specific instance types Value: !Ref LockDownAccessToInstanceTypesPolicy Export: Name: !Sub "${AWS::StackName}-LockDownAccessToInstanceTypesPolicy"