-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate iam_role and iam_role_info modules from community.aws
- Loading branch information
1 parent
3b5c0d0
commit 94f032a
Showing
16 changed files
with
969 additions
and
1,074 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
major_changes: | ||
- iam_role - The module has been migrated from the ``community.aws`` collection. Playbooks | ||
using the Fully Qualified Collection Name for this module should be updated to use | ||
``amazon.aws.iam_role`` (https://github.com/ansible-collections/amazon.aws/pull/1760). | ||
- iam_role_info - The module has been migrated from the ``community.aws`` collection. | ||
Playbooks using the Fully Qualified Collection Name for this module should be updated | ||
to use ``amazon.aws.iam_role_info`` (https://github.com/ansible-collections/amazon.aws/pull/1760). |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
--- | ||
test_role: '{{ resource_prefix }}-role' | ||
test_path: '/{{ resource_prefix }}/' | ||
safe_managed_policy: 'AWSDenyAll' | ||
test_path: /{{ resource_prefix }}/ | ||
safe_managed_policy: AWSDenyAll | ||
custom_policy_name: '{{ resource_prefix }}-denyall' | ||
boundary_policy: 'arn:aws:iam::aws:policy/AWSDenyAll' | ||
boundary_policy: arn:aws:iam::aws:policy/AWSDenyAll |
94 changes: 43 additions & 51 deletions
94
tests/integration/targets/iam_role/tasks/boundary_policy.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,94 +1,86 @@ | ||
--- | ||
- name: "Create minimal role with no boundary policy" | ||
- name: Create minimal role with no boundary policy | ||
iam_role: | ||
name: "{{ test_role }}" | ||
name: '{{ test_role }}' | ||
create_instance_profile: no | ||
register: iam_role | ||
|
||
- assert: | ||
that: | ||
- iam_role is changed | ||
- iam_role.iam_role.role_name == test_role | ||
- iam_role is changed | ||
- iam_role.iam_role.role_name == test_role | ||
|
||
- name: "Configure Boundary Policy (CHECK MODE)" | ||
- name: Configure Boundary Policy (CHECK MODE) | ||
iam_role: | ||
name: "{{ test_role }}" | ||
name: '{{ test_role }}' | ||
create_instance_profile: no | ||
boundary: "{{ boundary_policy }}" | ||
boundary: '{{ boundary_policy }}' | ||
check_mode: yes | ||
register: iam_role | ||
|
||
- assert: | ||
that: | ||
- iam_role is changed | ||
- iam_role is changed | ||
|
||
- name: "Configure Boundary Policy" | ||
- name: Configure Boundary Policy | ||
iam_role: | ||
name: "{{ test_role }}" | ||
name: '{{ test_role }}' | ||
create_instance_profile: no | ||
boundary: "{{ boundary_policy }}" | ||
boundary: '{{ boundary_policy }}' | ||
register: iam_role | ||
|
||
- assert: | ||
that: | ||
- iam_role is changed | ||
- iam_role.iam_role.role_name == test_role | ||
- iam_role is changed | ||
- iam_role.iam_role.role_name == test_role | ||
|
||
- name: "Configure Boundary Policy (no change) - check mode" | ||
- name: Configure Boundary Policy (no change) - check mode | ||
iam_role: | ||
name: "{{ test_role }}" | ||
name: '{{ test_role }}' | ||
create_instance_profile: no | ||
boundary: "{{ boundary_policy }}" | ||
boundary: '{{ boundary_policy }}' | ||
register: iam_role | ||
check_mode: yes | ||
|
||
- assert: | ||
that: | ||
- iam_role is not changed | ||
- iam_role is not changed | ||
|
||
- name: "Configure Boundary Policy (no change)" | ||
- name: Configure Boundary Policy (no change) | ||
iam_role: | ||
name: "{{ test_role }}" | ||
name: '{{ test_role }}' | ||
create_instance_profile: no | ||
boundary: "{{ boundary_policy }}" | ||
boundary: '{{ boundary_policy }}' | ||
register: iam_role | ||
|
||
- assert: | ||
that: | ||
- iam_role is not changed | ||
- iam_role.iam_role.role_name == test_role | ||
- iam_role is not changed | ||
- iam_role.iam_role.role_name == test_role | ||
|
||
- name: "iam_role_info after adding boundary policy" | ||
- name: iam_role_info after adding boundary policy | ||
iam_role_info: | ||
name: "{{ test_role }}" | ||
name: '{{ test_role }}' | ||
register: role_info | ||
|
||
- assert: | ||
that: | ||
- role_info is succeeded | ||
- role_info.iam_roles | length == 1 | ||
- 'role_info.iam_roles[0].arn.startswith("arn")' | ||
- 'role_info.iam_roles[0].arn.endswith("role/" + test_role )' | ||
- '"assume_role_policy_document" in role_info.iam_roles[0]' | ||
- '"create_date" in role_info.iam_roles[0]' | ||
- '"description" not in role_info.iam_roles[0]' | ||
- role_info.iam_roles[0].inline_policies | length == 0 | ||
- role_info.iam_roles[0].instance_profiles | length == 0 | ||
- role_info.iam_roles[0].managed_policies | length == 0 | ||
- role_info.iam_roles[0].max_session_duration == 3600 | ||
- role_info.iam_roles[0].path == '/' | ||
- role_info.iam_roles[0].permissions_boundary.permissions_boundary_arn == boundary_policy | ||
- role_info.iam_roles[0].permissions_boundary.permissions_boundary_type == 'Policy' | ||
- role_info.iam_roles[0].role_id == iam_role.iam_role.role_id | ||
- role_info.iam_roles[0].role_name == test_role | ||
- role_info is succeeded | ||
- role_info.iam_roles | length == 1 | ||
- role_info.iam_roles[0].arn.startswith("arn") | ||
- role_info.iam_roles[0].arn.endswith("role/" + test_role ) | ||
- '"assume_role_policy_document" in role_info.iam_roles[0]' | ||
- '"create_date" in role_info.iam_roles[0]' | ||
- '"description" not in role_info.iam_roles[0]' | ||
- role_info.iam_roles[0].inline_policies | length == 0 | ||
- role_info.iam_roles[0].instance_profiles | length == 0 | ||
- role_info.iam_roles[0].managed_policies | length == 0 | ||
- role_info.iam_roles[0].max_session_duration == 3600 | ||
- role_info.iam_roles[0].path == '/' | ||
- role_info.iam_roles[0].permissions_boundary.permissions_boundary_arn == boundary_policy | ||
- role_info.iam_roles[0].permissions_boundary.permissions_boundary_type == 'Policy' | ||
- role_info.iam_roles[0].role_id == iam_role.iam_role.role_id | ||
- role_info.iam_roles[0].role_name == test_role | ||
|
||
- name: "Remove IAM Role" | ||
- name: Remove IAM Role | ||
iam_role: | ||
state: absent | ||
name: "{{ test_role }}" | ||
name: '{{ test_role }}' | ||
delete_instance_profile: yes | ||
register: iam_role | ||
|
||
- assert: | ||
that: | ||
- iam_role is changed | ||
- iam_role is changed |
Oops, something went wrong.