我正在尝试通过python3脚本在中启动一个aws实例。它工作得很好,但我现在尝试向实例添加一些标签,但没有成功。我正在尝试下面的方法,但得到了一个“意外的关键字参数'tag_specifications'”错误。
import boto.ec2
conn=boto.ec2.connect_to_region("eu-west-1")
conn.run_instances('ami-12345',instance_type='c5.large',key_name='test.prod',
security_groups=['ProductionInstance'],instance_profile_name='TestProductionProcessor',
tag_specifications=[{'Key': 'Name','Value': 'TEST'}])我已经检查了botocore,直到现在,等等。
谢谢
发布于 2020-12-18 22:57:26
以下代码在Python 3.7上执行成功;
import boto3.ec2
conn=boto3.client('ec2',region_name='eu-west-1')
tags=[
{'Key':'Name','Value': 'Test'},
]
tag_specification=[{'ResourceType': 'instance','Tags': tags},]
conn.run_instances(ImageId='ami-12345',
TagSpecifications=tag_specification,
InstanceType='c5.large',
SecurityGroupIds=['sg-12345'], #change value of SecurityGroupIds as per your setup
IamInstanceProfile={
'Name': 'TestProductionProcessor'
},
MaxCount=1,
MinCount=1,
SubnetId='subnet-12345' #change value of SubnetId as per your setup
)发布于 2020-12-18 21:51:41
您可以使用以下命令尝试
TagSpecifications=[
{
'ResourceType': 'instance',
'Tags': [
{
'Key': 'Name',
'Value': 'Test'
},
]
}https://stackoverflow.com/questions/65357345
复制相似问题