2017-08-17 8 views
1

以下のカスタムIAMをインラインポリシーとしてIAMユーザに添付しましたが、ユーザログインからEC2インスタンスを起動しようとすると、動作していません。私の要件は、マイクロインスタンス。IAMポリシーが起動していません

{ 
    "Version": "2012-10-17", 
    "Statement": [ 
     { 
      "Effect": "Allow", 
      "Action": [ 
       "ec2:DescribeInstances", 
       "ec2:DescribeImages", 
       "ec2:DescribeKeyPairs", 
       "ec2:DescribeVpcs", 
       "ec2:DescribeSubnets", 
       "ec2:DescribeSecurityGroups" 
      ], 
      "Resource": "*" 
     }, 
     { 
      "Effect": "Allow", 
      "Action": "ec2:RunInstances", 
      "Resource": [ 
       "arn:aws:ec2:us-east-1:xxxxxxxxx:network-interface/*", 
       "arn:aws:ec2:us-east-1: xxxxxxxxx:volume/*", 
       "arn:aws:ec2:us-east-1: xxxxxxxxx:key-pair/*", 
       "arn:aws:ec2:us-east-1: xxxxxxxxx:security-group/*", 
       "arn:aws:ec2:us-east-1: xxxxxxxxx:subnet/*" 
      ] 
     }, 
     { 
      "Effect": "Allow", 
      "Action": "ec2:RunInstances", 
      "Resource": [ 
       "arn:aws:ec2:us-east-1: xxxxxxxxx:instance/*" 
      ], 
      "Condition": { 
       "StringEquals": { 
        "ec2:InstanceType": "t2.micro" 
       } 
      } 
     } 
    ] 
} 

問題の原因は何か考えてください。あなたが特定のイメージを定義することができ、また

"arn:aws:ec2:us-east-1::image/ami-*" 

+0

を「私はそれが動作していない者のログインユーザーによるEC2インスタンスを起動しようとします。」 - 何のエラーが出ていますか? –

+0

起動に失敗しました:この操作を実行する権限がありません。 – Venkat

+0

起動しようとしているインスタンスのタイプは何ですか? – Mahdi

答えて

0

私はあなたのポリシーは、以下を欠いだと思う、あなたはec2:*を許可しますが、このポリシーを追加することができます認め制限するよりもむしろ

"arn:aws:ec2:us-east-1::image/ami-xxxxxxxx" 
0

をそのが拒否する t2.micro以外:

{ 
    "Action": [ 
    "ec2:RunInstances" 
    ], 
    "Effect": "Deny", 
    "Resource": "arn:aws:ec2:*:*:instance/*", 
    "Condition": { 
    "StringNotEquals": { 
     "ec2:InstanceType": [ 
     "t2.micro" 
     ] 
    } 
    } 
}, 

しかし、誰かがt2.microを起動して停止し、インスタンスの種類を変更してから、再度起動できるので注意してください!これを防止するために

、あなたが追加することができます:

{ 
    "Action": [ 
    "ec2:ModifyInstanceAttribute" 
    ], 
    "Effect": "Deny", 
    "Resource": "*" 
}, 
関連する問題