要移除AWS Organizations中的成员账户,你可以使用AWS SDK来实现。以下是使用Python和Boto3 SDK的示例代码:
import boto3
def remove_member_account(organization_id, member_account_id):
client = boto3.client('organizations')
response = client.remove_account_from_organization(
AccountId=member_account_id,
RemoveAccountFromOrganization=True
)
print(response)
# 替换为你的组织ID和要移除的成员账户ID
organization_id = 'your-organization-id'
member_account_id = 'your-member-account-id'
remove_member_account(organization_id, member_account_id)
请确保你已经安装了Boto3库,并且正确配置了AWS凭证(Access Key和Secret Access Key)。这个示例代码将使用指定的组织ID和成员账户ID,调用remove_account_from_organization
API来移除成员账户。
注意:只有拥有适当权限的帐户才能移除成员帐户。