Я создаю экземпляр ec2 в python boto3 с этим кодом:
image_id = input("Enter the image id: ")
max_count = input("Enter the number of instances you want: ")
instance_type = input("Enter the instance type: ")
key_name = input("Enter the key name you want to use: ")
name_tag = input("Enter the host name: ")
instance = ec2_resource.create_instances(
ImageId=image_id,
MinCount=1,
MaxCount=max_count,
InstanceType=instance_type,
KeyName=key_name
)
Но когда я пытаюсь применить тег имени с этим кодом:
instance.add_tag('Name', name_tag)
Я получаю сообщение об ошибке:
Traceback (most recent call last):
File ".\aws_create_ec2_simple.py", line 134, in <module>
main()
File ".\aws_create_ec2_simple.py", line 130, in main
create_instances()
File ".\aws_create_ec2_simple.py", line 125, in create_instances
instance.add_tag('Name', name_tag)
AttributeError: 'list' object has no attribute 'add_tag'
Как я могу сделать это правильно?