Reputation: 2675
I'm trying to set tags on an EC2 instance with the following call from a python script where I am passing in a variable instanceId
as the resource to add the tags on:
subprocess.call('aws ec2 create-tags --resources $instanceId --tags "Key=somekey, Value=someval"')
But I get this error:
An error occurred (MissingParameter) when calling the CreateTags operation: The request must contain the parameter resourceIdSet
255
However, when I print out instanceId
, I see the correct id of the instance so there must be something wrong with the way I am passing in the variable. Is there a different convention for this?
Upvotes: 3
Views: 3693
Reputation: 36073
Your variable $instanceId
in your AWS CLI command will end up being a shell variable, and won't be substituted from your Python code.
So, if $instanceId
is a Python variable, you may need to do something like:
subprocess.call('aws ec2 create-tags --resources ' + $instanceId + ' --tags "Key=somekey, Value=someval"')
Note: I am not a Python developer, so this is a stab in the dark.
Upvotes: 2