Facing issue in writing ansible connection with AWS instance

Hi there,

I’ve tried AWS instance ec2 to ssh from ansible controller to target1 - target1 is also ec2.
we can ssh through >> ssh -i (keypair) ec2-user@private IP. Its working fine but is there any way to write this type of connections in inventory file?
what attributes we can use instead of ansible_connection=ssh , ansible_ssh_pass=
there is no password using to access other AWS ec2 instance

ansible configuration there will one parameter in /etc/ansible/ansible.cfg about mentioning private. private_key_file = /path/to/private-key

1 Like

Or you can use the command like : ansible-playbook main.yml -i inventories/dev/hosts --user ec2-user --key-file ansible_aut.pem

1 Like

Thanks for sharing @sathish2032.
Also, this link will be useful:
https://docs.ansible.com/ansible/latest/collections/amazon/aws/ec2_key_module.html

1 Like