ansible ec2 module: using a variable inside an instance_ids dictionary

Hey,

I would like to tag aws machines, but use a variable for the value of the tag. Is that possible?

I.e. instead of:

instance_ids={“key1”:“value1”, “key2”:“value2”}

I’d like to see something like:

instance_ids={“key1”:“{{var1}}”, “key2”:“{{var2}}”}

It doesn’t seem to be possible, but perhaps I’m not doing something right. I get an error:

failed: [localhost] => {“failed”: true}
msg: unable to evaluate dictionary for instance_tags

Hi,

Replying to myself, as it seems this was my mistake. At some point I dropped some quotes by mistake.

instance_ids=‘{“key1”:“{{var1}}”, “key2”:“{{var2}}”}’

does seem to work.