LoginSignup
6

More than 5 years have passed since last update.

[AWS][EC2]特定のタグがついたEC2インスタンスのみに対して操作を許可する設定

Last updated at Posted at 2016-03-15

ひとまずメモとして置いておきます。

特定のタグがついたEC2インスタンスにのみ以下の操作を許可するポリシーです。

  • インスタンスの再起動
  • インスタンスの開始
  • インスタンスの終了
policy.json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "xxxxxxxxxxxxxxxxx",
            "Effect": "Allow",
            "Action": [
                "ec2:RebootInstances",
                "ec2:StartInstances",
                "ec2:StopInstances"
            ],
            "Condition": {
                "StringEquals": {
                    "ec2:ResourceTag/[:tagName]": "[:value]"
                }
            },
            "Resource": [
                "*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "ec2:Describe*"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}

[:tagName]を指定するタグ名に、[:value]を指定する値に置き換えればOK。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6