EC2 instances with tagged volumes that delete on termination

The subject says what I’m trying to do.

I first tried to create the instances with a volume dictionary, but that method doesn’t let me tag the volumes.

I then tried to first create the instances, then create the volumes and attach them, but that method doesn’t let me set them to delete on termination.

I finally attempted to create the instances one at a time with a volume dictionary, intending to loop through the volumes and tag them after the fact. But then I ran into the issue where I’m unable to invoke my create-one-instance include in a with_sequential loop.

What am I missing? Or is there simply not a way to do this?

Hi Brenda, this has come up before a few times (including from our own QA testing team), but apparently we haven’t opened an issue on it to date. Feel free to do so, and we’ll take a look at getting it resolved. It’s definitely been a problem in the past.

Thanks!

Thanks so much for the response. I’m new to Ansible, so what’s the right way to open an issue? I assume I just submit it to the git projects (https://github.com/ansible/ansible/issues), right?

Yep, that’s it. Let us know if you have any further questions.

Thanks!

AHA! I found a work-around.

I create the untagged volumes at the same time I create the instances with the ec2 module. But if I then go back and attempt to create the same volumes with the ec2_vol module using the same device names, it doesn’t create or change the volumes, but it does give me back a result with all the volume IDs. I can then use the IDs to create my tags.

Messy, but it gives me what I want.