How to get IP based list in AWS EC2 dynamic inventory

Hi Everybody,

When trying to sync the dynamic inventory from AWS, i am getting amazon hostname based inventory but I need IP based inventory…

You must have your SOURCE VARIABLES set to “hostname_variable: tag:Name”. I think you need to set this to “vpc_destination_variable = ip_address” .

See https://github.com/ansible-collections/community.aws/blob/main/scripts/inventory/ec2.ini .

You can find the config for your dynamic inventory under sources.

Hi Nicolas,

The SOURCE VARIABLE does not seem to work for some reason. On a similar note I am working on using connection over aws_ssm and using aws_ssm.py. aws_ssm connects to Instance ID rather than IP / DNS Name. I am hence trying to use the hostname_variable to give me the instance-id rather than IP / DNS name.

Adding “hostname_variable: instance-id” under SOURCE VARIABLE does not work under AWX but, works fine on Ansible Tower.

Thanks!
Sidd