在AWS帐户中,管理策略以组织控制策略(SCP)的形式提供。下面是一个示例代码,通过调用AWS Organizations API来检索当前AWS帐户的SCP:
import boto3
# Create a client to connect to Organizations API
org_client = boto3.client('organizations')
# Get the list of SCPs applied to the account
response = org_client.list_policies_for_target(
TargetId='YOUR_ACCOUNT_ID',
Filter='SERVICE_CONTROL_POLICY'
)
# Print the list of SCPs
for scp in response['Policies']:
print(scp['Name'])
请注意,此代码中的TargetId
参数应替换为您的AWS帐户ID。如果您想查看与组匹配的所有SCP,请将TargetId
的值更改为组的ID。
上一篇:不加入Rust线程有什么缺点?
下一篇:不加外键约束的加入