スキップしてコンテンツを表示

IAM policy for EC2

0

Please provide me a sample for AWS IAM policy regarding EC2 for restart only

質問済み 3ヶ月前62ビュー
2回答
5
承認された回答

Take this:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowRebootEC2Instances",
      "Effect": "Allow",
      "Action": "ec2:RebootInstances",
      "Resource": "*"
    },
    {
      "Sid": "DenyOtherEC2Actions",
      "Effect": "Deny",
      "Action": [
        "ec2:StartInstances",
        "ec2:StopInstances",
        "ec2:TerminateInstances",
        "ec2:ModifyInstanceAttribute"
      ],
      "Resource": "*"
    }
  ]
}
エキスパート
回答済み 3ヶ月前
AWS
エキスパート
レビュー済み 3ヶ月前
1

Here's a sample IAM policy that grants permissions to restart (stop and start) EC2 instances:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:StartInstances",
"ec2:StopInstances"
],
"Resource": "*"
}
]
}

This policy allows the user, group, or role it's attached to perform only the StartInstances and StopInstances actions on any EC2 instance.

If you want to restrict this permission to specific instances, you can modify the Resource element to specify the ARNs of those instances.

For more granular control, you could also implement tag-based access control. For example, you could create a policy that only allows users to start or stop instances that have the same "CostCenter" tag value as the user attempting the action.
Sources
Identity-based policies for Amazon EC2 - Amazon Elastic Compute Cloud
EC2: Start or stop instances based on matching principal and resource tags - AWS Identity and Access Management

回答済み 3ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

関連するコンテンツ