Boto3 DirectoryService:create_microsoft_ad失败

时间:2017-08-02 19:25:10

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

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

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

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

我在本地保存了访问密钥,就像它提到的here用于Windows及其所属的用户具有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的模拟值,但我在控制台中验证了我使用的ID是可用的VPC和子网。 create_microsoft_ad调用按照here所述完成。

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

1 个答案:

答案 0 :(得分:1)

在AWS控制台中,您可以使用与us-west-2

不同的区域

Boto3使用了错误的凭据。有关配置凭据的信息,请参阅:Configuring Credentials。你使用的是Boto2。