選取您的 Cookie 偏好設定

我們使用提供自身網站和服務所需的基本 Cookie 和類似工具。我們使用效能 Cookie 收集匿名統計資料,以便了解客戶如何使用我們的網站並進行改進。基本 Cookie 無法停用,但可以按一下「自訂」或「拒絕」以拒絕效能 Cookie。

如果您同意,AWS 與經核准的第三方也會使用 Cookie 提供實用的網站功能、記住您的偏好設定,並顯示相關內容,包括相關廣告。若要接受或拒絕所有非必要 Cookie,請按一下「接受」或「拒絕」。若要進行更詳細的選擇,請按一下「自訂」。

使用 的組織範例 AWS CLI - AWS SDK 程式碼範例

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例

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

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例

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

使用 的組織範例 AWS CLI

下列程式碼範例示範如何使用 AWS Command Line Interface 搭配 Organizations 來執行動作和實作常見案例。

Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數,但您可以在其相關情境中查看內容中的動作。

每個範例都包含完整原始程式碼的連結,您可以在其中找到如何在內容中設定和執行程式碼的指示。

主題

動作

下列程式碼範例示範如何使用 accept-handshake

AWS CLI

接受來自另一個帳戶的交握

組織擁有者 Bill 先前已邀請 Juan 的帳戶加入他的組織。下列範例顯示 Juan 的帳戶接受交握,因此同意邀請。

aws organizations accept-handshake --handshake-id h-examplehandshakeid111

輸出顯示下列項目:

{ "Handshake": { "Action": "INVITE", "Arn": "arn:aws:organizations::111111111111:handshake/o-exampleorgid/invite/h-examplehandshakeid111", "RequestedTimestamp": 1481656459.257, "ExpirationTimestamp": 1482952459.257, "Id": "h-examplehandshakeid111", "Parties": [ { "Id": "o-exampleorgid", "Type": "ORGANIZATION" }, { "Id": "juan@example.com", "Type": "EMAIL" } ], "Resources": [ { "Resources": [ { "Type": "MASTER_EMAIL", "Value": "bill@amazon.com" }, { "Type": "MASTER_NAME", "Value": "Org Master Account" }, { "Type": "ORGANIZATION_FEATURE_SET", "Value": "ALL" } ], "Type": "ORGANIZATION", "Value": "o-exampleorgid" }, { "Type": "EMAIL", "Value": "juan@example.com" } ], "State": "ACCEPTED" } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 AcceptHandshake

下列程式碼範例示範如何使用 accept-handshake

AWS CLI

接受來自另一個帳戶的交握

組織擁有者 Bill 先前已邀請 Juan 的帳戶加入他的組織。下列範例顯示 Juan 的帳戶接受交握,因此同意邀請。

aws organizations accept-handshake --handshake-id h-examplehandshakeid111

輸出顯示下列項目:

{ "Handshake": { "Action": "INVITE", "Arn": "arn:aws:organizations::111111111111:handshake/o-exampleorgid/invite/h-examplehandshakeid111", "RequestedTimestamp": 1481656459.257, "ExpirationTimestamp": 1482952459.257, "Id": "h-examplehandshakeid111", "Parties": [ { "Id": "o-exampleorgid", "Type": "ORGANIZATION" }, { "Id": "juan@example.com", "Type": "EMAIL" } ], "Resources": [ { "Resources": [ { "Type": "MASTER_EMAIL", "Value": "bill@amazon.com" }, { "Type": "MASTER_NAME", "Value": "Org Master Account" }, { "Type": "ORGANIZATION_FEATURE_SET", "Value": "ALL" } ], "Type": "ORGANIZATION", "Value": "o-exampleorgid" }, { "Type": "EMAIL", "Value": "juan@example.com" } ], "State": "ACCEPTED" } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 AcceptHandshake

下列程式碼範例示範如何使用 attach-policy

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 詳細資訊,請參閱 AWS CLI 命令參考中的 AttachPolicy

下列程式碼範例示範如何使用 attach-policy

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 詳細資訊,請參閱 AWS CLI 命令參考中的 AttachPolicy

下列程式碼範例示範如何使用 cancel-handshake

AWS CLI

取消從另一個帳戶傳送的交握

Bill 先前已傳送邀請給 Susan 的帳戶加入他的組織。他改變主意,決定在 Susan 接受邀請之前取消邀請。下列範例顯示 Bill 的取消:

aws organizations cancel-handshake --handshake-id h-examplehandshakeid111

輸出包含交握物件,顯示狀態現在為 CANCELED

{ "Handshake": { "Id": "h-examplehandshakeid111", "State":"CANCELED", "Action": "INVITE", "Arn": "arn:aws:organizations::111111111111:handshake/o-exampleorgid/invite/h-examplehandshakeid111", "Parties": [ { "Id": "o-exampleorgid", "Type": "ORGANIZATION" }, { "Id": "susan@example.com", "Type": "EMAIL" } ], "Resources": [ { "Type": "ORGANIZATION", "Value": "o-exampleorgid", "Resources": [ { "Type": "MASTER_EMAIL", "Value": "bill@example.com" }, { "Type": "MASTER_NAME", "Value": "Master Account" }, { "Type": "ORGANIZATION_FEATURE_SET", "Value": "CONSOLIDATED_BILLING" } ] }, { "Type": "EMAIL", "Value": "anika@example.com" }, { "Type": "NOTES", "Value": "This is a request for Susan's account to join Bob's organization." } ], "RequestedTimestamp": 1.47008383521E9, "ExpirationTimestamp": 1.47137983521E9 } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 CancelHandshake

下列程式碼範例示範如何使用 cancel-handshake

AWS CLI

取消從另一個帳戶傳送的交握

Bill 先前已傳送邀請給 Susan 的帳戶加入他的組織。他改變主意,決定在 Susan 接受邀請之前取消邀請。下列範例顯示 Bill 的取消:

aws organizations cancel-handshake --handshake-id h-examplehandshakeid111

輸出包含交握物件,顯示狀態現在為 CANCELED

{ "Handshake": { "Id": "h-examplehandshakeid111", "State":"CANCELED", "Action": "INVITE", "Arn": "arn:aws:organizations::111111111111:handshake/o-exampleorgid/invite/h-examplehandshakeid111", "Parties": [ { "Id": "o-exampleorgid", "Type": "ORGANIZATION" }, { "Id": "susan@example.com", "Type": "EMAIL" } ], "Resources": [ { "Type": "ORGANIZATION", "Value": "o-exampleorgid", "Resources": [ { "Type": "MASTER_EMAIL", "Value": "bill@example.com" }, { "Type": "MASTER_NAME", "Value": "Master Account" }, { "Type": "ORGANIZATION_FEATURE_SET", "Value": "CONSOLIDATED_BILLING" } ] }, { "Type": "EMAIL", "Value": "anika@example.com" }, { "Type": "NOTES", "Value": "This is a request for Susan's account to join Bob's organization." } ], "RequestedTimestamp": 1.47008383521E9, "ExpirationTimestamp": 1.47137983521E9 } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 CancelHandshake

下列程式碼範例示範如何使用 create-account

AWS CLI

建立自動成為組織一部分的成員帳戶

下列範例示範如何在組織中建立成員帳戶。成員帳戶是以生產帳戶名稱和 susan@example.com 的電子郵件地址來設定。Organizations 會使用 OrganizationAccountAccessRole 的預設名稱自動建立 IAM 角色,因為未指定 roleName 參數。此外,由於未指定 IamUserAccessToBilling 參數,因此允許具有足夠許可存取帳戶帳單資料的 IAM 使用者或角色的設定會設定為預設值 ALLOW。組織會自動傳送「歡迎 AWS」電子郵件給 Susan:

aws organizations create-account --email susan@example.com --account-name "Production Account"

輸出包含一個請求物件,顯示狀態現在為 IN_PROGRESS

{ "CreateAccountStatus": { "State": "IN_PROGRESS", "Id": "car-examplecreateaccountrequestid111" } }

您稍後可以透過提供 Id 回應值給 describe-create-account-status 命令做為 create-account-request-id 參數的值,來查詢請求的目前狀態。

如需詳細資訊,請參閱《 AWS Organizations 使用者指南》中的在您的組織中建立 AWS 帳戶。

  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 CreateAccount

下列程式碼範例示範如何使用 create-account

AWS CLI

建立自動成為組織一部分的成員帳戶

下列範例示範如何在組織中建立成員帳戶。成員帳戶是以生產帳戶名稱和 susan@example.com 的電子郵件地址來設定。Organizations 會使用 OrganizationAccountAccessRole 的預設名稱自動建立 IAM 角色,因為未指定 roleName 參數。此外,由於未指定 IamUserAccessToBilling 參數,因此允許具有足夠許可存取帳戶帳單資料的 IAM 使用者或角色的設定會設定為預設值 ALLOW。組織會自動傳送「歡迎 AWS」電子郵件給 Susan:

aws organizations create-account --email susan@example.com --account-name "Production Account"

輸出包含一個請求物件,顯示狀態現在為 IN_PROGRESS

{ "CreateAccountStatus": { "State": "IN_PROGRESS", "Id": "car-examplecreateaccountrequestid111" } }

您稍後可以透過提供 Id 回應值給 describe-create-account-status 命令做為 create-account-request-id 參數的值,來查詢請求的目前狀態。

如需詳細資訊,請參閱《 AWS Organizations 使用者指南》中的在您的組織中建立 AWS 帳戶。

  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 CreateAccount

下列程式碼範例示範如何使用 create-organization

AWS CLI

範例 1:建立新組織

Bill 想要使用來自帳戶 111111111111 的登入資料來建立組織。下列範例顯示帳戶成為新組織中的主要帳戶。由於他未指定功能集,因此新組織預設為啟用的所有功能,且服務控制政策會在根上啟用。

aws organizations create-organization

輸出包含組織物件,其中包含新組織的詳細資訊:

{ "Organization": { "AvailablePolicyTypes": [ { "Status": "ENABLED", "Type": "SERVICE_CONTROL_POLICY" } ], "MasterAccountId": "111111111111", "MasterAccountArn": "arn:aws:organizations::111111111111:account/o-exampleorgid/111111111111", "MasterAccountEmail": "bill@example.com", "FeatureSet": "ALL", "Id": "o-exampleorgid", "Arn": "arn:aws:organizations::111111111111:organization/o-exampleorgid" } }

範例 2:建立僅啟用合併帳單功能的新組織

下列範例會建立僅支援合併帳單功能的組織:

aws organizations create-organization --feature-set CONSOLIDATED_BILLING

輸出包含組織物件,其中包含新組織的詳細資訊:

{ "Organization": { "Arn": "arn:aws:organizations::111111111111:organization/o-exampleorgid", "AvailablePolicyTypes": [], "Id": "o-exampleorgid", "MasterAccountArn": "arn:aws:organizations::111111111111:account/o-exampleorgid/111111111111", "MasterAccountEmail": "bill@example.com", "MasterAccountId": "111111111111", "FeatureSet": "CONSOLIDATED_BILLING" } }

如需詳細資訊,請參閱《 AWS Organizations 使用者指南》中的建立組織

下列程式碼範例示範如何使用 create-organization

AWS CLI

範例 1:建立新組織

Bill 想要使用來自帳戶 111111111111 的登入資料來建立組織。下列範例顯示帳戶成為新組織中的主要帳戶。由於他未指定功能集,因此新組織預設為啟用的所有功能,且服務控制政策會在根上啟用。

aws organizations create-organization

輸出包含組織物件,其中包含新組織的詳細資訊:

{ "Organization": { "AvailablePolicyTypes": [ { "Status": "ENABLED", "Type": "SERVICE_CONTROL_POLICY" } ], "MasterAccountId": "111111111111", "MasterAccountArn": "arn:aws:organizations::111111111111:account/o-exampleorgid/111111111111", "MasterAccountEmail": "bill@example.com", "FeatureSet": "ALL", "Id": "o-exampleorgid", "Arn": "arn:aws:organizations::111111111111:organization/o-exampleorgid" } }

範例 2:建立僅啟用合併帳單功能的新組織

下列範例會建立僅支援合併帳單功能的組織:

aws organizations create-organization --feature-set CONSOLIDATED_BILLING

輸出包含組織物件,其中包含新組織的詳細資訊:

{ "Organization": { "Arn": "arn:aws:organizations::111111111111:organization/o-exampleorgid", "AvailablePolicyTypes": [], "Id": "o-exampleorgid", "MasterAccountArn": "arn:aws:organizations::111111111111:account/o-exampleorgid/111111111111", "MasterAccountEmail": "bill@example.com", "MasterAccountId": "111111111111", "FeatureSet": "CONSOLIDATED_BILLING" } }

如需詳細資訊,請參閱《 AWS Organizations 使用者指南》中的建立組織

下列程式碼範例示範如何使用 create-organizational-unit

AWS CLI

在根或父 OU 中建立 OU

下列範例示範如何建立名為 AccountingOU 的 OU:

aws organizations create-organizational-unit --parent-id r-examplerootid111 --name AccountingOU

輸出包含 organizationalUnit 物件,其中包含新 OU 的詳細資訊:

{ "OrganizationalUnit": { "Id": "ou-examplerootid111-exampleouid111", "Arn": "arn:aws:organizations::111111111111:ou/o-exampleorgid/ou-examplerootid111-exampleouid111", "Name": "AccountingOU" } }

下列程式碼範例示範如何使用 create-organizational-unit

AWS CLI

在根或父 OU 中建立 OU

下列範例示範如何建立名為 AccountingOU 的 OU:

aws organizations create-organizational-unit --parent-id r-examplerootid111 --name AccountingOU

輸出包含 organizationalUnit 物件,其中包含新 OU 的詳細資訊:

{ "OrganizationalUnit": { "Id": "ou-examplerootid111-exampleouid111", "Arn": "arn:aws:organizations::111111111111:ou/o-exampleorgid/ou-examplerootid111-exampleouid111", "Name": "AccountingOU" } }

下列程式碼範例示範如何使用 create-policy

AWS CLI

範例 1:使用 JSON 政策的文字來源檔案建立政策

下列範例示範如何建立名為 的服務控制政策 (SCP)AllowAllS3Actions。政策內容是從本機電腦上名為 的檔案取得policy.json

aws organizations create-policy --content file://policy.json --name AllowAllS3Actions, --type SERVICE_CONTROL_POLICY --description "Allows delegation of all S3 actions"

輸出包含政策物件,其中包含新政策的詳細資訊:

{ "Policy": { "Content": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"s3:*\"],\"Resource\":[\"*\"]}]}", "PolicySummary": { "Arn": "arn:aws:organizations::o-exampleorgid:policy/service_control_policy/p-examplepolicyid111", "Description": "Allows delegation of all S3 actions", "Name": "AllowAllS3Actions", "Type":"SERVICE_CONTROL_POLICY" } } }

範例 2:使用 JSON 政策做為參數來建立政策

下列範例示範如何建立相同的 SCP,這次在 參數中將政策內容內嵌為 JSON 字串。字串必須在雙引號之前以反斜線逸出,以確保它們在 參數中被視為常值,而參數本身被雙引號包圍:

aws organizations create-policy --content "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"s3:*\"],\"Resource\":[\"*\"]}]}" --name AllowAllS3Actions --type SERVICE_CONTROL_POLICY --description "Allows delegation of all S3 actions"

如需在組織中建立和使用政策的詳細資訊,請參閱《 AWS Organizations 使用者指南》中的管理組織政策。

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 CreatePolicy

下列程式碼範例示範如何使用 create-policy

AWS CLI

範例 1:使用 JSON 政策的文字來源檔案建立政策

下列範例示範如何建立名為 的服務控制政策 (SCP)AllowAllS3Actions。政策內容是從本機電腦上名為 的檔案取得policy.json

aws organizations create-policy --content file://policy.json --name AllowAllS3Actions, --type SERVICE_CONTROL_POLICY --description "Allows delegation of all S3 actions"

輸出包含政策物件,其中包含新政策的詳細資訊:

{ "Policy": { "Content": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"s3:*\"],\"Resource\":[\"*\"]}]}", "PolicySummary": { "Arn": "arn:aws:organizations::o-exampleorgid:policy/service_control_policy/p-examplepolicyid111", "Description": "Allows delegation of all S3 actions", "Name": "AllowAllS3Actions", "Type":"SERVICE_CONTROL_POLICY" } } }

範例 2:使用 JSON 政策做為參數來建立政策

下列範例示範如何建立相同的 SCP,這次在 參數中將政策內容內嵌為 JSON 字串。字串必須在雙引號之前以反斜線逸出,以確保它們在 參數中被視為常值,而參數本身被雙引號包圍:

aws organizations create-policy --content "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"s3:*\"],\"Resource\":[\"*\"]}]}" --name AllowAllS3Actions --type SERVICE_CONTROL_POLICY --description "Allows delegation of all S3 actions"

如需在組織中建立和使用政策的詳細資訊,請參閱《 AWS Organizations 使用者指南》中的管理組織政策。

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 CreatePolicy

下列程式碼範例示範如何使用 decline-handshake

AWS CLI

拒絕從另一個帳戶傳送的交握

下列範例顯示,帳戶 222222222222 擁有者的管理員 Susan 拒絕加入 Bill 組織的邀請。DeclineHandshake 操作會傳回交握物件,顯示狀態現在為 DECLINED:

aws organizations decline-handshake --handshake-id h-examplehandshakeid111

輸出包含交握物件,顯示 的新狀態DECLINED

{ "Handshake": { "Id": "h-examplehandshakeid111", "State": "DECLINED", "Resources": [ { "Type": "ORGANIZATION", "Value": "o-exampleorgid", "Resources": [ { "Type": "MASTER_EMAIL", "Value": "bill@example.com" }, { "Type": "MASTER_NAME", "Value": "Master Account" } ] }, { "Type": "EMAIL", "Value": "susan@example.com" }, { "Type": "NOTES", "Value": "This is an invitation to Susan's account to join the Bill's organization." } ], "Parties": [ { "Type": "EMAIL", "Id": "susan@example.com" }, { "Type": "ORGANIZATION", "Id": "o-exampleorgid" } ], "Action": "INVITE", "RequestedTimestamp": 1470684478.687, "ExpirationTimestamp": 1471980478.687, "Arn": "arn:aws:organizations::111111111111:handshake/o-exampleorgid/invite/h-examplehandshakeid111" } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DeclineHandshake

下列程式碼範例示範如何使用 decline-handshake

AWS CLI

拒絕從另一個帳戶傳送的交握

下列範例顯示,帳戶 222222222222 擁有者的管理員 Susan 拒絕加入 Bill 組織的邀請。DeclineHandshake 操作會傳回交握物件,顯示狀態現在為 DECLINED:

aws organizations decline-handshake --handshake-id h-examplehandshakeid111

輸出包含交握物件,顯示 的新狀態DECLINED

{ "Handshake": { "Id": "h-examplehandshakeid111", "State": "DECLINED", "Resources": [ { "Type": "ORGANIZATION", "Value": "o-exampleorgid", "Resources": [ { "Type": "MASTER_EMAIL", "Value": "bill@example.com" }, { "Type": "MASTER_NAME", "Value": "Master Account" } ] }, { "Type": "EMAIL", "Value": "susan@example.com" }, { "Type": "NOTES", "Value": "This is an invitation to Susan's account to join the Bill's organization." } ], "Parties": [ { "Type": "EMAIL", "Id": "susan@example.com" }, { "Type": "ORGANIZATION", "Id": "o-exampleorgid" } ], "Action": "INVITE", "RequestedTimestamp": 1470684478.687, "ExpirationTimestamp": 1471980478.687, "Arn": "arn:aws:organizations::111111111111:handshake/o-exampleorgid/invite/h-examplehandshakeid111" } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DeclineHandshake

下列程式碼範例示範如何使用 delete-organization

AWS CLI

刪除組織

下列範例示範如何刪除組織。若要執行此操作,您必須是組織中主要帳戶的管理員。此範例假設您先前已從組織移除所有成員帳戶、OUs 和政策:

aws organizations delete-organization

下列程式碼範例示範如何使用 delete-organization

AWS CLI

刪除組織

下列範例示範如何刪除組織。若要執行此操作,您必須是組織中主要帳戶的管理員。此範例假設您先前已從組織移除所有成員帳戶、OUs 和政策:

aws organizations delete-organization

下列程式碼範例示範如何使用 delete-organizational-unit

AWS CLI

刪除 OU

下列範例顯示如何刪除 OU。此範例假設您先前已從 OUs 移除所有帳戶和其他 OU:

aws organizations delete-organizational-unit --organizational-unit-id ou-examplerootid111-exampleouid111

下列程式碼範例示範如何使用 delete-organizational-unit

AWS CLI

刪除 OU

下列範例顯示如何刪除 OU。此範例假設您先前已從 OUs 移除所有帳戶和其他 OU:

aws organizations delete-organizational-unit --organizational-unit-id ou-examplerootid111-exampleouid111

下列程式碼範例示範如何使用 delete-policy

AWS CLI

刪除政策

下列範例示範如何從組織刪除政策。此範例假設您先前已從所有實體分離政策:

aws organizations delete-policy --policy-id p-examplepolicyid111
  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 DeletePolicy

下列程式碼範例示範如何使用 delete-policy

AWS CLI

刪除政策

下列範例示範如何從組織刪除政策。此範例假設您先前已從所有實體分離政策:

aws organizations delete-policy --policy-id p-examplepolicyid111
  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 DeletePolicy

下列程式碼範例示範如何使用 describe-account

AWS CLI

取得帳戶的詳細資訊

下列範例示範如何請求帳戶的詳細資訊:

aws organizations describe-account --account-id 555555555555

輸出會顯示帳戶物件,其中包含帳戶的詳細資訊:

{ "Account": { "Id": "555555555555", "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/555555555555", "Name": "Beta account", "Email": "anika@example.com", "JoinedMethod": "INVITED", "JoinedTimeStamp": 1481756563.134, "Status": "ACTIVE" } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DescribeAccount

下列程式碼範例示範如何使用 describe-account

AWS CLI

取得帳戶的詳細資訊

下列範例示範如何請求帳戶的詳細資訊:

aws organizations describe-account --account-id 555555555555

輸出會顯示帳戶物件,其中包含帳戶的詳細資訊:

{ "Account": { "Id": "555555555555", "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/555555555555", "Name": "Beta account", "Email": "anika@example.com", "JoinedMethod": "INVITED", "JoinedTimeStamp": 1481756563.134, "Status": "ACTIVE" } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DescribeAccount

下列程式碼範例示範如何使用 describe-create-account-status

AWS CLI

若要取得建立帳戶之請求的最新狀態

下列範例示範如何為先前的請求請求請求最新狀態,以在組織中建立帳戶。指定的 --request-id 來自原始呼叫 create-account 的回應。帳戶建立請求會依狀態欄位顯示 Organizations 已成功完成帳戶建立。

命令:

aws organizations describe-create-account-status --create-account-request-id car-examplecreateaccountrequestid111

輸出:

{ "CreateAccountStatus": { "State": "SUCCEEDED", "AccountId": "555555555555", "AccountName": "Beta account", "RequestedTimestamp": 1470684478.687, "CompletedTimestamp": 1470684532.472, "Id": "car-examplecreateaccountrequestid111" } }

下列程式碼範例示範如何使用 describe-create-account-status

AWS CLI

若要取得建立帳戶之請求的最新狀態

下列範例示範如何為先前的請求請求請求最新狀態,以在組織中建立帳戶。指定的 --request-id 來自原始呼叫 create-account 的回應。帳戶建立請求會依狀態欄位顯示 Organizations 已成功完成帳戶建立。

命令:

aws organizations describe-create-account-status --create-account-request-id car-examplecreateaccountrequestid111

輸出:

{ "CreateAccountStatus": { "State": "SUCCEEDED", "AccountId": "555555555555", "AccountName": "Beta account", "RequestedTimestamp": 1470684478.687, "CompletedTimestamp": 1470684532.472, "Id": "car-examplecreateaccountrequestid111" } }

下列程式碼範例示範如何使用 describe-handshake

AWS CLI

取得交握的相關資訊

下列範例示範如何請求交握的詳細資訊。交握 ID 來自對 的原始呼叫InviteAccountToOrganization,或來自對 ListHandshakesForAccount或 的呼叫ListHandshakesForOrganization

aws organizations describe-handshake --handshake-id h-examplehandshakeid111

輸出包含交握物件,其中包含所請求交握的所有詳細資訊:

{ "Handshake": { "Id": "h-examplehandshakeid111", "State": "OPEN", "Resources": [ { "Type": "ORGANIZATION", "Value": "o-exampleorgid", "Resources": [ { "Type": "MASTER_EMAIL", "Value": "bill@example.com" }, { "Type": "MASTER_NAME", "Value": "Master Account" } ] }, { "Type": "EMAIL", "Value": "anika@example.com" } ], "Parties": [ { "Type": "ORGANIZATION", "Id": "o-exampleorgid" }, { "Type": "EMAIL", "Id": "anika@example.com" } ], "Action": "INVITE", "RequestedTimestamp": 1470158698.046, "ExpirationTimestamp": 1471454698.046, "Arn": "arn:aws:organizations::111111111111:handshake/o-exampleorgid/invite/h-examplehandshakeid111" } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DescribeHandshake

下列程式碼範例示範如何使用 describe-handshake

AWS CLI

取得交握的相關資訊

下列範例示範如何請求交握的詳細資訊。交握 ID 來自對 的原始呼叫InviteAccountToOrganization,或來自對 ListHandshakesForAccount或 的呼叫ListHandshakesForOrganization

aws organizations describe-handshake --handshake-id h-examplehandshakeid111

輸出包含交握物件,其中包含所請求交握的所有詳細資訊:

{ "Handshake": { "Id": "h-examplehandshakeid111", "State": "OPEN", "Resources": [ { "Type": "ORGANIZATION", "Value": "o-exampleorgid", "Resources": [ { "Type": "MASTER_EMAIL", "Value": "bill@example.com" }, { "Type": "MASTER_NAME", "Value": "Master Account" } ] }, { "Type": "EMAIL", "Value": "anika@example.com" } ], "Parties": [ { "Type": "ORGANIZATION", "Id": "o-exampleorgid" }, { "Type": "EMAIL", "Id": "anika@example.com" } ], "Action": "INVITE", "RequestedTimestamp": 1470158698.046, "ExpirationTimestamp": 1471454698.046, "Arn": "arn:aws:organizations::111111111111:handshake/o-exampleorgid/invite/h-examplehandshakeid111" } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DescribeHandshake

下列程式碼範例示範如何使用 describe-organization

AWS CLI

取得目前組織的相關資訊

下列範例示範如何請求有關組織的詳細資訊:

aws organizations describe-organization

輸出包含具有組織詳細資訊的組織物件:

{ "Organization": { "MasterAccountArn": "arn:aws:organizations::111111111111:account/o-exampleorgid/111111111111", "MasterAccountEmail": "bill@example.com", "MasterAccountId": "111111111111", "Id": "o-exampleorgid", "FeatureSet": "ALL", "Arn": "arn:aws:organizations::111111111111:organization/o-exampleorgid", "AvailablePolicyTypes": [ { "Status": "ENABLED", "Type": "SERVICE_CONTROL_POLICY" } ] } }

下列程式碼範例示範如何使用 describe-organization

AWS CLI

取得目前組織的相關資訊

下列範例示範如何請求有關組織的詳細資訊:

aws organizations describe-organization

輸出包含具有組織詳細資訊的組織物件:

{ "Organization": { "MasterAccountArn": "arn:aws:organizations::111111111111:account/o-exampleorgid/111111111111", "MasterAccountEmail": "bill@example.com", "MasterAccountId": "111111111111", "Id": "o-exampleorgid", "FeatureSet": "ALL", "Arn": "arn:aws:organizations::111111111111:organization/o-exampleorgid", "AvailablePolicyTypes": [ { "Status": "ENABLED", "Type": "SERVICE_CONTROL_POLICY" } ] } }

下列程式碼範例示範如何使用 describe-organizational-unit

AWS CLI

取得 OU 的相關資訊

下列describe-organizational-unit範例會請求 OU 的詳細資訊。

aws organizations describe-organizational-unit \ --organizational-unit-id ou-examplerootid111-exampleouid111

輸出:

{ "OrganizationalUnit": { "Name": "Accounting Group", "Arn": "arn:aws:organizations::123456789012:ou/o-exampleorgid/ou-examplerootid111-exampleouid111", "Id": "ou-examplerootid111-exampleouid111" } }

下列程式碼範例示範如何使用 describe-organizational-unit

AWS CLI

取得 OU 的相關資訊

下列describe-organizational-unit範例會請求 OU 的詳細資訊。

aws organizations describe-organizational-unit \ --organizational-unit-id ou-examplerootid111-exampleouid111

輸出:

{ "OrganizationalUnit": { "Name": "Accounting Group", "Arn": "arn:aws:organizations::123456789012:ou/o-exampleorgid/ou-examplerootid111-exampleouid111", "Id": "ou-examplerootid111-exampleouid111" } }

下列程式碼範例示範如何使用 describe-policy

AWS CLI

取得政策的相關資訊

下列範例示範如何請求政策的相關資訊:

aws organizations describe-policy --policy-id p-examplepolicyid111

輸出包含政策物件,其中包含政策的詳細資訊:

{ "Policy": { "Content": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": \"*\",\n \"Resource\": \"*\"\n }\n ]\n}", "PolicySummary": { "Arn": "arn:aws:organizations::111111111111:policy/o-exampleorgid/service_control_policy/p-examplepolicyid111", "Type": "SERVICE_CONTROL_POLICY", "Id": "p-examplepolicyid111", "AwsManaged": false, "Name": "AllowAllS3Actions", "Description": "Enables admins to delegate S3 permissions" } } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DescribePolicy

下列程式碼範例示範如何使用 describe-policy

AWS CLI

取得政策的相關資訊

下列範例示範如何請求政策的相關資訊:

aws organizations describe-policy --policy-id p-examplepolicyid111

輸出包含政策物件,其中包含政策的詳細資訊:

{ "Policy": { "Content": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": \"*\",\n \"Resource\": \"*\"\n }\n ]\n}", "PolicySummary": { "Arn": "arn:aws:organizations::111111111111:policy/o-exampleorgid/service_control_policy/p-examplepolicyid111", "Type": "SERVICE_CONTROL_POLICY", "Id": "p-examplepolicyid111", "AwsManaged": false, "Name": "AllowAllS3Actions", "Description": "Enables admins to delegate S3 permissions" } } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DescribePolicy

下列程式碼範例示範如何使用 detach-policy

AWS CLI

從根帳戶、OU 或帳戶分離政策

下列範例示範如何從 OU 分離政策:

aws organizations detach-policy --target-id ou-examplerootid111-exampleouid111 --policy-id p-examplepolicyid111
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DetachPolicy

下列程式碼範例示範如何使用 detach-policy

AWS CLI

從根帳戶、OU 或帳戶分離政策

下列範例示範如何從 OU 分離政策:

aws organizations detach-policy --target-id ou-examplerootid111-exampleouid111 --policy-id p-examplepolicyid111
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DetachPolicy

下列程式碼範例示範如何使用 disable-policy-type

AWS CLI

在根目錄中停用政策類型

下列範例示範如何在根目錄中停用服務控制政策 (SCP) 政策類型:

aws organizations disable-policy-type --root-id r-examplerootid111 --policy-type SERVICE_CONTROL_POLICY

輸出顯示 PolicyTypes 回應元素不再包含 SERVICE_CONTROL_POLICY:

{ "Root": { "PolicyTypes": [], "Name": "Root", "Id": "r-examplerootid111", "Arn": "arn:aws:organizations::111111111111:root/o-exampleorgid/r-examplerootid111" } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DisablePolicyType

下列程式碼範例示範如何使用 disable-policy-type

AWS CLI

在根目錄中停用政策類型

下列範例示範如何在根目錄中停用服務控制政策 (SCP) 政策類型:

aws organizations disable-policy-type --root-id r-examplerootid111 --policy-type SERVICE_CONTROL_POLICY

輸出顯示 PolicyTypes 回應元素不再包含 SERVICE_CONTROL_POLICY:

{ "Root": { "PolicyTypes": [], "Name": "Root", "Id": "r-examplerootid111", "Arn": "arn:aws:organizations::111111111111:root/o-exampleorgid/r-examplerootid111" } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DisablePolicyType

下列程式碼範例示範如何使用 enable-all-features

AWS CLI

啟用組織中的所有功能

此範例顯示管理員要求組織中的所有受邀帳戶核准組織中已啟用的所有功能。 AWS 組織會傳送電子郵件到向每個受邀成員帳戶註冊的地址,要求擁有者透過接受傳送的交握來核准所有功能的變更。在所有受邀的成員帳戶接受交握後,組織管理員可以完成所有功能的變更,具有適當許可的管理員可以建立政策並將其套用至根帳戶、OUs 和 帳戶:

aws organizations enable-all-features

輸出是交握物件,會傳送至所有受邀的成員帳戶進行核准:

{ "Handshake": { "Action": "ENABLE_ALL_FEATURES", "Arn":"arn:aws:organizations::111111111111:handshake/o-exampleorgid/enable_all_features/h-examplehandshakeid111", "ExpirationTimestamp":1.483127868609E9, "Id":"h-examplehandshakeid111", "Parties": [ { "id":"o-exampleorgid", "type":"ORGANIZATION" } ], "requestedTimestamp":1.481831868609E9, "resources": [ { "type":"ORGANIZATION", "value":"o-exampleorgid" } ], "state":"REQUESTED" } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 EnableAllFeatures

下列程式碼範例示範如何使用 enable-all-features

AWS CLI

啟用組織中的所有功能

此範例顯示管理員要求組織中的所有受邀帳戶核准組織中已啟用的所有功能。 AWS 組織會傳送電子郵件到向每個受邀成員帳戶註冊的地址,要求擁有者透過接受傳送的交握來核准所有功能的變更。在所有受邀的成員帳戶接受交握後,組織管理員可以完成所有功能的變更,具有適當許可的管理員可以建立政策並將其套用至根帳戶、OUs 和 帳戶:

aws organizations enable-all-features

輸出是交握物件,會傳送至所有受邀的成員帳戶進行核准:

{ "Handshake": { "Action": "ENABLE_ALL_FEATURES", "Arn":"arn:aws:organizations::111111111111:handshake/o-exampleorgid/enable_all_features/h-examplehandshakeid111", "ExpirationTimestamp":1.483127868609E9, "Id":"h-examplehandshakeid111", "Parties": [ { "id":"o-exampleorgid", "type":"ORGANIZATION" } ], "requestedTimestamp":1.481831868609E9, "resources": [ { "type":"ORGANIZATION", "value":"o-exampleorgid" } ], "state":"REQUESTED" } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 EnableAllFeatures

下列程式碼範例示範如何使用 enable-policy-type

AWS CLI

在根中啟用政策類型的使用

下列範例示範如何在根中啟用服務控制政策 (SCP) 政策類型:

aws organizations enable-policy-type --root-id r-examplerootid111 --policy-type SERVICE_CONTROL_POLICY

輸出顯示根物件,其具有 policyTypes 回應元素,顯示現在已啟用 SCPs:

{ "Root": { "PolicyTypes": [ { "Status":"ENABLED", "Type":"SERVICE_CONTROL_POLICY" } ], "Id": "r-examplerootid111", "Name": "Root", "Arn": "arn:aws:organizations::111111111111:root/o-exampleorgid/r-examplerootid111" } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 EnablePolicyType

下列程式碼範例示範如何使用 enable-policy-type

AWS CLI

在根中啟用政策類型的使用

下列範例示範如何在根中啟用服務控制政策 (SCP) 政策類型:

aws organizations enable-policy-type --root-id r-examplerootid111 --policy-type SERVICE_CONTROL_POLICY

輸出顯示根物件,其具有 policyTypes 回應元素,顯示現在已啟用 SCPs:

{ "Root": { "PolicyTypes": [ { "Status":"ENABLED", "Type":"SERVICE_CONTROL_POLICY" } ], "Id": "r-examplerootid111", "Name": "Root", "Arn": "arn:aws:organizations::111111111111:root/o-exampleorgid/r-examplerootid111" } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 EnablePolicyType

下列程式碼範例示範如何使用 invite-account-to-organization

AWS CLI

邀請帳戶加入組織

下列範例顯示 bill@example.com 擁有的主帳戶,邀請 juan@example.com 擁有的帳戶加入組織:

aws organizations invite-account-to-organization --target '{"Type": "EMAIL", "Id": "juan@example.com"}' --notes "This is a request for Juan's account to join Bill's organization."

輸出包含交握結構,顯示傳送至受邀帳戶的內容:

{ "Handshake": { "Action": "INVITE", "Arn": "arn:aws:organizations::111111111111:handshake/o-exampleorgid/invite/h-examplehandshakeid111", "ExpirationTimestamp": 1482952459.257, "Id": "h-examplehandshakeid111", "Parties": [ { "Id": "o-exampleorgid", "Type": "ORGANIZATION" }, { "Id": "juan@example.com", "Type": "EMAIL" } ], "RequestedTimestamp": 1481656459.257, "Resources": [ { "Resources": [ { "Type": "MASTER_EMAIL", "Value": "bill@amazon.com" }, { "Type": "MASTER_NAME", "Value": "Org Master Account" }, { "Type": "ORGANIZATION_FEATURE_SET", "Value": "FULL" } ], "Type": "ORGANIZATION", "Value": "o-exampleorgid" }, { "Type": "EMAIL", "Value": "juan@example.com" } ], "State": "OPEN" } }

下列程式碼範例示範如何使用 invite-account-to-organization

AWS CLI

邀請帳戶加入組織

下列範例顯示 bill@example.com 擁有的主帳戶,邀請 juan@example.com 擁有的帳戶加入組織:

aws organizations invite-account-to-organization --target '{"Type": "EMAIL", "Id": "juan@example.com"}' --notes "This is a request for Juan's account to join Bill's organization."

輸出包含交握結構,顯示傳送至受邀帳戶的內容:

{ "Handshake": { "Action": "INVITE", "Arn": "arn:aws:organizations::111111111111:handshake/o-exampleorgid/invite/h-examplehandshakeid111", "ExpirationTimestamp": 1482952459.257, "Id": "h-examplehandshakeid111", "Parties": [ { "Id": "o-exampleorgid", "Type": "ORGANIZATION" }, { "Id": "juan@example.com", "Type": "EMAIL" } ], "RequestedTimestamp": 1481656459.257, "Resources": [ { "Resources": [ { "Type": "MASTER_EMAIL", "Value": "bill@amazon.com" }, { "Type": "MASTER_NAME", "Value": "Org Master Account" }, { "Type": "ORGANIZATION_FEATURE_SET", "Value": "FULL" } ], "Type": "ORGANIZATION", "Value": "o-exampleorgid" }, { "Type": "EMAIL", "Value": "juan@example.com" } ], "State": "OPEN" } }

下列程式碼範例示範如何使用 leave-organization

AWS CLI

將組織保留為成員帳戶

下列範例顯示請求離開組織的成員帳戶的管理員,目前是 的成員:

aws organizations leave-organization
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 LeaveOrganization

下列程式碼範例示範如何使用 leave-organization

AWS CLI

將組織保留為成員帳戶

下列範例顯示請求離開組織的成員帳戶的管理員,目前是 的成員:

aws organizations leave-organization
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 LeaveOrganization

下列程式碼範例示範如何使用 list-accounts-for-parent

AWS CLI

擷取指定父系根或 OU 中所有帳戶的清單

下列範例示範如何請求 OU 中的帳戶清單:

aws organizations list-accounts-for-parent --parent-id ou-examplerootid111-exampleouid111

輸出包含帳戶摘要物件的清單。

{ "Accounts": [ { "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/333333333333", "JoinedMethod": "INVITED", "JoinedTimestamp": 1481835795.536, "Id": "333333333333", "Name": "Development Account", "Email": "juan@example.com", "Status": "ACTIVE" }, { "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/444444444444", "JoinedMethod": "INVITED", "JoinedTimestamp": 1481835812.143, "Id": "444444444444", "Name": "Test Account", "Email": "anika@example.com", "Status": "ACTIVE" } ] }

下列程式碼範例示範如何使用 list-accounts-for-parent

AWS CLI

擷取指定父系根或 OU 中所有帳戶的清單

下列範例示範如何請求 OU 中的帳戶清單:

aws organizations list-accounts-for-parent --parent-id ou-examplerootid111-exampleouid111

輸出包含帳戶摘要物件的清單。

{ "Accounts": [ { "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/333333333333", "JoinedMethod": "INVITED", "JoinedTimestamp": 1481835795.536, "Id": "333333333333", "Name": "Development Account", "Email": "juan@example.com", "Status": "ACTIVE" }, { "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/444444444444", "JoinedMethod": "INVITED", "JoinedTimestamp": 1481835812.143, "Id": "444444444444", "Name": "Test Account", "Email": "anika@example.com", "Status": "ACTIVE" } ] }

下列程式碼範例示範如何使用 list-accounts

AWS CLI

擷取組織中所有帳戶的清單

下列範例示範如何請求組織中的帳戶清單:

aws organizations list-accounts

輸出包含帳戶摘要物件的清單。

{ "Accounts": [ { "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/111111111111", "JoinedMethod": "INVITED", "JoinedTimestamp": 1481830215.45, "Id": "111111111111", "Name": "Master Account", "Email": "bill@example.com", "Status": "ACTIVE" }, { "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/222222222222", "JoinedMethod": "INVITED", "JoinedTimestamp": 1481835741.044, "Id": "222222222222", "Name": "Production Account", "Email": "alice@example.com", "Status": "ACTIVE" }, { "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/333333333333", "JoinedMethod": "INVITED", "JoinedTimestamp": 1481835795.536, "Id": "333333333333", "Name": "Development Account", "Email": "juan@example.com", "Status": "ACTIVE" }, { "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/444444444444", "JoinedMethod": "INVITED", "JoinedTimestamp": 1481835812.143, "Id": "444444444444", "Name": "Test Account", "Email": "anika@example.com", "Status": "ACTIVE" } ] }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListAccounts

下列程式碼範例示範如何使用 list-accounts

AWS CLI

擷取組織中所有帳戶的清單

下列範例示範如何請求組織中的帳戶清單:

aws organizations list-accounts

輸出包含帳戶摘要物件的清單。

{ "Accounts": [ { "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/111111111111", "JoinedMethod": "INVITED", "JoinedTimestamp": 1481830215.45, "Id": "111111111111", "Name": "Master Account", "Email": "bill@example.com", "Status": "ACTIVE" }, { "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/222222222222", "JoinedMethod": "INVITED", "JoinedTimestamp": 1481835741.044, "Id": "222222222222", "Name": "Production Account", "Email": "alice@example.com", "Status": "ACTIVE" }, { "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/333333333333", "JoinedMethod": "INVITED", "JoinedTimestamp": 1481835795.536, "Id": "333333333333", "Name": "Development Account", "Email": "juan@example.com", "Status": "ACTIVE" }, { "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/444444444444", "JoinedMethod": "INVITED", "JoinedTimestamp": 1481835812.143, "Id": "444444444444", "Name": "Test Account", "Email": "anika@example.com", "Status": "ACTIVE" } ] }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListAccounts

下列程式碼範例示範如何使用 list-children

AWS CLI

擷取父系 OUs 或根的子帳戶和 OU

下列範例說明如何列出包含該帳戶 444444444444 的根或 OU:

aws organizations list-children --child-type ORGANIZATIONAL_UNIT --parent-id ou-examplerootid111-exampleouid111

輸出會顯示父系包含的兩個子 OUs:

{ "Children": [ { "Id": "ou-examplerootid111-exampleouid111", "Type":"ORGANIZATIONAL_UNIT" }, { "Id":"ou-examplerootid111-exampleouid222", "Type":"ORGANIZATIONAL_UNIT" } ] }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListChildren

下列程式碼範例示範如何使用 list-children

AWS CLI

擷取父系 OUs 或根的子帳戶和 OU

下列範例說明如何列出包含該帳戶 444444444444 的根或 OU:

aws organizations list-children --child-type ORGANIZATIONAL_UNIT --parent-id ou-examplerootid111-exampleouid111

輸出會顯示父系包含的兩個子 OUs:

{ "Children": [ { "Id": "ou-examplerootid111-exampleouid111", "Type":"ORGANIZATIONAL_UNIT" }, { "Id":"ou-examplerootid111-exampleouid222", "Type":"ORGANIZATIONAL_UNIT" } ] }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListChildren

下列程式碼範例示範如何使用 list-create-account-status

AWS CLI

範例 1:擷取在目前組織中提出的帳戶建立請求清單

下列範例顯示如何為成功完成的組織請求帳戶建立請求清單:

aws organizations list-create-account-status --states SUCCEEDED

輸出包含物件陣列,其中包含每個請求的相關資訊。

{ "CreateAccountStatuses": [ { "AccountId": "444444444444", "AccountName": "Developer Test Account", "CompletedTimeStamp": 1481835812.143, "Id": "car-examplecreateaccountrequestid111", "RequestedTimeStamp": 1481829432.531, "State": "SUCCEEDED" } ] }

範例 2:擷取目前組織中提出的進行中帳戶建立請求清單

下列範例會取得組織的進行中帳戶建立請求清單:

aws organizations list-create-account-status --states IN_PROGRESS

輸出包含物件陣列,其中包含每個請求的相關資訊。

{ "CreateAccountStatuses": [ { "State": "IN_PROGRESS", "Id": "car-examplecreateaccountrequestid111", "RequestedTimeStamp": 1481829432.531, "AccountName": "Production Account" } ] }

下列程式碼範例示範如何使用 list-create-account-status

AWS CLI

範例 1:擷取在目前組織中提出的帳戶建立請求清單

下列範例顯示如何為成功完成的組織請求帳戶建立請求清單:

aws organizations list-create-account-status --states SUCCEEDED

輸出包含物件陣列,其中包含每個請求的相關資訊。

{ "CreateAccountStatuses": [ { "AccountId": "444444444444", "AccountName": "Developer Test Account", "CompletedTimeStamp": 1481835812.143, "Id": "car-examplecreateaccountrequestid111", "RequestedTimeStamp": 1481829432.531, "State": "SUCCEEDED" } ] }

範例 2:擷取目前組織中提出的進行中帳戶建立請求清單

下列範例會取得組織的進行中帳戶建立請求清單:

aws organizations list-create-account-status --states IN_PROGRESS

輸出包含物件陣列,其中包含每個請求的相關資訊。

{ "CreateAccountStatuses": [ { "State": "IN_PROGRESS", "Id": "car-examplecreateaccountrequestid111", "RequestedTimeStamp": 1481829432.531, "AccountName": "Production Account" } ] }

下列程式碼範例示範如何使用 list-handshakes-for-account

AWS CLI

擷取傳送至 帳戶的交握清單

下列範例示範如何取得與用來呼叫 操作的登入資料帳戶相關聯的所有交握清單:

aws organizations list-handshakes-for-account

輸出包含交握結構清單,其中包含每個交握的相關資訊,包括其目前狀態:

{ "Handshake": { "Action": "INVITE", "Arn": "arn:aws:organizations::111111111111:handshake/o-exampleorgid/invite/h-examplehandshakeid111", "ExpirationTimestamp": 1482952459.257, "Id": "h-examplehandshakeid111", "Parties": [ { "Id": "o-exampleorgid", "Type": "ORGANIZATION" }, { "Id": "juan@example.com", "Type": "EMAIL" } ], "RequestedTimestamp": 1481656459.257, "Resources": [ { "Resources": [ { "Type": "MASTER_EMAIL", "Value": "bill@amazon.com" }, { "Type": "MASTER_NAME", "Value": "Org Master Account" }, { "Type": "ORGANIZATION_FEATURE_SET", "Value": "FULL" } ], "Type": "ORGANIZATION", "Value": "o-exampleorgid" }, { "Type": "EMAIL", "Value": "juan@example.com" } ], "State": "OPEN" } }

下列程式碼範例示範如何使用 list-handshakes-for-account

AWS CLI

擷取傳送至 帳戶的交握清單

下列範例示範如何取得與用來呼叫 操作的登入資料帳戶相關聯的所有交握清單:

aws organizations list-handshakes-for-account

輸出包含交握結構清單,其中包含每個交握的相關資訊,包括其目前狀態:

{ "Handshake": { "Action": "INVITE", "Arn": "arn:aws:organizations::111111111111:handshake/o-exampleorgid/invite/h-examplehandshakeid111", "ExpirationTimestamp": 1482952459.257, "Id": "h-examplehandshakeid111", "Parties": [ { "Id": "o-exampleorgid", "Type": "ORGANIZATION" }, { "Id": "juan@example.com", "Type": "EMAIL" } ], "RequestedTimestamp": 1481656459.257, "Resources": [ { "Resources": [ { "Type": "MASTER_EMAIL", "Value": "bill@amazon.com" }, { "Type": "MASTER_NAME", "Value": "Org Master Account" }, { "Type": "ORGANIZATION_FEATURE_SET", "Value": "FULL" } ], "Type": "ORGANIZATION", "Value": "o-exampleorgid" }, { "Type": "EMAIL", "Value": "juan@example.com" } ], "State": "OPEN" } }

下列程式碼範例示範如何使用 list-handshakes-for-organization

AWS CLI

擷取與組織相關聯的交握清單

下列範例示範如何取得與目前組織相關聯的交握清單:

aws organizations list-handshakes-for-organization

輸出會顯示兩個交握。第一個是 Juan 帳戶的邀請,並顯示 OPEN 狀態。第二個是 Anika 帳戶的邀請,並顯示接受狀態:

{ "Handshakes": [ { "Action": "INVITE", "Arn": "arn:aws:organizations::111111111111:handshake/o-exampleorgid/invite/h-examplehandshakeid111", "ExpirationTimestamp": 1482952459.257, "Id": "h-examplehandshakeid111", "Parties": [ { "Id": "o-exampleorgid", "Type": "ORGANIZATION" }, { "Id": "juan@example.com", "Type": "EMAIL" } ], "RequestedTimestamp": 1481656459.257, "Resources": [ { "Resources": [ { "Type": "MASTER_EMAIL", "Value": "bill@amazon.com" }, { "Type": "MASTER_NAME", "Value": "Org Master Account" }, { "Type": "ORGANIZATION_FEATURE_SET", "Value": "FULL" } ], "Type": "ORGANIZATION", "Value": "o-exampleorgid" }, { "Type": "EMAIL", "Value": "juan@example.com" }, { "Type":"NOTES", "Value":"This is an invitation to Juan's account to join Bill's organization." } ], "State": "OPEN" }, { "Action": "INVITE", "State":"ACCEPTED", "Arn": "arn:aws:organizations::111111111111:handshake/o-exampleorgid/invite/h-examplehandshakeid111", "ExpirationTimestamp": 1.471797437427E9, "Id": "h-examplehandshakeid222", "Parties": [ { "Id": "o-exampleorgid", "Type": "ORGANIZATION" }, { "Id": "anika@example.com", "Type": "EMAIL" } ], "RequestedTimestamp": 1.469205437427E9, "Resources": [ { "Resources": [ { "Type":"MASTER_EMAIL", "Value":"bill@example.com" }, { "Type":"MASTER_NAME", "Value":"Master Account" } ], "Type":"ORGANIZATION", "Value":"o-exampleorgid" }, { "Type":"EMAIL", "Value":"anika@example.com" }, { "Type":"NOTES", "Value":"This is an invitation to Anika's account to join Bill's organization." } ] } ] }

下列程式碼範例示範如何使用 list-handshakes-for-organization

AWS CLI

擷取與組織相關聯的交握清單

下列範例示範如何取得與目前組織相關聯的交握清單:

aws organizations list-handshakes-for-organization

輸出會顯示兩個交握。第一個是 Juan 帳戶的邀請,並顯示 OPEN 狀態。第二個是 Anika 帳戶的邀請,並顯示接受狀態:

{ "Handshakes": [ { "Action": "INVITE", "Arn": "arn:aws:organizations::111111111111:handshake/o-exampleorgid/invite/h-examplehandshakeid111", "ExpirationTimestamp": 1482952459.257, "Id": "h-examplehandshakeid111", "Parties": [ { "Id": "o-exampleorgid", "Type": "ORGANIZATION" }, { "Id": "juan@example.com", "Type": "EMAIL" } ], "RequestedTimestamp": 1481656459.257, "Resources": [ { "Resources": [ { "Type": "MASTER_EMAIL", "Value": "bill@amazon.com" }, { "Type": "MASTER_NAME", "Value": "Org Master Account" }, { "Type": "ORGANIZATION_FEATURE_SET", "Value": "FULL" } ], "Type": "ORGANIZATION", "Value": "o-exampleorgid" }, { "Type": "EMAIL", "Value": "juan@example.com" }, { "Type":"NOTES", "Value":"This is an invitation to Juan's account to join Bill's organization." } ], "State": "OPEN" }, { "Action": "INVITE", "State":"ACCEPTED", "Arn": "arn:aws:organizations::111111111111:handshake/o-exampleorgid/invite/h-examplehandshakeid111", "ExpirationTimestamp": 1.471797437427E9, "Id": "h-examplehandshakeid222", "Parties": [ { "Id": "o-exampleorgid", "Type": "ORGANIZATION" }, { "Id": "anika@example.com", "Type": "EMAIL" } ], "RequestedTimestamp": 1.469205437427E9, "Resources": [ { "Resources": [ { "Type":"MASTER_EMAIL", "Value":"bill@example.com" }, { "Type":"MASTER_NAME", "Value":"Master Account" } ], "Type":"ORGANIZATION", "Value":"o-exampleorgid" }, { "Type":"EMAIL", "Value":"anika@example.com" }, { "Type":"NOTES", "Value":"This is an invitation to Anika's account to join Bill's organization." } ] } ] }

下列程式碼範例示範如何使用 list-organizational-units-for-parent

AWS CLI

擷取父 OUs 或根中的 OU 清單

下列範例說明如何取得指定根中的 OUs 清單:

aws organizations list-organizational-units-for-parent --parent-id r-examplerootid111

輸出顯示指定的根包含兩個 OUs並顯示每個 的詳細資訊:

{ "OrganizationalUnits": [ { "Name": "AccountingDepartment", "Arn": "arn:aws:organizations::o-exampleorgid:ou/r-examplerootid111/ou-examplerootid111-exampleouid111" }, { "Name": "ProductionDepartment", "Arn": "arn:aws:organizations::o-exampleorgid:ou/r-examplerootid111/ou-examplerootid111-exampleouid222" } ] }

下列程式碼範例示範如何使用 list-organizational-units-for-parent

AWS CLI

擷取父 OUs 或根中的 OU 清單

下列範例說明如何取得指定根中的 OUs 清單:

aws organizations list-organizational-units-for-parent --parent-id r-examplerootid111

輸出顯示指定的根包含兩個 OUs並顯示每個 的詳細資訊:

{ "OrganizationalUnits": [ { "Name": "AccountingDepartment", "Arn": "arn:aws:organizations::o-exampleorgid:ou/r-examplerootid111/ou-examplerootid111-exampleouid111" }, { "Name": "ProductionDepartment", "Arn": "arn:aws:organizations::o-exampleorgid:ou/r-examplerootid111/ou-examplerootid111-exampleouid222" } ] }

下列程式碼範例示範如何使用 list-parents

AWS CLI

列出帳戶或子 OUs 的父 OU 或根

下列範例說明如何列出包含該帳戶 444444444444 的根或父 OU:

aws organizations list-parents --child-id 444444444444

輸出顯示指定的帳戶位於具有指定 ID 的 OU 中:

{ "Parents": [ { "Id": "ou-examplerootid111-exampleouid111", "Type": "ORGANIZATIONAL_UNIT" } ] }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListParents

下列程式碼範例示範如何使用 list-parents

AWS CLI

列出帳戶或子 OUs 的父 OU 或根

下列範例說明如何列出包含該帳戶 444444444444 的根或父 OU:

aws organizations list-parents --child-id 444444444444

輸出顯示指定的帳戶位於具有指定 ID 的 OU 中:

{ "Parents": [ { "Id": "ou-examplerootid111-exampleouid111", "Type": "ORGANIZATIONAL_UNIT" } ] }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListParents

下列程式碼範例示範如何使用 list-policies-for-target

AWS CLI

擷取直接連接到帳戶的 SCPs 清單

下列範例示範如何取得直接連接到 帳戶的所有服務控制政策 (SCPs) 清單,如篩選條件參數所指定:

aws organizations list-policies-for-target --filter SERVICE_CONTROL_POLICY --target-id 444444444444

輸出包含政策結構的清單,其中包含政策的摘要資訊。此清單不包含因繼承自 OU 階層中位置而套用至帳戶的政策:

{ "Policies": [ { "Type": "SERVICE_CONTROL_POLICY", "Name": "AllowAllEC2Actions", "AwsManaged", false, "Id": "p-examplepolicyid222", "Arn": "arn:aws:organizations::o-exampleorgid:policy/service_control_policy/p-examplepolicyid222", "Description": "Enables account admins to delegate permissions for any EC2 actions to users and roles in their accounts." } ] }

下列程式碼範例示範如何使用 list-policies-for-target

AWS CLI

擷取直接連接到帳戶的 SCPs 清單

下列範例示範如何取得直接連接到 帳戶的所有服務控制政策 (SCPs) 清單,如篩選條件參數所指定:

aws organizations list-policies-for-target --filter SERVICE_CONTROL_POLICY --target-id 444444444444

輸出包含政策結構的清單,其中包含政策的摘要資訊。此清單不包含因繼承自 OU 階層中位置而套用至帳戶的政策:

{ "Policies": [ { "Type": "SERVICE_CONTROL_POLICY", "Name": "AllowAllEC2Actions", "AwsManaged", false, "Id": "p-examplepolicyid222", "Arn": "arn:aws:organizations::o-exampleorgid:policy/service_control_policy/p-examplepolicyid222", "Description": "Enables account admins to delegate permissions for any EC2 actions to users and roles in their accounts." } ] }

下列程式碼範例示範如何使用 list-policies

AWS CLI

擷取特定類型組織中所有政策的清單

下列範例示範如何取得篩選條件參數所指定的 SCPs 清單:

aws organizations list-policies --filter SERVICE_CONTROL_POLICY

輸出包含具有摘要資訊的政策清單:

{ "Policies": [ { "Type": "SERVICE_CONTROL_POLICY", "Name": "AllowAllS3Actions", "AwsManaged": false, "Id": "p-examplepolicyid111", "Arn": "arn:aws:organizations::111111111111:policy/service_control_policy/p-examplepolicyid111", "Description": "Enables account admins to delegate permissions for any S3 actions to users and roles in their accounts." }, { "Type": "SERVICE_CONTROL_POLICY", "Name": "AllowAllEC2Actions", "AwsManaged": false, "Id": "p-examplepolicyid222", "Arn": "arn:aws:organizations::111111111111:policy/service_control_policy/p-examplepolicyid222", "Description": "Enables account admins to delegate permissions for any EC2 actions to users and roles in their accounts." }, { "AwsManaged": true, "Description": "Allows access to every operation", "Type": "SERVICE_CONTROL_POLICY", "Id": "p-FullAWSAccess", "Arn": "arn:aws:organizations::aws:policy/service_control_policy/p-FullAWSAccess", "Name": "FullAWSAccess" } ] }
  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 ListPolicies

下列程式碼範例示範如何使用 list-policies

AWS CLI

擷取特定類型組織中所有政策的清單

下列範例示範如何取得篩選條件參數所指定的 SCPs 清單:

aws organizations list-policies --filter SERVICE_CONTROL_POLICY

輸出包含具有摘要資訊的政策清單:

{ "Policies": [ { "Type": "SERVICE_CONTROL_POLICY", "Name": "AllowAllS3Actions", "AwsManaged": false, "Id": "p-examplepolicyid111", "Arn": "arn:aws:organizations::111111111111:policy/service_control_policy/p-examplepolicyid111", "Description": "Enables account admins to delegate permissions for any S3 actions to users and roles in their accounts." }, { "Type": "SERVICE_CONTROL_POLICY", "Name": "AllowAllEC2Actions", "AwsManaged": false, "Id": "p-examplepolicyid222", "Arn": "arn:aws:organizations::111111111111:policy/service_control_policy/p-examplepolicyid222", "Description": "Enables account admins to delegate permissions for any EC2 actions to users and roles in their accounts." }, { "AwsManaged": true, "Description": "Allows access to every operation", "Type": "SERVICE_CONTROL_POLICY", "Id": "p-FullAWSAccess", "Arn": "arn:aws:organizations::aws:policy/service_control_policy/p-FullAWSAccess", "Name": "FullAWSAccess" } ] }
  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 ListPolicies

下列程式碼範例示範如何使用 list-roots

AWS CLI

擷取組織中根的清單

此範例說明如何取得組織的根目錄清單:

aws organizations list-roots

輸出包含具有摘要資訊的根結構清單:

{ "Roots": [ { "Name": "Root", "Arn": "arn:aws:organizations::111111111111:root/o-exampleorgid/r-examplerootid111", "Id": "r-examplerootid111", "PolicyTypes": [ { "Status":"ENABLED", "Type":"SERVICE_CONTROL_POLICY" } ] } ] }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListRoots

下列程式碼範例示範如何使用 list-roots

AWS CLI

擷取組織中根的清單

此範例說明如何取得組織的根目錄清單:

aws organizations list-roots

輸出包含具有摘要資訊的根結構清單:

{ "Roots": [ { "Name": "Root", "Arn": "arn:aws:organizations::111111111111:root/o-exampleorgid/r-examplerootid111", "Id": "r-examplerootid111", "PolicyTypes": [ { "Status":"ENABLED", "Type":"SERVICE_CONTROL_POLICY" } ] } ] }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListRoots

下列程式碼範例示範如何使用 list-targets-for-policy

AWS CLI

擷取政策所連接之根目錄、OUs 和帳戶的清單

下列範例示範如何取得指定政策所連接的根、OUs 和帳戶的清單:

aws organizations list-targets-for-policy --policy-id p-FullAWSAccess

輸出包含連接物件的清單,其中包含政策所連接之根、OUs 和帳戶的摘要資訊:

{ "Targets": [ { "Arn": "arn:aws:organizations::111111111111:root/o-exampleorgid/r-examplerootid111", "Name": "Root", "TargetId":"r-examplerootid111", "Type":"ROOT" }, { "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/333333333333;", "Name": "Developer Test Account", "TargetId": "333333333333", "Type": "ACCOUNT" }, { "Arn":"arn:aws:organizations::111111111111:ou/o-exampleorgid/ou-examplerootid111-exampleouid111", "Name":"Accounting", "TargetId":"ou-examplerootid111-exampleouid111", "Type":"ORGANIZATIONAL_UNIT" } ] }

下列程式碼範例示範如何使用 list-targets-for-policy

AWS CLI

擷取政策所連接之根目錄、OUs 和帳戶的清單

下列範例示範如何取得指定政策所連接的根、OUs 和帳戶的清單:

aws organizations list-targets-for-policy --policy-id p-FullAWSAccess

輸出包含連接物件的清單,其中包含政策所連接之根、OUs 和帳戶的摘要資訊:

{ "Targets": [ { "Arn": "arn:aws:organizations::111111111111:root/o-exampleorgid/r-examplerootid111", "Name": "Root", "TargetId":"r-examplerootid111", "Type":"ROOT" }, { "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/333333333333;", "Name": "Developer Test Account", "TargetId": "333333333333", "Type": "ACCOUNT" }, { "Arn":"arn:aws:organizations::111111111111:ou/o-exampleorgid/ou-examplerootid111-exampleouid111", "Name":"Accounting", "TargetId":"ou-examplerootid111-exampleouid111", "Type":"ORGANIZATIONAL_UNIT" } ] }

下列程式碼範例示範如何使用 move-account

AWS CLI

在根或 OUs 之間移動帳戶

下列範例示範如何將組織中的主帳戶從根目錄移至 OU:

aws organizations move-account --account-id 333333333333 --source-parent-id r-examplerootid111 --destination-parent-id ou-examplerootid111-exampleouid111
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 MoveAccount

下列程式碼範例示範如何使用 move-account

AWS CLI

在根或 OUs 之間移動帳戶

下列範例示範如何將組織中的主帳戶從根目錄移至 OU:

aws organizations move-account --account-id 333333333333 --source-parent-id r-examplerootid111 --destination-parent-id ou-examplerootid111-exampleouid111
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 MoveAccount

下列程式碼範例示範如何使用 remove-account-from-organization

AWS CLI

將 帳戶從組織中移除為主要帳戶

下列範例示範如何從組織移除帳戶:

aws organizations remove-account-from-organization --account-id 333333333333

下列程式碼範例示範如何使用 remove-account-from-organization

AWS CLI

將 帳戶從組織中移除為主要帳戶

下列範例示範如何從組織移除帳戶:

aws organizations remove-account-from-organization --account-id 333333333333

下列程式碼範例示範如何使用 update-organizational-unit

AWS CLI

重新命名 OU

此範例說明如何重新命名 OU:在此範例中,OU 會重新命名為「AccountingOU」:

aws organizations update-organizational-unit --organizational-unit-id ou-examplerootid111-exampleouid111 --name AccountingOU

輸出會顯示新名稱:

{ "OrganizationalUnit": { "Id": "ou-examplerootid111-exampleouid111" "Name": "AccountingOU", "Arn": "arn:aws:organizations::111111111111:ou/o-exampleorgid/ou-examplerootid111-exampleouid111"" } }

下列程式碼範例示範如何使用 update-organizational-unit

AWS CLI

重新命名 OU

此範例說明如何重新命名 OU:在此範例中,OU 會重新命名為「AccountingOU」:

aws organizations update-organizational-unit --organizational-unit-id ou-examplerootid111-exampleouid111 --name AccountingOU

輸出會顯示新名稱:

{ "OrganizationalUnit": { "Id": "ou-examplerootid111-exampleouid111" "Name": "AccountingOU", "Arn": "arn:aws:organizations::111111111111:ou/o-exampleorgid/ou-examplerootid111-exampleouid111"" } }

下列程式碼範例示範如何使用 update-policy

AWS CLI

範例 1:重新命名政策

下列update-policy範例會重新命名政策,並提供新的描述。

aws organizations update-policy \ --policy-id p-examplepolicyid111 \ --name Renamed-Policy \ --description "This description replaces the original."

輸出會顯示新名稱和描述。

{ "Policy": { "Content": "{\n \"Version\":\"2012-10-17\",\n \"Statement\":{\n \"Effect\":\"Allow\",\n \"Action\":\"ec2:*\",\n \"Resource\":\"*\"\n }\n}\n", "PolicySummary": { "Id": "p-examplepolicyid111", "AwsManaged": false, "Arn":"arn:aws:organizations::111111111111:policy/o-exampleorgid/service_control_policy/p-examplepolicyid111", "Description": "This description replaces the original.", "Name": "Renamed-Policy", "Type": "SERVICE_CONTROL_POLICY" } } }

範例 2:取代政策的 JSON 文字內容

下列範例示範如何將上一個範例中 SCP 的 JSON 文字取代為新的 JSON 政策文字字串,該字串允許 S3 而非 EC2:

aws organizations update-policy \ --policy-id p-examplepolicyid111 \ --content "{\"Version\":\"2012-10-17\",\"Statement\":{\"Effect\":\"Allow\",\"Action\":\"s3:*\",\"Resource\":\"*\"}}"

輸出顯示新內容:

{ "Policy": { "Content": "{ \"Version\": \"2012-10-17\", \"Statement\": { \"Effect\": \"Allow\", \"Action\": \"s3:*\", \"Resource\": \"*\" } }", "PolicySummary": { "Arn": "arn:aws:organizations::111111111111:policy/o-exampleorgid/service_control_policy/p-examplepolicyid111", "AwsManaged": false; "Description": "This description replaces the original.", "Id": "p-examplepolicyid111", "Name": "Renamed-Policy", "Type": "SERVICE_CONTROL_POLICY" } } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 UpdatePolicy

下列程式碼範例示範如何使用 update-policy

AWS CLI

範例 1:重新命名政策

下列update-policy範例會重新命名政策,並提供新的描述。

aws organizations update-policy \ --policy-id p-examplepolicyid111 \ --name Renamed-Policy \ --description "This description replaces the original."

輸出會顯示新名稱和描述。

{ "Policy": { "Content": "{\n \"Version\":\"2012-10-17\",\n \"Statement\":{\n \"Effect\":\"Allow\",\n \"Action\":\"ec2:*\",\n \"Resource\":\"*\"\n }\n}\n", "PolicySummary": { "Id": "p-examplepolicyid111", "AwsManaged": false, "Arn":"arn:aws:organizations::111111111111:policy/o-exampleorgid/service_control_policy/p-examplepolicyid111", "Description": "This description replaces the original.", "Name": "Renamed-Policy", "Type": "SERVICE_CONTROL_POLICY" } } }

範例 2:取代政策的 JSON 文字內容

下列範例示範如何將上一個範例中 SCP 的 JSON 文字取代為新的 JSON 政策文字字串,該字串允許 S3 而非 EC2:

aws organizations update-policy \ --policy-id p-examplepolicyid111 \ --content "{\"Version\":\"2012-10-17\",\"Statement\":{\"Effect\":\"Allow\",\"Action\":\"s3:*\",\"Resource\":\"*\"}}"

輸出顯示新內容:

{ "Policy": { "Content": "{ \"Version\": \"2012-10-17\", \"Statement\": { \"Effect\": \"Allow\", \"Action\": \"s3:*\", \"Resource\": \"*\" } }", "PolicySummary": { "Arn": "arn:aws:organizations::111111111111:policy/o-exampleorgid/service_control_policy/p-examplepolicyid111", "AwsManaged": false; "Description": "This description replaces the original.", "Id": "p-examplepolicyid111", "Name": "Renamed-Policy", "Type": "SERVICE_CONTROL_POLICY" } } }
  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 UpdatePolicy

下一個主題:

AWS Outposts

上一個主題:

AWS OpsWorks CM
隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。