Created
June 4, 2020 07:53
-
-
Save nirsky/318822ef15c85f224b0c0c5a0a5403b5 to your computer and use it in GitHub Desktop.
This file contains 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 characters
import { Policy, PolicyStatement } from '@aws-cdk/aws-iam'; | |
// Give our EC2 instance the needed permissions to manage EBS | |
const ec2PolicyEbs = new Policy(stack, 'ec2-policy-create-ebs', { | |
policyName: 'REXRay-EBS', | |
statements: [ | |
PolicyStatement.fromJson({ | |
Effect: 'Allow', | |
Action: [ | |
'ec2:AttachVolume', | |
'ec2:CreateVolume', | |
'ec2:CreateSnapshot', | |
'ec2:CreateTags', | |
'ec2:DeleteVolume', | |
'ec2:DeleteSnapshot', | |
'ec2:DescribeAvailabilityZones', | |
'ec2:DescribeInstances', | |
'ec2:DescribeVolumes', | |
'ec2:DescribeVolumeAttribute', | |
'ec2:DescribeVolumeStatus', | |
'ec2:DescribeSnapshots', | |
'ec2:CopySnapshot', | |
'ec2:DescribeSnapshotAttribute', | |
'ec2:DetachVolume', | |
'ec2:ModifySnapshotAttribute', | |
'ec2:ModifyVolumeAttribute', | |
'ec2:DescribeTags', | |
], | |
Resource: '*', | |
}), | |
], | |
}); | |
// Attach policy to our AutoScalingGroup | |
autoScalingGroup.role.attachInlinePolicy(ec2PolicyEbs); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment