0

i'm experiencing a strange issue with using of AWS CLI tools (awscli python module awscli-1.11.136, awscli-1.11.177). When calling 'run-instances' action with --cli-input-json argument, instance is not Tagged with the Name tag i specify in a call. Example of the call: aws ec2 run-instances --cli-input-json file://test-1c.json.

The test-1c.json contains following TagSpecifications:

"TagSpecifications": [
        {
            "ResourceType": "instance",
            "Tags": [
                {
                    "Key": "Name",
                    "Value": "test-1c"
                }
            ],
            "ResourceType": "volume",
            "Tags": [
                {
                    "Key": "Name",
                    "Value": "test-1c"
                }
            ]
        }
    ]

Volume is properly tagged with the specified Name tag, but instance is not.

When calling the same using command line arguments, it works properly:

aws ec2 run-instances \                                             
--image-id ami-123456 \
--instance-type t2.micro \
--placement AvailabilityZone=eu-central-1b \
--security-group-ids sg-123456 \
--subnet-id subnet-123456 \
--private-ip-address 172.31.0.1 \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=test-1c}]' 'ResourceType=volume,Tags=[{Key=name,Value=test-1c}]'{code}

Is there a bug in the JSON's run-instances awscli python module functionality or am i doing anything wrong?

Thanks in advance for any help!

1 Answer 1

1

There is a problem with your JSON structure.

Your TagSpecifications array only has a single tag object in it. That one object has 2 ResourceType and 2 Tags properties, the 2nd of which (for the volume) is overriding the 1st (for the instance). This is the cause for the failure.

Add missing },{ into your structure before "ResourceType": "volume",

Such as

"TagSpecifications": [
        {
            "ResourceType": "instance",
            "Tags": [
                {
                    "Key": "Name",
                    "Value": "test-1c"
                }
            ],
        },
        {
            "ResourceType": "volume",
            "Tags": [
                {
                    "Key": "Name",
                    "Value": "test-1c"
                }
            ]
        }
    ]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .