AWS-限制组织账户成员的资源访问

AWS-限制组织账户成员的资源访问

我们为客户提供某些 AWS 实验室。每次用户打开实验室时,都会创建一个新的成员帐户并将其添加到组织帐户中。

这只会在用户第一次登录实验室时发生。此成员帐户没有资源限制,可以做任何用户想做的事情。

例如。

  1. 启动任意类型和数量的 ec2 实例。
  2. 创建尽可能多的 s3 存储桶并上传任意大小的文件。
  3. 启动任何类型的 RDS 和 ElastiCache 集群。

这给我们带来了巨大的问题,我们希望根据实验室需要来限制资源。

经过大量研究,我得出了以下结论:

Resource restrictions on OU level using SCP:
1. Deny every service by default.
2. Allow only those services which are used in tasks.
3. Allow those services in 1 particular region only (For e.g. us-east-1)
4. Limit what type of instances can be launched (For e.g. t2.micro only)
5. Limit specific AMI's using which instances can be launched (For e.g. Only free AMI's like ubuntu and linux AMI's, no windows AMI's)
6. Policy for limiting s3 bucket sizes is not possible.

Organisation account removal:
1. Can't remove member account if they don't have required information to become standalone account.
2. This information includes:
    - AWS Customer Agreement
    - choose a support plan
    - provide and verify the required contact information
    - provide a current payment method
3. This can't be automated so the idea is to create 2 OU's "Organisational units".
    - Working accounts
    - Disabled accounts
4. 1st OU will have required permissions to perform the lab tasks only (Principle of least privilege)
5. 2nd OU will have no permissions, Deny All for all services and actions.

管理 OU

https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_ous.html

将账户从一个 OU 移动到另一个 OU 可以编写一个程序来列出“工作账户 OU”下的账户

https://docs.aws.amazon.com/cli/latest/reference/organizations/list-accounts-for-parent.html

从输出中,过滤掉“JoinedTimestamp”参数,对超过 xx 天的账户执行移动操作。

https://docs.aws.amazon.com/cli/latest/reference/organizations/move-account.html

我想向经验丰富的AWS架构师了解“组织单元”的第二部分是否可行。

如果是的话,有人可以帮我弄清楚如何实现它吗,因为我没有太多的编程经验。

答案1

您的方法是有效的。您可以考虑使用 IAM 角色而不是 SCP 来实现大部分功能,尽管 SCP 是中央控制,所以您所要做的就是将帐户放入 OU,所以我认为对于您的情况来说,这比 IAM 策略更好。

您可能希望对依赖其他区域(例如 S3/IAM)的 IAM/S3 等内容使用“拒绝”和“不执行操作”。请注意,这可能是一个相当长的列表。然后是您所在区域允许服务的白名单 - 您可能需要很多,但您会找到它们。

{
  "Version": "2012-10-17",
  "Statement": [
      {
          "Sid": "AllowOutsideSingapore",
          "Effect": "Deny",
          "NotAction": [
              "iam:*",
              "aws-portal:*",
              "organizations:*",                  
              "s3:PutEncryptionConfiguration"
          ],
          "Resource": "*",
          "Condition": {
              "StringNotEquals": {
                  "aws:RequestedRegion": [
                      "ap-southeast-1"
                  ]
              }
          }
      },
      {
          "Sid": "WhitelistAllowedServices",
          "Effect": "Allow",
          "Action": [
              "ec2:*",
              "autoscaling:*"
  }
}

仅强制执行特定 AMI 非常麻烦。您需要创建一个按 AMI ID 列出它们的策略,然后每次发布新 AMI 时都需要手动更新该策略。

抱歉,我无法帮助您解决移动 OU 的问题。此处的替代方法是直接将“拒绝所有”策略附加到 SCP 中的帐户,因为它将覆盖允许权限,或者向其 IAM 角色添加“拒绝所有”权限。

相关内容