简体   繁体   中英

How to create user-data in Windows EC2 Instance using Boto3?

I have created one Boto3 script to launch Windows EC2 instance with User-Data(Batch Script) using Boto3. When i run my boto3 script, its launching instance successfully, but user-data not applied to my Windows Ec2 Instance. I have checked stack-overflow regarding solutions. But everything about user-data with Linux based EC2 instance. I have attached my boto3 script. I don't get any solution, that's why i created new question.

ec2Resource = boto3.resource('ec2',region_name='us-west-2')
ec2 = boto3.resource('ec2')

windata = '''<script>net user /add Latchu ABC@2020</script>'''

# Create the instance
instanceDict = ec2Resource.create_instances(
    DryRun = dryRun,
    ImageId = "ami-xxxxxxxxx",
    KeyName = "ZabbixServerPrivateKey",
    InstanceType = "t2.micro",
    SecurityGroupIds = ["sg-xxxxx"],
    MinCount = 1,
    MaxCount = 1,
    UserData = windata
)

i have created above question to catch solutions. But its simple issue, just now i found that. This boto3 code is exactly right. Why user-data is not applied? - Because password length is not allow me to run the simple user creation command. When i used simple password than complex (like 8 digit password than 22 digit password), then user-data is applied.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM