AWS WorkMail创建用户API引发`OrganizationNotFoundException`错误

2024-06-02 09:37:43 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我使用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 Organization Settings Screenshot, I have whitened my creds. But you can still see the start and end of OrganizationID


Tags: 用户importclientawsapiid权限boto3
1条回答
网友
1楼 · 发布于 2024-06-02 09:37:43

发现我的错误,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='********'
)

相关问题 更多 >