---
|
- import_playbook: ../../include_vars.yml
|
|
- name: Stop instances in all regions
|
hosts: localhost
|
gather_facts: false
|
become: false
|
environment:
|
AWS_ACCESS_KEY_ID: "{{aws_access_key_id}}"
|
AWS_SECRET_ACCESS_KEY: "{{aws_secret_access_key}}"
|
tasks:
|
- debug:
|
msg: "Step 002 Post Infrastructure"
|
|
- loop: "{{ target_regions | json_query('[].region') }}"
|
loop_control:
|
loop_var: _region
|
ec2:
|
instance_tags:
|
"aws:cloudformation:stack-name": "{{ project_tag }}"
|
state: stopped
|
region: "{{ _region }}"
|
# Shell equivalent
|
# shell: >-
|
# aws ec2 stop-instances
|
# --region {{ _region }}
|
# --instance-ids $(
|
# aws ec2 describe-instances
|
# --filters "Name=tag:aws:cloudformation:stack-name,Values={{ project_tag }}
|
# --query Reservations[*].Instances[*].InstanceId
|
# --region {{_region }}
|
# --output text
|
# )
|