Create infra-aws-byo-verify role
New file |
| | |
| | | --- |
| | | _all_regions: |
| | | - eu-north-1 |
| | | - ap-south-1 |
| | | - eu-west-3 |
| | | - eu-west-2 |
| | | - eu-west-1 |
| | | - ap-northeast-2 |
| | | - ap-northeast-1 |
| | | - sa-east-1 |
| | | - ca-central-1 |
| | | - ap-southeast-1 |
| | | - ap-southeast-2 |
| | | - eu-central-1 |
| | | - us-east-1 |
| | | - us-east-2 |
| | | - us-west-1 |
| | | - us-west-2 |
New file |
| | |
| | | --- |
| | | - name: Test describe-instances |
| | | ec2_instance_facts: |
| | | aws_access_key: "{{ aws_access_key_id }}" |
| | | aws_secret_key: "{{ aws_secret_access_key }}" |
| | | region: us-east-1 |
| | | filters: |
| | | "tag:foo": bar |
| | | register: _raccess |
| | | failed_when: false |
| | | |
| | | - name: Exit if cannot list instances using the credentials |
| | | fail: |
| | | msg: "Cannot list instances using the provided credentials" |
| | | when: '"error" in _raccess' |
New file |
| | |
| | | --- |
| | | - name: Search for instances in region {{ loop_region }} |
| | | ec2_instance_facts: |
| | | aws_access_key: "{{ aws_access_key_id }}" |
| | | aws_secret_key: "{{ aws_secret_access_key }}" |
| | | region: "{{ loop_region }}" |
| | | register: _ri |
| | | |
| | | - fail: |
| | | msg: "{{ _ri.instances | length }} instances found in region {{ loop_region }} AWS account." |
| | | when: _ri.instances | length > 0 |
New file |
| | |
| | | --- |
| | | - import_tasks: access.yml |
| | | |
| | | - name: Search for instances in all regions |
| | | include_tasks: instances.yml |
| | | vars: |
| | | loop_region: "{{ _region }}" |
| | | loop_control: |
| | | loop_var: _region |
| | | loop: "{{ _all_regions }}" |