Python 3.x 如何使用Boto3在Windows EC2实例中创建用户数据?

Python 3.x 如何使用Boto3在Windows EC2实例中创建用户数据?,python-3.x,amazon-web-services,amazon-ec2,boto3,Python 3.x,Amazon Web Services,Amazon Ec2,Boto3,我已经创建了一个Boto3脚本来使用Boto3启动带有用户数据的Windows EC2实例(批处理脚本)。当我运行我的boto3脚本时,它的启动实例成功,但用户数据未应用于我的Windows Ec2实例。我已经检查了有关解决方案的堆栈溢出。但是关于基于Linux的EC2实例的用户数据的一切。我已附上我的boto3脚本。 我没有得到任何解决方案,这就是为什么我创造了一个新问题 ec2Resource = boto3.resource('ec2',region_name='us-west-2') e

我已经创建了一个Boto3脚本来使用Boto3启动带有用户数据的Windows EC2实例(批处理脚本)。当我运行我的boto3脚本时,它的启动实例成功,但用户数据未应用于我的Windows Ec2实例。我已经检查了有关解决方案的堆栈溢出。但是关于基于Linux的EC2实例的用户数据的一切。我已附上我的boto3脚本。 我没有得到任何解决方案,这就是为什么我创造了一个新问题

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
)
ec2Resource=boto3.resource('ec2',region_name='us-west-2')
ec2=boto3.resource('ec2')
windata=''净用户/添加LatchuABC@2020'''
#创建实例
instanceDict=ec2Resource.create_实例(
DryRun=DryRun,
ImageId=“ami-xxxxxxxx”,
KeyName=“ZabbixServerPrivateKey”,
InstanceType=“t2.micro”,
SecurityGroupId=[“sg-xxxxx”],
MinCount=1,
MaxCount=1,
UserData=windata
)

我创建了上面的问题以获取解决方案。但问题很简单,刚才我发现了。这段代码完全正确。 为什么不应用用户数据?-因为密码长度不允许我运行简单的用户创建命令。当我使用简单密码而不是复杂密码(比如8位密码而不是22位密码)时,就会应用用户数据