EC2 类型的 AWS SCP

AWS SCP for EC2 type

我只想允许用户创建 t2.micro/small/medium 用于开发,并允许他们仅使用 spot 实例。已创建 IAM 策略以限制 type/size 个实例。此外,我想限制“按需”实例(团队必须仅选择现场实例)。实现它的更清洁的方法是什么?

试试 AWS Service Catalog。这正是可以帮助您的服务。

在您的 IAM 策略中使用 ec2:InstanceMarketType 条件键。

示例(未经测试):

{
    "Version": "2012-10-17",
    "Statement": {
        "Effect": "Allow",
        "Action": "*",
        "Resource": "*",
        "Condition": {
            "StringEquals": {
                "ec2:InstanceMarketType": "spot"
            }
        }
    }
}

参考文献:

允许使用该帐户进行完全访问

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "limitedSize",
      "Effect": "Deny",
      "Action": [
        "ec2:RunInstances",
        "cloudwatch:DescribeAlarms"
      ],
      "Resource": [
        "arn:aws:ec2:*:*:instance/*"
      ],
      "Condition": {
        "ForAnyValue:StringNotLike": {
          "ec2:InstanceType": [
            "t3.*",
            "t2.*"
          ]
        }
      }
    }
  ]
}