附加組織政策 AWS Organizations - AWS Organizations

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

附加組織政策 AWS Organizations

本主題說明如何附加原則 AWS Organizations。 原則會定義您要套用至下列群組的控制項 AWS 帳戶. AWS Organizations 支援管理原則和授權原則。

附加原則 AWS Organizations

最低許可

若要附加原則,您必須具有執行下列動作的權限:

  • organizations:AttachPolicy

最低許可

若要附加SCP至根、OU 或帳戶,您需要執行下列動作的權限:

  • organizations:AttachPolicy在相同政策陳述式中包含一個Resource元素,其中包含指定政策的「*」或 Amazon 資源名稱 (ARN),以及您要附加政策的根、OU 或帳戶 ARN

Backup policies

您可以導覽至政策或連接政策的根、OU 或帳戶,以連接備份政策。

導覽至根、OU 或帳戶以連接備份政策
  1. 登入 AWS Organizations 控制台。您必須以IAM使用者身分登入、擔任IAM角色,或以 root 使用者身分登入 (不建議) 在組織的管理帳戶中。

  2. 在「」 AWS 帳戶」頁面上,瀏覽至您要附加原則的根、OU 或帳戶,然後選擇其名稱。您可能必須展開 OUs (選擇 Gray cloud icon representing cloud computing or storage services. ) 才能找到您想要的 OU 或帳戶。

  3. Policies (政策) 索引標籤的 Backup policies (備份政策) 項目中,選擇 Attach (連接)。

  4. 尋找您所需的政策,然後選擇 Attach policy (連接政策)。

    Policies (政策) 索引標籤上的連接的備份政策清單會更新,以包含新的新增項目。政策變更會立即生效。

導覽至政策以連接備份政策
  1. 登入 AWS Organizations 控制台。您必須以IAM使用者身分登入、擔任IAM角色,或以 root 使用者身分登入 (不建議) 在組織的管理帳戶中。

  2. Backup policies (備份政策) 頁面上,選擇您要連接的政策名稱。

  3. Targets (目標) 索引標籤上,選擇 Attach (連接)。

  4. 選擇您要連接政策的根、OU 或帳戶旁的選項按鈕。您可能必須展開 OUs (選擇 Gray cloud icon representing cloud computing or storage services. ) 才能找到您想要的 OU 或帳戶。

  5. 選擇連接政策

    Targets (目標) 索引標籤上的連接的備份政策清單會更新,以包含新的新增項目。政策變更會立即生效。

Tag policies

您可以導覽至政策或連接政策的根、OU 或帳戶,以連接標籤政策。

導覽至根、OU 或帳戶以連接標籤政策
  1. 登入 AWS Organizations 控制台。您必須以IAM使用者身分登入、擔任IAM角色,或以 root 使用者身分登入 (不建議) 在組織的管理帳戶中。

  2. 在「」 AWS 帳戶」頁面上,瀏覽至您要附加原則的根、OU 或帳戶,然後選擇其名稱。您可能必須展開 OUs (選擇 Gray cloud icon representing cloud computing or storage services. ) 才能找到您想要的 OU 或帳戶。

  3. Policies (政策) 索引標籤的 Tag policies (標籤政策) 項目中,選擇 Attach (連接)。

  4. 尋找您所需的政策,然後選擇 Attach policy (連接政策)。

    Policies (政策) 索引標籤上的連接的標籤政策清單會更新,以包含新的新增項目。政策變更會立即生效。

導覽至政策以連接標籤政策
  1. 登入 AWS Organizations 控制台。您必須以IAM使用者身分登入、擔任IAM角色,或以 root 使用者身分登入 (不建議) 在組織的管理帳戶中。

  2. Tag policies (標籤政策) 頁面上,選擇您要連接的政策名稱。

  3. Targets (目標) 索引標籤上,選擇 Attach (連接)。

  4. 選擇您要連接政策的根、OU 或帳戶旁的選項按鈕。您可能必須展開 OUs (選擇 Gray cloud icon representing cloud computing or storage services. ) 才能找到您想要的 OU 或帳戶。

  5. 選擇連接政策

    Targets (目標) 索引標籤上的連接的標籤政策清單會更新,以包含新的新增項目。政策變更會立即生效。

AI services opt-out policies

您可以導覽至政策或連接政策的根、OU 或帳戶,以連接 AI 服務選擇退出政策。

導覽至根、OU 或帳戶以連接 AI 服務選擇退出政策
  1. 登入 AWS Organizations 控制台。您必須以IAM使用者身分登入、擔任IAM角色,或以 root 使用者身分登入 (不建議) 在組織的管理帳戶中。

  2. 在「」 AWS 帳戶」頁面上,瀏覽至您要附加原則的根、OU 或帳戶,然後選擇其名稱。您可能必須展開 OUs (選擇 Gray cloud icon representing cloud computing or storage services. ) 才能找到您想要的 OU 或帳戶。

  3. Policies (政策) 索引標籤的 AI service opt-out policies (AI 服務選擇退出政策) 項目中,選擇 Attach (連接)。

  4. 尋找您所需的政策,然後選擇 Attach policy (連接政策)。

    Policies (政策) 索引標籤上的連接的 AI 服務選擇退出政策清單會更新,以包含新的新增項目。政策變更會立即生效。

導覽至政策以連接 AI 服務選擇退出政策
  1. 登入 AWS Organizations 控制台。您必須以IAM使用者身分登入、擔任IAM角色,或以 root 使用者身分登入 (不建議) 在組織的管理帳戶中。

  2. AI services opt-out policies (AI 服務選擇退出政策) 頁面上,選擇您要連接的政策名稱。

  3. Targets (目標) 索引標籤上,選擇 Attach (連接)。

  4. 選擇您要連接政策的根、OU 或帳戶旁的選項按鈕。您可能必須展開 OUs (選擇 Gray cloud icon representing cloud computing or storage services. ) 才能找到您想要的 OU 或帳戶。

  5. 選擇連接政策

    Targets (目標) 索引標籤上的連接的 AI 服務選擇退出政策清單會更新,以包含新的新增項目。政策變更會立即生效。

Service control policies (SCPs)

您可以瀏覽至原則或要附加原則的根、OU 或帳戶來附加。SCP

SCP透過瀏覽至根、OU 或帳戶來附加
  1. 登入 AWS Organizations 控制台。您必須以IAM使用者身分登入、擔任IAM角色,或以 root 使用者身分登入 (不建議) 在組織的管理帳戶中。

  2. 在「」 AWS 帳戶頁面上,瀏覽至您要附加的根、OU 或帳戶,然後選擇旁邊的核取方塊。SCP您可能必須展開 OUs (選擇 Gray cloud icon representing cloud computing or storage services. ) 才能找到您想要的 OU 或帳戶。

  3. Policies (政策) 索引標籤的 Service control policies (服務控制政策) 項目中,選擇 Attach (連接)。

  4. 尋找您所需的政策,然後選擇 Attach policy (連接政策)。

    [策略] 索引標籤SCPs上附加的清單會更新為包含新增項目。原則變更會立即生效,影響IAM使用者和角色在連結的根目錄或 OU 下所有帳號的權限。

若要SCP透過瀏覽至原則來附加
  1. 登入 AWS Organizations 控制台。您必須以IAM使用者身分登入、擔任IAM角色,或以 root 使用者身分登入 (不建議) 在組織的管理帳戶中。

  2. Service control policies (服務控制政策) 頁面上,選擇您要連接的政策名稱。

  3. Targets (目標) 索引標籤上,選擇 Attach (連接)。

  4. 選擇您要連接政策的根、OU 或帳戶旁的選項按鈕。您可能必須展開 OUs (選擇 Gray cloud icon representing cloud computing or storage services. ) 才能找到您想要的 OU 或帳戶。

  5. 選擇連接政策

    已更新「目標」標籤SCPs上附加的清單,以包含新增項目。原則變更會立即生效,影響IAM使用者和角色在連結的根目錄或 OU 下所有帳號的權限。

原則變更會立即生效,影響IAM使用者和角色在連結的根目錄或 OU 下所有帳號的權限

若要附加原則

下列程式碼範例會示範如何使用AttachPolicy

.NET
AWS SDK for .NET
注意

還有更多關於 GitHub。尋找完整的範例,並瞭解如何在 AWS 代碼示例存儲庫

using System; using System.Threading.Tasks; using Amazon.Organizations; using Amazon.Organizations.Model; /// <summary> /// Shows how to attach an AWS Organizations policy to an organization, /// an organizational unit, or an account. /// </summary> public class AttachPolicy { /// <summary> /// Initializes the Organizations client object and then calls the /// AttachPolicyAsync method to attach the policy to the root /// organization. /// </summary> public static async Task Main() { IAmazonOrganizations client = new AmazonOrganizationsClient(); var policyId = "p-00000000"; var targetId = "r-0000"; var request = new AttachPolicyRequest { PolicyId = policyId, TargetId = targetId, }; var response = await client.AttachPolicyAsync(request); if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) { Console.WriteLine($"Successfully attached Policy ID {policyId} to Target ID: {targetId}."); } else { Console.WriteLine("Was not successful in attaching the policy."); } } }
  • 有API關詳細資訊,請參閱 AttachPolicyAWS SDK for .NET API參考

CLI
AWS CLI

將策略附加到根、OU 或帳號

範例 1

下列範例顯示如何將服務控制原則 (SCP) 附加至 OU:

aws organizations attach-policy --policy-id p-examplepolicyid111 --target-id ou-examplerootid111-exampleouid111

範例 2

下列範例顯示如何將服務控制原則直接附加至帳戶:

aws organizations attach-policy --policy-id p-examplepolicyid111 --target-id 333333333333
  • 有API關詳細資訊,請參閱 AttachPolicyAWS CLI 指令參考

Python
SDK對於 Python(肉毒桿菌 3)
注意

還有更多關於 GitHub。尋找完整的範例,並瞭解如何在 AWS 代碼示例存儲庫

def attach_policy(policy_id, target_id, orgs_client): """ Attaches a policy to a target. The target is an organization root, account, or organizational unit. :param policy_id: The ID of the policy to attach. :param target_id: The ID of the resources to attach the policy to. :param orgs_client: The Boto3 Organizations client. """ try: orgs_client.attach_policy(PolicyId=policy_id, TargetId=target_id) logger.info("Attached policy %s to target %s.", policy_id, target_id) except ClientError: logger.exception( "Couldn't attach policy %s to target %s.", policy_id, target_id ) raise
  • 有API關詳細資訊,請參閱 AttachPolicyAWS SDK對於 Python(肉毒桿 3)API參考。

原則變更會立即生效,影響IAM使用者和角色在連結的根目錄或 OU 下所有帳號的權限