文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
DescribePolicy
搭配 a AWS SDK 或 CLI 使用
下列程式碼範例示範如何使用 DescribePolicy
。
- CLI
-
- 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
。
-
- Python
-
- SDK for Python (Boto3)
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 def describe_policy(policy_id, orgs_client): """ Describes a policy. :param policy_id: The ID of the policy to describe. :param orgs_client: The Boto3 Organizations client. :return: The description of the policy. """ try: response = orgs_client.describe_policy(PolicyId=policy_id) policy = response["Policy"] logger.info("Got policy %s.", policy_id) except ClientError: logger.exception("Couldn't get policy %s.", policy_id) raise else: return policy
-
如需 API 詳細資訊,請參閱 DescribePolicy AWS SDK for Python (Boto3) Word 參考中的 API。
-
DeletePolicy
DetachPolicy