Jan 19, 2022

Attach or Detach Volumes to an EC2 Instance

0
0
{{ }} Substitute variables

Adjust the variable values according to your preference.

Policy Code

1{
2    "Version": "2012-10-17",
3    "Statement": [
4        {
5            "Effect": "Allow",
6            "Action": [
7                "ec2:AttachVolume",
8                "ec2:DetachVolume"
9            ],
10            "Resource": [
11                "arn:aws:ec2:*:*:volume/*",
12                "arn:aws:ec2:*:*:instance/*"
13            ],
14            "Condition": {
15                "ArnEquals": {"ec2:SourceInstanceARN": "arn:aws:ec2:*:*:instance/{{instanceId}}"}
16            }
17        }
18    ]
19}
DOC

Replace {{instanceId}} with the id value of your EC2 instance

    Get the IAM Pulse Check Newsletter

    We send out a periodic newsletter full of tips & tricks, contributions from the community, commentary on the industry, relevant social posts, and more.

    Checkout past issues for a sampling of the goods.