Show a minimal `aws_ec2` dynamic inventory configuration.

IntermediateConceptInventory
Answer
# inventory/aws_ec2.yml
plugin: amazon.aws.aws_ec2
regions:
  - ap-south-1
filters:
  instance-state-name: running
  tag:Env: prod
compose:
  ansible_host: private_ip_address
ansible-galaxy collection install amazon.aws
pip install boto3 botocore
ansible-inventory -i inventory/aws_ec2.yml --graph

Credentials come from the normal AWS chain (environment variables, shared profile, or an instance role). The file name must end in aws_ec2.yml or aws_ec2.yaml, or the plugin refuses it.

All Ansible questions Roadmap: Ansible

More on Inventory