Skip to content

Instantly share code, notes, and snippets.

@naavveenn
Last active June 13, 2018 03:39
Show Gist options
  • Save naavveenn/f93004c1d06919ff2a87d6ba9592c7ae to your computer and use it in GitHub Desktop.
Save naavveenn/f93004c1d06919ff2a87d6ba9592c7ae to your computer and use it in GitHub Desktop.
---
- hosts: local
connection: local
gather_facts: yes
vars:
aws_region: ap-south-1
aws_access_key: asfhafsfaadvadvdv
aws_secret_key: KVsfioefln845141cashcgaksjsdvsdv
tasks:
- name: get instance id
ec2_instance_facts:
region: "{{ aws_region }}"
access_key: "{{ aws_access_key }}"
secret_key: "{{ aws_secret_key }}"
# filters: #based on tags
# "tag:Owner": Naveen
# instance-state-name: running #will only filter based on running instances
register: ec2
- debug:
msg: "The instance id is '{{ item.instance_id }}'"
with_items:
- "{{ ec2.instances }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment