ablog

不器用で落着きのない技術者のメモ

AWS Organizations の Service Control Policy で OU で Allow した権限を所属するアカウントで Deny すると

AWS Organizations で Organizations Unit (OU) にアタッチしている Service Control Policy (SCP)で Deny している権限を、所属しているアカウントにアタッチする SCP で Allow しても上書きされないことを確認した。


Internet Gateway (IGW) の作成・アタッチを許可するSCP「IGWAllow」と拒否する SCP「IGWDeny」を作成する。

  • IGWAllow
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1535967122000",
            "Effect": "Allow",
            "Action": [
                "ec2:AttachInternetGateway",
                "ec2:CreateInternetGateway"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}
  • IGWDeny
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1535819596000",
            "Effect": "Deny",
            "Action": [
                "ec2:AttachInternetGateway",
                "ec2:CreateInternetGateway"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}

PrivateOU に IGWDeny をアタッチし、所属するアカウント(Yohei Azekatsu 2)に IGWAllow をアタッチする。

アカウント(Yohei Azekatsu 2)で IGW を作成しようとすると失敗する。

ドキュメントにも以下の通り記載されている。

An OU at the next level down gets the mathematical intersection of the permissions that flow down from the parent root and the SCPs that are attached to the OU. In other words, any account has only those permissions permitted by every parent above it. If a permission is blocked at any level above the account, either implicitly (by not being included in an Allow policy statement) or explicitly (by being included in a Deny policy statement), a user or role in the affected account cannot use that permission, even if the account administrator attaches the AdministratorAccess IAM policy with */* permissions to the user.

サービスコントロールポリシー - AWS Organizations