-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework example module to use EC2 rather than STS.
STS doesn't use regions...
- Loading branch information
Showing
8 changed files
with
168 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
- hosts: all | ||
gather_facts: no | ||
collections: | ||
- community.aws | ||
- amazon.aws | ||
roles: | ||
- 'ansible_aws_module' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 2 additions & 7 deletions
9
tests/integration/targets/ansible_aws_module/roles/ansible_aws_module/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
--- | ||
- name: 'run test module' | ||
boto3_example: | ||
#region: '{{ aws_region }}' | ||
#aws_access_key: "{{ aws_access_key }}" | ||
#aws_secret_key: "{{ aws_secret_key }}" | ||
#security_token: "{{ security_token | default(omit) }}" | ||
profile: 'test_profile' | ||
- name: 'Test that the varients we expect to succeed, do' | ||
include_tasks: 'success.yml' |
118 changes: 118 additions & 0 deletions
118
tests/integration/targets/ansible_aws_module/roles/ansible_aws_module/tasks/success.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
--- | ||
################################################################################## | ||
# Tests using standard credential parameters | ||
|
||
- name: 'Test basic operation using simple credentials (simple-parameters)' | ||
boto3_example: | ||
region: '{{ aws_region }}' | ||
access_key: '{{ aws_access_key }}' | ||
secret_key: '{{ aws_secret_key }}' | ||
security_token: '{{ security_token }}' | ||
register: credential_result | ||
|
||
- name: 'Test basic operation using simple credentials (aws-parameters)' | ||
boto3_example: | ||
aws_region: '{{ aws_region }}' | ||
aws_access_key: '{{ aws_access_key }}' | ||
aws_secret_key: '{{ aws_secret_key }}' | ||
aws_security_token: '{{ security_token }}' | ||
register: credential_result | ||
|
||
- name: 'Test basic operation using simple credentials (ec2-parameters)' | ||
boto3_example: | ||
ec2_region: '{{ aws_region }}' | ||
ec2_access_key: '{{ aws_access_key }}' | ||
ec2_secret_key: '{{ aws_secret_key }}' | ||
access_token: '{{ security_token }}' | ||
register: credential_result | ||
|
||
################################################################################## | ||
# Tests using standard credentials from environment variables | ||
|
||
- name: 'Test basic operation using simple credentials (aws-environment)' | ||
boto3_example: | ||
environment: | ||
AWS_REGION: '{{ aws_region }}' | ||
AWS_ACCESS_KEY_ID: '{{ aws_access_key }}' | ||
AWS_SECRET_ACCESS_KEY: '{{ aws_secret_key }}' | ||
AWS_SECURITY_TOKEN: '{{ security_token }}' | ||
register: credential_result | ||
|
||
- name: 'Test basic operation using simple credentials (aws2-environment)' | ||
boto3_example: | ||
environment: | ||
AWS_DEFAULT_REGION: '{{ aws_region }}' | ||
AWS_ACCESS_KEY: '{{ aws_access_key }}' | ||
AWS_SECRET_KEY: '{{ aws_secret_key }}' | ||
AWS_SESSION_TOKEN: '{{ security_token }}' | ||
register: credential_result | ||
|
||
- name: 'Test basic operation using simple credentials (ec2-environment)' | ||
boto3_example: | ||
environment: | ||
EC2_REGION: '{{ aws_region }}' | ||
EC2_ACCESS_KEY: '{{ aws_access_key }}' | ||
EC2_SECRET_KEY: '{{ aws_secret_key }}' | ||
EC2_SECURITY_TOKEN: '{{ security_token }}' | ||
register: credential_result | ||
|
||
################################################################################## | ||
# Tests using profiles instead of directly consuming credentials | ||
|
||
- name: 'Test basic operation using profile (simple-parameters)' | ||
boto3_example: | ||
profile: 'test_profile' | ||
register: profile_result | ||
|
||
- name: 'Test basic operation using profile (aws-parameters)' | ||
boto3_example: | ||
profile: 'test_profile' | ||
register: profile_result | ||
|
||
- name: 'Test basic operation using profile (aws-environment)' | ||
boto3_example: | ||
environment: | ||
AWS_PROFILE: 'test_profile' | ||
register: profile_result | ||
|
||
- name: 'Test basic operation using profile (aws2-environment)' | ||
boto3_example: | ||
environment: | ||
AWS_DEFAULT_PROFILE: 'test_profile' | ||
register: profile_result | ||
|
||
################################################################################## | ||
# Tests using profiles instead of directly consuming credentials | ||
|
||
- name: 'Test basic operation using standard endpoint (aws-parameters)' | ||
boto3_example: | ||
region: '{{ aws_region }}' | ||
aws_endpoint_url: 'https://ec2.{{ aws_region }}.amazonaws.com' | ||
aws_access_key: '{{ aws_access_key }}' | ||
aws_secret_key: '{{ aws_secret_key }}' | ||
aws_security_token: '{{ security_token }}' | ||
register: standard_endpoint_result | ||
|
||
- name: 'Check that we connected to the standard endpoint' | ||
assert: | ||
that: | ||
- standard_endpoint_result is successful | ||
- '"ec2:DescribeImages" in standard_endpoint_result.resource_actions' | ||
|
||
# The FIPS endpoints aren't available in every region, this will trigger errors | ||
# outside of: [ us-east-1, us-east-2, us-west-1, us-west-2 ] | ||
|
||
- name: 'Test basic operation using FIPS endpoint (aws-parameters)' | ||
boto3_example: | ||
region: '{{ aws_region }}' | ||
aws_endpoint_url: 'https://ec2-fips.{{ aws_region }}.amazonaws.com' | ||
aws_access_key: '{{ aws_access_key }}' | ||
aws_secret_key: '{{ aws_secret_key }}' | ||
aws_security_token: '{{ security_token }}' | ||
register: fips_endpoint_result | ||
|
||
- name: 'Check that we connected to the FIPS endpoint' | ||
assert: | ||
that: | ||
- fips_endpoint_result is successful | ||
- '"ec2-fips:DescribeImages" in fips_endpoint_result.resource_actions' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
tests/integration/targets/ansible_aws_module/templates/boto_config.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
[profile test_profile] | ||
region = {{ aws_region }} | ||
aws_access_key_id = {{ aws_access_key }} | ||
aws_secret_access_key = {{ aws_secret_key }} | ||
{% if security_token is defined %} | ||
aws_security_token = {{ security_token }} | ||
{% endif %} | ||
aws_access_key_id = {{ session_access_key | default(aws_access_key) }} | ||
aws_secret_access_key = {{ session_secret_key | default(aws_secret_key) }} | ||
aws_security_token = {{ session_security_token | default(security_token) }} |
3 changes: 3 additions & 0 deletions
3
tests/integration/targets/ansible_aws_module/templates/session_credentials.yml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
aws_access_key: {{ session_access_key | default(aws_access_key) }} | ||
aws_secret_key: {{ session_secret_key | default(aws_secret_key) }} | ||
security_token: {{ session_security_token | default(security_token) }} |