ec2_instance vs ec2 - which one to use & and is there a plan?

Hi

While trying to debug some issues (notably trying to add several security groups to an EC2 instance), I once again ran into the question about which ansible module to use to for EC2 instances.

From the docs it appears that both the ec2 and the ec2_instance module are supported, with the latter being the newest, and they do largely the same things.
I’ve shuffled around the ec2_instance task into an ec2 task, and I was able to get that to work with multiple security groups.
But now I’m having a hard time getting this new ec2 task to be idempotent, and also the way that IP addresses are assigned is more limited than ec2_instance.

I’m wary of picking the “old” ec2 module for my tasks, or mixing the two, because I suspect ec2 might get deprecated some time soon in favor of the ec2_instance module.

I couldn’t find any statement or road map on this topic - is there a long term plan or a road map wrt the two EC2 modules? If so, I can at least make a sound decision on where to spend energy, also in terms of fixing issues.

thx

You can get an idempotent ec2 task using the instance_tags, exact_count, and count_tag options. The IP addresses are more limited because the module uses the old boto library which is no longer actively maintained by AWS.

I’m not aware of any plans to deprecate the ec2 module in the near future. The ec2_instance module is preview status as there are still some things to be fixed, like you’ve found.

I think the current state of things is that features can be added to ec2_instance, but not ec2 (we try to avoid adding more boto-dependent code). The ec2 module can still receive bug fixes, but since it uses the boto library which isn’t getting patched for its own bugs or updated with features there are issues that won’t be able to be resolved in that module. Those problems can be fixed in ec2_instance since that module uses boto3.