【问题标题】:Boto3 DirectoryService: create_microsoft_ad failsBoto3 DirectoryService:create_microsoft_ad 失败
【发布时间】:2017-08-03 05:28:57
【问题描述】:

我正在尝试使用 python 中的 boto3 库创建 Microsoft AD。我可以从 AWS 控制台创建它,但是当我尝试使用我从控制台尝试时使用的相同值从我的脚本中创建它时,它会失败并出现以下错误:

botocore.errorfactory.ClientException: An error occurred (ClientException) when calling the CreateMicrosoftAD operation: Invalid VPC ID. : RequestId: <id>

异常响应的 HTTP 状态代码为 400。

我将访问密钥保存在本地,就像它提到的 Windows 的 here 一样,它所属的用户具有提到的 CreateMicrosoftAD 的权限 here。 (由于这是一个测试设置,我已授予用户完全访问权限。)

脚本如下:

import boto3
client = boto3.client('ds', region_name='us-west-2')
response = client.create_microsoft_ad(
    Name='test1.test2.com',
    ShortName='test1',
    Password='TestPassword1',
    Description='test description',
    VpcSettings={
        'VpcId': 'vpc-1234abcd',
        'SubnetIds': [
        'subnet-1235abcd',
        'subnet-1236abcd'
        ]
    }
)

我在此处为 VPC 和子网 ID 添加了模拟值,但我在控制台中验证了我正在使用可用 VPC 和子网的 ID。 create_microsoft_ad 调用如 here 所述完成。

我不确定我是否缺少 IAM 用户设置或脚本中的步骤。如果我需要提供更多信息,请告诉我。谢谢!

【问题讨论】:

  • 有可能在 AWS 控制台中,您使用的区域与 us-west-2 不同。或者 Boto3 使用了错误的凭据。有关配置凭据,请参阅:boto3.readthedocs.io/en/latest/guide/configuration.html。你用的是Boto2
  • 我也尝试在 boto3.client 调用中对凭据进行硬编码,但仍然遇到同样的错误。但改变地区奏效了。谢谢!

标签: python-3.x boto3 aws-directory-services


【解决方案1】:

可能在 AWS 控制台中,您使用的区域不同于 us-west-2

或者Boto3 使用了错误的凭据。请参阅:Configuring Credentials 以配置凭据。你用的是Boto2。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-08-17
    • 2019-08-13
    • 2018-03-31
    • 2017-02-26
    • 1970-01-01
    • 1970-01-01
    • 2019-02-17
    • 1970-01-01
    相关资源
    最近更新 更多