2017-10-17 19 views
0

これは、タグがcostcenterでdeptに値が115の場合にのみインスタンスの作成を許可するポリシーで、これらのタグがなくても作成されたインスタンスをテストするときにプロンプ​​トされます。タグをリクエストするIamポリシー

{ 
 
      "Sid": "AllowTaggedInstances", 
 
      "Effect": "Allow", 
 
      "Action": "ec2:RunInstances", 
 
      "Resource": "arn:aws:ec2:us-east-1:729964090428:instance/*", 
 
      "Condition": { 
 
       "StringEquals": { 
 
        "aws:RequestTag/costcenter": "115", 
 
        "aws:RequestTag/dept": "prod" 
 
       }, 
 
       "ForAllValues:StringEquals": { 
 
        "aws:TagKeys": [ 
 
         "costcenter", 
 
         "dept" 
 
        ] 
 
       } 
 
      } 
 
     },

答えて

0

あなたが示した政策は、インスタンスを作成するための十分な権限がありません。これは、これを上書きしている別のポリシーまたはロールがあることを意味します。

ポリシーでは、「RequestTag」という単語を「ResourceTag」に置き換えてください。

注:条件を使用するのに最適なポリシーでは、「この場合は許可する」を使用せず、代わりに「これでない場合は拒否」を使用します。拒否はすべての許可を無効にします。ここで

はResourceTagsのお手伝いをするためのリンクです:

EC2 Resource Tags

0

あなたのポリシーは制限するのに十分な権限とポリシーではありません。
ユーザーがタグcostcenter:115 and dept:prodで新しいインスタンスを作成できるようにしたい場合は、ポリシーの下に試してみてください。

{ 
    "Version": "2012-10-17", 
    "Statement": [ 
    { 
     "Effect": "Allow", 
     "Action": [ 
     "ec2:Describe*", 
     "ec2:GetConsole*" 
     ], 
     "Resource": "*" 
    }, 
    { 
     "Effect": "Allow", 
     "Action": [ 
     "ec2:RunInstances" 
     ], 
     "Resource": [ 
     "arn:aws:ec2:region::image/*", 
     "arn:aws:ec2:region:account:subnet/*", 
     "arn:aws:ec2:region:account:network-interface/*", 
     "arn:aws:ec2:region:account:security-group/*", 
     "arn:aws:ec2:region:account:key-pair/*" 
     ] 
    }, 
    { 
     "Effect": "Allow", 
     "Action": "ec2:RunInstances", 
     "Resource": [ 
     "arn:aws:ec2:region:account:instance/*" 
     ], 
     "Condition": { 
     "StringEquals": { 
      "aws:RequestTag/costcenter": "115", 
      "aws:RequestTag/dept": "prod" 
     }, 
     "ForAllValues:StringEquals": { 
      "aws:TagKeys": [ 
      "costcenter", 
      "dept" 
      ] 
     } 
     } 
    }, 
    { 
     "Effect": "Allow", 
     "Action": [ 
     "ec2:CreateTags" 
     ], 
     "Resource": "arn:aws:ec2:region:account:*/*", 
     "Condition": { 
     "StringEquals": { 
      "ec2:CreateAction": "RunInstances" 
     } 
     } 
    } 
    ] 
} 
関連する問題