4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWSリソース操作権限をタグで絞る EC2とRDS

Last updated at Posted at 2016-05-14

タグで絞った権限付与をしたいという話

リソースの操作権限をインスタンス単位ではなくタグで絞りたい場面ってありますよね。
特定システムに関するタグが付いたリソースだけ、star,stop,restart権限を与えて、
ディベロッパーが効率よく開発できるようにしてあげるとか。
でも、タグで絞れるリソースって限られていて、EC2とRDSしかない認識。

EC2

EC2 に関してはググればたくさん出てきます。
公式ドキュメントの[ココ](http://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/ec2-supported-iam-actions-resources.html"Amazon EC2 API アクションでサポートされるリソースレベルのアクセス許可")にタグでしぼれる操作の一覧があります。このドキュメントでCondition Keysに含まれる操作が対象です。

絞れる操作はあまり多くない。EBSのバックアップに関する操作権限があるといいなぁと思ったがなかった。
やはりstart,stop,restartあたりが無難かも。

ポリシーのサンプル

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow"
      "Action": [
        "ec2:RebootInstances",
        "ec2:StartInstances",
        "ec2:StopInstances",
      ],
      "Condition": {
        "StringEquals": {
          "ec2:ResourceTag/Nametagtoka": "mobileapplication"
        }
      },
      "Resource": [
        "*"
      ]
    }
  ]
}

RDS

RDSは情報が少ない。

Jimさんのブログ
http://blogs.aws.amazon.com/security/post/Tx2H8VFYCM8A1BF/A-primer-on-RDS-resource-level-permissions

で紹介されており、ドキュメントでは[ココ](http://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/ec2-supported-iam-actions-resources.html"Amazon EC2 API アクションでサポートされるリソースレベルのアクセス許可")に記載がある。

RDSをタグで絞るポリシーのサンプル

{
   "Version":"2012-10-17",
   "Statement":[
      {
         "Sid":"DenyProductionCreate",
         "Effect":"Allow",
         "Action":"rds:RebootDBInstance",
         "Resource":"*",
         "Condition":{
            "StringEquals":{
               "rds:db-tag/usage":"prod"
            }
         }
      }
   ]
}

おまけ

IAMのポリシーでアンド条件やオア条件とか困る時ありますよね。
http://docs.aws.amazon.com/ja_jp/IAM/latest/UserGuide/reference_policies_elements.html

タグで操作をしぼれるのはEC2とRDSだけの認識です。
他にもある、というのをご存じの方はぜひ教えて下さい。

4
5
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
4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?