I am trying to create a Microsoft AD using the boto3 library in python. I am able to create it from the AWS console, but when i try to do it from my script using the same values i used when i tried from the console, it fails with the following error:
botocore.errorfactory.ClientException: An error occurred (ClientException) when calling the CreateMicrosoftAD operation: Invalid VPC ID. : RequestId: <id>
The exception response has a HTTP status code of 400.
I have the access key saved locally the way its mentioned here for windows and the user it belongs to has the permissions mentioned here for CreateMicrosoftAD. (Since this is a test setup, I've given the user full access.)
The script is given below:
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'
]
}
)
I've added mock values for the VPC and subnet IDs here, but i verified in the console that i was using the IDs for available VPC and subnets. The create_microsoft_ad call is done as mentioned here.
I am not sure if i am missing a step in the IAM user setup or in the script. Please let me know if i need to provide more information. Thanks!
It is possible in AWS console, you are using a region different from
us-west-2
Or
Boto3
is using the wrong credentials. See: Configuring Credentials for configuring credentials. The one you used was for Boto2.