AWS WorkMail 创建用户 API 抛出“OrganizationNotFoundException”错误

AWS WorkMail Create User API throwing `OrganizationNotFoundException` error

所以我使用 boto3 连接 AWS WorkMail。我使用了我的一个 IAM 用户,并向该用户授予了完整的 WoekMail 权限。我创建了一个组织,我想使用他们的 API.

之一以编程方式为其创建一个用户

所以我的代码看起来像这样:

import boto3

from config import aws_credentials

client = boto3.client('workmail', **aws_credentials)

response = client.create_user(
    OrganizationId="m-69a01**********************848eb",
    Name='abhi',
    DisplayName='abhi jain',
    Password='********'
)

所以我一直收到这个错误:

botocore.errorfactory.OrganizationNotFoundException: An error occurred (OrganizationNotFoundException) when calling the CreateUser operation: Could not find organization with id 'm-69a01**********************848eb'

只是为了确保我仔细检查了我的组织 ID 并附上了屏幕截图。我不确定这是否是用于此 API.

的正确组织 ID

发现我的错误,aws 凭据设置为 us-west-2 区域,而我的组织位于 us-east-1

因为我无法更改我的组织区域,所以我将我在 ~/.aws/config 中的区域更改为与我的组织相同的区域,并使用相同的代码,效果非常好。

import boto3

from config import aws_credentials

client = boto3.client('workmail', **aws_credentials)

response = client.create_user(
    OrganizationId="m-69a01**********************848eb",
    Name='abhi',
    DisplayName='abhi jain',
    Password='********'
)