Debian Codegraph @

ansible_collections/amazon/aws/tests/integration/targets/iam_user/tasks/boundary_policy.yml

raw
1 ---
2 # ===========================================
3 # Test Boundary Policy management
4 #
5 # Use a couple of benign policies for testing:
6 # - AWSDenyAll
7 # - ServiceQuotasReadOnlyAccess
8 #
9 - name: Attach boundary policy to user (check mode)
10 amazon.aws.iam_user:
11 name: "{{ test_user }}"
12 state: present
13 boundary: arn:aws:iam::aws:policy/AWSDenyAll
14 register: iam_user
15 check_mode: true
16 - name: Assert that the user is changed
17 ansible.builtin.assert:
18 that:
19 - iam_user is changed
20
21 - name: Attach boundary policy to user
22 amazon.aws.iam_user:
23 name: "{{ test_user }}"
24 state: present
25 boundary: arn:aws:iam::aws:policy/AWSDenyAll
26 register: iam_user
27 - name: Assert that the user is changed
28 ansible.builtin.assert:
29 that:
30 - iam_user is changed
31
32 - name: Ensure boundary policy is attached to user (no change - check mode)
33 amazon.aws.iam_user:
34 name: "{{ test_user }}"
35 state: present
36 boundary: arn:aws:iam::aws:policy/AWSDenyAll
37 register: iam_user
38 check_mode: true
39 - name: Assert that the user hasn't changed
40 ansible.builtin.assert:
41 that:
42 - iam_user is not changed
43
44 - name: Ensure boundary policy is attached to user (no change)
45 amazon.aws.iam_user:
46 name: "{{ test_user }}"
47 state: present
48 boundary: arn:aws:iam::aws:policy/AWSDenyAll
49 register: iam_user
50 - name: Assert that the user hasn't changed
51 ansible.builtin.assert:
52 that:
53 - iam_user is not changed
54
55 # ------------------------------------------------------------------------------------------
56
57 - name: Check that policy doesn't require full ARN path
58 amazon.aws.iam_user:
59 name: "{{ test_user }}"
60 state: present
61 boundary: AWSDenyAll
62 register: iam_user
63 - name: Assert that the user hasn't changed
64 ansible.builtin.assert:
65 that:
66 - iam_user is not changed
67
68 # ------------------------------------------------------------------------------------------
69
70 - name: Attach different boundary policy to user (check mode)
71 check_mode: true
72 amazon.aws.iam_user:
73 name: "{{ test_user }}"
74 state: present
75 boundary: arn:aws:iam::aws:policy/ServiceQuotasReadOnlyAccess
76 register: iam_user
77 - name: Assert that the user changed
78 ansible.builtin.assert:
79 that:
80 - iam_user is changed
81
82 - name: Attach different boundary policy to user
83 amazon.aws.iam_user:
84 name: "{{ test_user }}"
85 state: present
86 boundary: arn:aws:iam::aws:policy/ServiceQuotasReadOnlyAccess
87 register: iam_user
88 - name: Assert that the user changed
89 ansible.builtin.assert:
90 that:
91 - iam_user is changed
92
93 - name: Attach different boundary policy to user (no change - check mode)
94 amazon.aws.iam_user:
95 name: "{{ test_user }}"
96 state: present
97 boundary: arn:aws:iam::aws:policy/ServiceQuotasReadOnlyAccess
98 register: iam_user
99 check_mode: true
100 - name: Assert that the user hasn't changed
101 ansible.builtin.assert:
102 that:
103 - iam_user is not changed
104
105 - name: Check first policy wasn't purged
106 amazon.aws.iam_user:
107 name: "{{ test_user }}"
108 state: present
109 boundary: arn:aws:iam::aws:policy/ServiceQuotasReadOnlyAccess
110 register: iam_user
111 - name: Assert that the user hasn't changed
112 ansible.builtin.assert:
113 that:
114 - iam_user is not changed
115
116 # ------------------------------------------------------------------------------------------
117
118 - name: Remove the boundary policy (check mode)
119 check_mode: true
120 amazon.aws.iam_user:
121 name: "{{ test_user }}"
122 state: present
123 boundary: ""
124 register: iam_user
125 - name: Assert that the user changed
126 ansible.builtin.assert:
127 that:
128 - iam_user is changed
129
130 - name: Remove the boundary policy
131 amazon.aws.iam_user:
132 name: "{{ test_user }}"
133 state: present
134 boundary: ""
135 register: iam_user
136 - name: Assert that the user changed
137 ansible.builtin.assert:
138 that:
139 - iam_user is changed
140
141 - name: Remove the boundary policy (no change) (check mode)
142 amazon.aws.iam_user:
143 name: "{{ test_user }}"
144 state: present
145 boundary: ""
146 register: iam_user
147 check_mode: true
148 - name: Assert that the user hasn't changed
149 ansible.builtin.assert:
150 that:
151 - iam_user is not changed
152
153 - name: Remove the boundary policy (no change)
154 amazon.aws.iam_user:
155 name: "{{ test_user }}"
156 state: present
157 boundary: ""
158 register: iam_user
159 - name: Assert that the user hasn't changed
160 ansible.builtin.assert:
161 that:
162 - iam_user is not changed