LoginSignup
3
0

More than 5 years have passed since last update.

タグで特定のEC2インスタンスを保護するIAMポリシー

Posted at

保護対象のEC2 Instancesの停止、再起動、削除を禁止します。
また、保護手段であるTagの削除も禁止します

※特定のVPCやSubnet内のEC2 Instancesを保護する方法について、
【Amazon EC2 API アクションでサポートされるリソースレベルのアクセス許可】により、(非常に残念ですが)インスタンスの起動(StartInstances)、停止(StopInstances)、削除(TerminateInstances)、再起動(RebootInstances)(作成(RunInstances)を除く)のAPI Actionはリソースベースのアクセス許可をサポートされていないため、ConditionにVPCやSubnetを指定することでは、そのVPCやSubnet内のEC2 Instancesを保護することができません。

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "ProtectedEc2Instances",
            "Effect": "Deny",
            "Action": [
                "ec2:StopInstances",
                "ec2:RebootInstances",
                "ec2:TerminateInstances",
                "ec2:DeleteTags"
            ],
            "Condition": {
                "StringEquals": {
                    "ec2:ResourceTag/tag-key": "value"
                }
            },
            "Resource": "arn:aws:ec2:region:account:instance/*"
        }
    ]
}
3
0
0

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
3
0