| 1 |
--- |
| 2 |
# Tests the manipulation of networkfirewall resources one option at a time |
| 3 |
|
| 4 |
- vars: |
| 5 |
complex_firewall_name: '{{ firewall_name_prefix }}-Complex' |
| 6 |
first_tags: |
| 7 |
CamelCaseKey: CamelCaseValue |
| 8 |
'Key with Spaces': Value with spaces |
| 9 |
pascalCaseKey: pascalCaseValue |
| 10 |
snake_case_key: snake_case_value |
| 11 |
second_tags: |
| 12 |
CamelCaseKey: CamelCaseValue |
| 13 |
'Key with Spaces': Updated Value with spaces |
| 14 |
NewCamelCaseKey: CamelCaseValue |
| 15 |
'New Key with Spaces': Value with spaces |
| 16 |
newPascalCaseKey: pascalCaseValue |
| 17 |
new_snake_case_key: snake_case_value |
| 18 |
pascalCaseKey: pascalCaseValue |
| 19 |
snake_case_key: snake_case_value |
| 20 |
block: |
| 21 |
################################################################### |
| 22 |
# Creation |
| 23 |
|
| 24 |
- name: '(CHECK) Create a complex firewall' |
| 25 |
check_mode: True |
| 26 |
networkfirewall: |
| 27 |
name: '{{ complex_firewall_name }}' |
| 28 |
state: present |
| 29 |
delete_protection: True |
| 30 |
description: "An example Description" |
| 31 |
policy: '{{ default_policy_names[0] }}' |
| 32 |
policy_change_protection: True |
| 33 |
subnets: |
| 34 |
- '{{ subnet_id_a_1 }}' |
| 35 |
- '{{ subnet_id_a_2 }}' |
| 36 |
subnet_change_protection: True |
| 37 |
tags: '{{ first_tags }}' |
| 38 |
register: complex_firewall |
| 39 |
|
| 40 |
- assert: |
| 41 |
that: |
| 42 |
- complex_firewall is changed |
| 43 |
- '"firewall" in complex_firewall' |
| 44 |
- '"firewall" in complex_firewall.firewall' |
| 45 |
- '"delete_protection" in firewall_data' |
| 46 |
- '"description" in firewall_data' |
| 47 |
- '"firewall_metadata" in complex_firewall.firewall' |
| 48 |
- '"firewall_name" in firewall_data' |
| 49 |
- '"firewall_policy_arn" in firewall_data' |
| 50 |
- '"firewall_policy_change_protection" in firewall_data' |
| 51 |
- '"subnet_change_protection" in firewall_data' |
| 52 |
- '"subnet_mappings" in firewall_data' |
| 53 |
- '"tags" in firewall_data' |
| 54 |
- '"vpc_id" in firewall_data' |
| 55 |
- firewall_data.delete_protection == true |
| 56 |
- firewall_data.description == 'An example Description' |
| 57 |
- firewall_data.firewall_name == complex_firewall_name |
| 58 |
- firewall_data.firewall_policy_arn == default_policy_arns[0] |
| 59 |
- firewall_data.firewall_policy_change_protection == true |
| 60 |
- firewall_data.subnet_change_protection == true |
| 61 |
- firewall_data.subnet_mappings | length == 2 |
| 62 |
- '"subnet_id" in firewall_data.subnet_mappings[0]' |
| 63 |
- subnet_id_a_1 in subnet_ids |
| 64 |
- subnet_id_a_2 in subnet_ids |
| 65 |
- firewall_data.vpc_id == vpc_id_a |
| 66 |
- firewall_data.tags == first_tags |
| 67 |
vars: |
| 68 |
firewall_data: '{{ complex_firewall.firewall.firewall }}' |
| 69 |
subnet_ids: '{{ firewall_data.subnet_mappings | map(attribute="subnet_id") | list }}' |
| 70 |
|
| 71 |
- name: 'Create a complex firewall' |
| 72 |
networkfirewall: |
| 73 |
name: '{{ complex_firewall_name }}' |
| 74 |
state: present |
| 75 |
delete_protection: True |
| 76 |
description: "An example Description" |
| 77 |
policy: '{{ default_policy_names[0] }}' |
| 78 |
policy_change_protection: True |
| 79 |
subnets: |
| 80 |
- '{{ subnet_id_a_1 }}' |
| 81 |
- '{{ subnet_id_a_2 }}' |
| 82 |
subnet_change_protection: True |
| 83 |
tags: '{{ first_tags }}' |
| 84 |
register: complex_firewall |
| 85 |
|
| 86 |
- assert: |
| 87 |
that: |
| 88 |
- complex_firewall is changed |
| 89 |
- '"firewall" in complex_firewall' |
| 90 |
- '"firewall" in complex_firewall.firewall' |
| 91 |
- '"delete_protection" in firewall_data' |
| 92 |
- '"description" in firewall_data' |
| 93 |
- '"firewall_arn" in firewall_data' |
| 94 |
- '"firewall_id" in firewall_data' |
| 95 |
- '"firewall_metadata" in complex_firewall.firewall' |
| 96 |
- '"firewall_name" in firewall_data' |
| 97 |
- '"firewall_policy_arn" in firewall_data' |
| 98 |
- '"firewall_policy_change_protection" in firewall_data' |
| 99 |
- '"subnet_change_protection" in firewall_data' |
| 100 |
- '"subnet_mappings" in firewall_data' |
| 101 |
- '"tags" in firewall_data' |
| 102 |
- '"vpc_id" in firewall_data' |
| 103 |
- firewall_data.delete_protection == true |
| 104 |
- firewall_data.description == 'An example Description' |
| 105 |
- firewall_data.firewall_arn.startswith(account_arn) |
| 106 |
- firewall_data.firewall_arn.endswith(complex_firewall_name) |
| 107 |
- firewall_data.firewall_name == complex_firewall_name |
| 108 |
- firewall_data.firewall_policy_arn == default_policy_arns[0] |
| 109 |
- firewall_data.firewall_policy_change_protection == true |
| 110 |
- firewall_data.subnet_change_protection == true |
| 111 |
- firewall_data.subnet_mappings | length == 2 |
| 112 |
- '"subnet_id" in firewall_data.subnet_mappings[0]' |
| 113 |
- subnet_id_a_1 in subnet_ids |
| 114 |
- subnet_id_a_2 in subnet_ids |
| 115 |
- firewall_data.vpc_id == vpc_id_a |
| 116 |
- firewall_data.tags == first_tags |
| 117 |
- '"configuration_sync_state_summary" in firewall_metadata' |
| 118 |
- '"status" in firewall_metadata' |
| 119 |
- '"sync_states" in firewall_metadata' |
| 120 |
- firewall_metadata.status == "READY" |
| 121 |
- firewall_metadata.configuration_sync_state_summary == "IN_SYNC" |
| 122 |
vars: |
| 123 |
firewall_data: '{{ complex_firewall.firewall.firewall }}' |
| 124 |
firewall_metadata: '{{ complex_firewall.firewall.firewall_metadata }}' |
| 125 |
subnet_ids: '{{ firewall_data.subnet_mappings | map(attribute="subnet_id") | list }}' |
| 126 |
|
| 127 |
- name: 'Save Policy ID/ARN for later' |
| 128 |
set_fact: |
| 129 |
complex_firewall_id: '{{ firewall_data.firewall_id }}' |
| 130 |
complex_firewall_arn: '{{ firewall_data.firewall_arn }}' |
| 131 |
vars: |
| 132 |
firewall_data: '{{ complex_firewall.firewall.firewall }}' |
| 133 |
|
| 134 |
- name: '(CHECK) Create a complex firewall (idempotency)' |
| 135 |
check_mode: True |
| 136 |
networkfirewall: |
| 137 |
name: '{{ complex_firewall_name }}' |
| 138 |
state: present |
| 139 |
delete_protection: True |
| 140 |
description: "An example Description" |
| 141 |
policy: '{{ default_policy_names[0] }}' |
| 142 |
policy_change_protection: True |
| 143 |
subnets: |
| 144 |
- '{{ subnet_id_a_1 }}' |
| 145 |
- '{{ subnet_id_a_2 }}' |
| 146 |
subnet_change_protection: True |
| 147 |
tags: '{{ first_tags }}' |
| 148 |
register: complex_firewall |
| 149 |
|
| 150 |
- assert: |
| 151 |
that: |
| 152 |
- complex_firewall is not changed |
| 153 |
- '"firewall" in complex_firewall' |
| 154 |
- '"firewall" in complex_firewall.firewall' |
| 155 |
- '"delete_protection" in firewall_data' |
| 156 |
- '"description" in firewall_data' |
| 157 |
- '"firewall_arn" in firewall_data' |
| 158 |
- '"firewall_id" in firewall_data' |
| 159 |
- '"firewall_metadata" in complex_firewall.firewall' |
| 160 |
- '"firewall_name" in firewall_data' |
| 161 |
- '"firewall_policy_arn" in firewall_data' |
| 162 |
- '"firewall_policy_change_protection" in firewall_data' |
| 163 |
- '"subnet_change_protection" in firewall_data' |
| 164 |
- '"subnet_mappings" in firewall_data' |
| 165 |
- '"tags" in firewall_data' |
| 166 |
- '"vpc_id" in firewall_data' |
| 167 |
- firewall_data.delete_protection == true |
| 168 |
- firewall_data.description == 'An example Description' |
| 169 |
- firewall_data.firewall_arn == complex_firewall_arn |
| 170 |
- firewall_data.firewall_id == complex_firewall_id |
| 171 |
- firewall_data.firewall_name == complex_firewall_name |
| 172 |
- firewall_data.firewall_policy_arn == default_policy_arns[0] |
| 173 |
- firewall_data.firewall_policy_change_protection == true |
| 174 |
- firewall_data.subnet_change_protection == true |
| 175 |
- firewall_data.subnet_mappings | length == 2 |
| 176 |
- '"subnet_id" in firewall_data.subnet_mappings[0]' |
| 177 |
- subnet_id_a_1 in subnet_ids |
| 178 |
- subnet_id_a_2 in subnet_ids |
| 179 |
- firewall_data.vpc_id == vpc_id_a |
| 180 |
- firewall_data.tags == first_tags |
| 181 |
- '"configuration_sync_state_summary" in firewall_metadata' |
| 182 |
- '"status" in firewall_metadata' |
| 183 |
- '"sync_states" in firewall_metadata' |
| 184 |
- firewall_metadata.status == "READY" |
| 185 |
- firewall_metadata.configuration_sync_state_summary == "IN_SYNC" |
| 186 |
vars: |
| 187 |
firewall_data: '{{ complex_firewall.firewall.firewall }}' |
| 188 |
firewall_metadata: '{{ complex_firewall.firewall.firewall_metadata }}' |
| 189 |
subnet_ids: '{{ firewall_data.subnet_mappings | map(attribute="subnet_id") | list }}' |
| 190 |
|
| 191 |
- name: 'Create a complex firewall (idempotency)' |
| 192 |
networkfirewall: |
| 193 |
name: '{{ complex_firewall_name }}' |
| 194 |
state: present |
| 195 |
delete_protection: True |
| 196 |
description: "An example Description" |
| 197 |
policy: '{{ default_policy_names[0] }}' |
| 198 |
policy_change_protection: True |
| 199 |
subnets: |
| 200 |
- '{{ subnet_id_a_1 }}' |
| 201 |
- '{{ subnet_id_a_2 }}' |
| 202 |
subnet_change_protection: True |
| 203 |
tags: '{{ first_tags }}' |
| 204 |
register: complex_firewall |
| 205 |
|
| 206 |
- assert: |
| 207 |
that: |
| 208 |
- complex_firewall is not changed |
| 209 |
- '"firewall" in complex_firewall' |
| 210 |
- '"firewall" in complex_firewall.firewall' |
| 211 |
- '"delete_protection" in firewall_data' |
| 212 |
- '"description" in firewall_data' |
| 213 |
- '"firewall_arn" in firewall_data' |
| 214 |
- '"firewall_id" in firewall_data' |
| 215 |
- '"firewall_metadata" in complex_firewall.firewall' |
| 216 |
- '"firewall_name" in firewall_data' |
| 217 |
- '"firewall_policy_arn" in firewall_data' |
| 218 |
- '"firewall_policy_change_protection" in firewall_data' |
| 219 |
- '"subnet_change_protection" in firewall_data' |
| 220 |
- '"subnet_mappings" in firewall_data' |
| 221 |
- '"tags" in firewall_data' |
| 222 |
- '"vpc_id" in firewall_data' |
| 223 |
- firewall_data.delete_protection == true |
| 224 |
- firewall_data.description == 'An example Description' |
| 225 |
- firewall_data.firewall_arn == complex_firewall_arn |
| 226 |
- firewall_data.firewall_id == complex_firewall_id |
| 227 |
- firewall_data.firewall_name == complex_firewall_name |
| 228 |
- firewall_data.firewall_policy_arn == default_policy_arns[0] |
| 229 |
- firewall_data.firewall_policy_change_protection == true |
| 230 |
- firewall_data.subnet_change_protection == true |
| 231 |
- firewall_data.subnet_mappings | length == 2 |
| 232 |
- '"subnet_id" in firewall_data.subnet_mappings[0]' |
| 233 |
- subnet_id_a_1 in subnet_ids |
| 234 |
- subnet_id_a_2 in subnet_ids |
| 235 |
- firewall_data.vpc_id == vpc_id_a |
| 236 |
- firewall_data.tags == first_tags |
| 237 |
- '"configuration_sync_state_summary" in firewall_metadata' |
| 238 |
- '"status" in firewall_metadata' |
| 239 |
- '"sync_states" in firewall_metadata' |
| 240 |
- firewall_metadata.status == "READY" |
| 241 |
- firewall_metadata.configuration_sync_state_summary == "IN_SYNC" |
| 242 |
vars: |
| 243 |
firewall_data: '{{ complex_firewall.firewall.firewall }}' |
| 244 |
firewall_metadata: '{{ complex_firewall.firewall.firewall_metadata }}' |
| 245 |
subnet_ids: '{{ firewall_data.subnet_mappings | map(attribute="subnet_id") | list }}' |
| 246 |
|
| 247 |
################################################################### |
| 248 |
# Update |
| 249 |
|
| 250 |
- name: '(CHECK) Update a complex firewall' |
| 251 |
check_mode: True |
| 252 |
networkfirewall: |
| 253 |
name: '{{ complex_firewall_name }}' |
| 254 |
state: present |
| 255 |
description: "An updated Description" |
| 256 |
policy: '{{ default_policy_arns[2] }}' |
| 257 |
policy_change_protection: False |
| 258 |
subnet_change_protection: False |
| 259 |
subnets: |
| 260 |
- '{{ subnet_id_a_1a }}' |
| 261 |
- '{{ subnet_id_a_2 }}' |
| 262 |
- '{{ subnet_id_a_3 }}' |
| 263 |
tags: '{{ second_tags }}' |
| 264 |
register: complex_firewall |
| 265 |
|
| 266 |
- assert: |
| 267 |
that: |
| 268 |
- complex_firewall is changed |
| 269 |
- '"firewall" in complex_firewall' |
| 270 |
- '"firewall" in complex_firewall.firewall' |
| 271 |
- '"delete_protection" in firewall_data' |
| 272 |
- '"description" in firewall_data' |
| 273 |
- '"firewall_arn" in firewall_data' |
| 274 |
- '"firewall_id" in firewall_data' |
| 275 |
- '"firewall_metadata" in complex_firewall.firewall' |
| 276 |
- '"firewall_name" in firewall_data' |
| 277 |
- '"firewall_policy_arn" in firewall_data' |
| 278 |
- '"firewall_policy_change_protection" in firewall_data' |
| 279 |
- '"subnet_change_protection" in firewall_data' |
| 280 |
- '"subnet_mappings" in firewall_data' |
| 281 |
- '"tags" in firewall_data' |
| 282 |
- '"vpc_id" in firewall_data' |
| 283 |
- firewall_data.delete_protection == true |
| 284 |
- firewall_data.description == 'An updated Description' |
| 285 |
- firewall_data.firewall_arn == complex_firewall_arn |
| 286 |
- firewall_data.firewall_id == complex_firewall_id |
| 287 |
- firewall_data.firewall_name == complex_firewall_name |
| 288 |
- firewall_data.firewall_policy_arn == default_policy_arns[2] |
| 289 |
- firewall_data.firewall_policy_change_protection == false |
| 290 |
- firewall_data.subnet_change_protection == false |
| 291 |
- firewall_data.subnet_mappings | length == 3 |
| 292 |
- '"subnet_id" in firewall_data.subnet_mappings[0]' |
| 293 |
- subnet_id_a_1a in subnet_ids |
| 294 |
- subnet_id_a_2 in subnet_ids |
| 295 |
- subnet_id_a_3 in subnet_ids |
| 296 |
- firewall_data.vpc_id == vpc_id_a |
| 297 |
- firewall_data.tags == second_tags |
| 298 |
- '"configuration_sync_state_summary" in firewall_metadata' |
| 299 |
- '"status" in firewall_metadata' |
| 300 |
- '"sync_states" in firewall_metadata' |
| 301 |
- firewall_metadata.status == "READY" |
| 302 |
- firewall_metadata.configuration_sync_state_summary == "IN_SYNC" |
| 303 |
vars: |
| 304 |
firewall_data: '{{ complex_firewall.firewall.firewall }}' |
| 305 |
firewall_metadata: '{{ complex_firewall.firewall.firewall_metadata }}' |
| 306 |
subnet_ids: '{{ firewall_data.subnet_mappings | map(attribute="subnet_id") | list }}' |
| 307 |
|
| 308 |
- name: 'Update a complex firewall' |
| 309 |
networkfirewall: |
| 310 |
name: '{{ complex_firewall_name }}' |
| 311 |
state: present |
| 312 |
description: "An updated Description" |
| 313 |
policy: '{{ default_policy_arns[2] }}' |
| 314 |
policy_change_protection: False |
| 315 |
subnet_change_protection: False |
| 316 |
subnets: |
| 317 |
- '{{ subnet_id_a_1a }}' |
| 318 |
- '{{ subnet_id_a_2 }}' |
| 319 |
- '{{ subnet_id_a_3 }}' |
| 320 |
tags: '{{ second_tags }}' |
| 321 |
register: complex_firewall |
| 322 |
|
| 323 |
- assert: |
| 324 |
that: |
| 325 |
- complex_firewall is changed |
| 326 |
- '"firewall" in complex_firewall' |
| 327 |
- '"firewall" in complex_firewall.firewall' |
| 328 |
- '"delete_protection" in firewall_data' |
| 329 |
- '"description" in firewall_data' |
| 330 |
- '"firewall_arn" in firewall_data' |
| 331 |
- '"firewall_id" in firewall_data' |
| 332 |
- '"firewall_metadata" in complex_firewall.firewall' |
| 333 |
- '"firewall_name" in firewall_data' |
| 334 |
- '"firewall_policy_arn" in firewall_data' |
| 335 |
- '"firewall_policy_change_protection" in firewall_data' |
| 336 |
- '"subnet_change_protection" in firewall_data' |
| 337 |
- '"subnet_mappings" in firewall_data' |
| 338 |
- '"tags" in firewall_data' |
| 339 |
- '"vpc_id" in firewall_data' |
| 340 |
- firewall_data.delete_protection == true |
| 341 |
- firewall_data.description == 'An updated Description' |
| 342 |
- firewall_data.firewall_arn == complex_firewall_arn |
| 343 |
- firewall_data.firewall_id == complex_firewall_id |
| 344 |
- firewall_data.firewall_name == complex_firewall_name |
| 345 |
- firewall_data.firewall_policy_arn == default_policy_arns[2] |
| 346 |
- firewall_data.firewall_policy_change_protection == false |
| 347 |
- firewall_data.subnet_change_protection == false |
| 348 |
- firewall_data.subnet_mappings | length == 3 |
| 349 |
- '"subnet_id" in firewall_data.subnet_mappings[0]' |
| 350 |
- subnet_id_a_1a in subnet_ids |
| 351 |
- subnet_id_a_2 in subnet_ids |
| 352 |
- subnet_id_a_3 in subnet_ids |
| 353 |
- firewall_data.vpc_id == vpc_id_a |
| 354 |
- firewall_data.tags == second_tags |
| 355 |
- '"configuration_sync_state_summary" in firewall_metadata' |
| 356 |
- '"status" in firewall_metadata' |
| 357 |
- '"sync_states" in firewall_metadata' |
| 358 |
- firewall_metadata.status == "READY" |
| 359 |
- firewall_metadata.configuration_sync_state_summary == "IN_SYNC" |
| 360 |
vars: |
| 361 |
firewall_data: '{{ complex_firewall.firewall.firewall }}' |
| 362 |
firewall_metadata: '{{ complex_firewall.firewall.firewall_metadata }}' |
| 363 |
subnet_ids: '{{ firewall_data.subnet_mappings | map(attribute="subnet_id") | list }}' |
| 364 |
|
| 365 |
# There's a delay of a couple of seconds between requesting a change and the |
| 366 |
# firewall entering a PENDING/PROVISIONING state. The delay is enough to |
| 367 |
# let the firewall enter the expected PENDING state is it's going to. |
| 368 |
- name: 'Pause to let synchroization start' |
| 369 |
pause: |
| 370 |
seconds: 5 |
| 371 |
|
| 372 |
# Also checks that we get the info we expect |
| 373 |
- name: 'Check firewall is not still updating' |
| 374 |
networkfirewall_info: |
| 375 |
arn: '{{ complex_firewall_arn }}' |
| 376 |
register: complex_firewall_info |
| 377 |
|
| 378 |
- assert: |
| 379 |
that: |
| 380 |
- complex_firewall_info is successful |
| 381 |
- complex_firewall_info.firewalls | length == 1 |
| 382 |
- '"firewalls" in complex_firewall_info' |
| 383 |
- '"firewall" in complex_firewall_info.firewalls[0]' |
| 384 |
- '"delete_protection" in firewall_data' |
| 385 |
- '"description" in firewall_data' |
| 386 |
- '"firewall_arn" in firewall_data' |
| 387 |
- '"firewall_id" in firewall_data' |
| 388 |
- '"firewall_metadata" in complex_firewall_info.firewalls[0]' |
| 389 |
- '"firewall_name" in firewall_data' |
| 390 |
- '"firewall_policy_arn" in firewall_data' |
| 391 |
- '"firewall_policy_change_protection" in firewall_data' |
| 392 |
- '"subnet_change_protection" in firewall_data' |
| 393 |
- '"subnet_mappings" in firewall_data' |
| 394 |
- '"tags" in firewall_data' |
| 395 |
- '"vpc_id" in firewall_data' |
| 396 |
- firewall_data.delete_protection == true |
| 397 |
- firewall_data.description == 'An updated Description' |
| 398 |
- firewall_data.firewall_arn == complex_firewall_arn |
| 399 |
- firewall_data.firewall_id == complex_firewall_id |
| 400 |
- firewall_data.firewall_name == complex_firewall_name |
| 401 |
- firewall_data.firewall_policy_arn == default_policy_arns[2] |
| 402 |
- firewall_data.firewall_policy_change_protection == false |
| 403 |
- firewall_data.subnet_change_protection == false |
| 404 |
- firewall_data.subnet_mappings | length == 3 |
| 405 |
- '"subnet_id" in firewall_data.subnet_mappings[0]' |
| 406 |
- subnet_id_a_1a in subnet_ids |
| 407 |
- subnet_id_a_2 in subnet_ids |
| 408 |
- subnet_id_a_3 in subnet_ids |
| 409 |
- firewall_data.vpc_id == vpc_id_a |
| 410 |
- firewall_data.tags == second_tags |
| 411 |
- '"configuration_sync_state_summary" in firewall_metadata' |
| 412 |
- '"status" in firewall_metadata' |
| 413 |
- '"sync_states" in firewall_metadata' |
| 414 |
- firewall_metadata.status == "READY" |
| 415 |
- firewall_metadata.configuration_sync_state_summary == "IN_SYNC" |
| 416 |
vars: |
| 417 |
firewall_data: '{{ complex_firewall_info.firewalls[0].firewall }}' |
| 418 |
firewall_metadata: '{{ complex_firewall_info.firewalls[0].firewall_metadata }}' |
| 419 |
subnet_ids: '{{ firewall_data.subnet_mappings | map(attribute="subnet_id") | list }}' |
| 420 |
|
| 421 |
- name: '(CHECK) Update a complex firewall (idempotency)' |
| 422 |
check_mode: True |
| 423 |
networkfirewall: |
| 424 |
name: '{{ complex_firewall_name }}' |
| 425 |
state: present |
| 426 |
description: "An updated Description" |
| 427 |
policy: '{{ default_policy_arns[2] }}' |
| 428 |
policy_change_protection: False |
| 429 |
subnet_change_protection: False |
| 430 |
subnets: |
| 431 |
- '{{ subnet_id_a_1a }}' |
| 432 |
- '{{ subnet_id_a_2 }}' |
| 433 |
- '{{ subnet_id_a_3 }}' |
| 434 |
tags: '{{ second_tags }}' |
| 435 |
register: complex_firewall |
| 436 |
|
| 437 |
- assert: |
| 438 |
that: |
| 439 |
- complex_firewall is not changed |
| 440 |
- '"firewall" in complex_firewall' |
| 441 |
- '"firewall" in complex_firewall.firewall' |
| 442 |
- '"delete_protection" in firewall_data' |
| 443 |
- '"description" in firewall_data' |
| 444 |
- '"firewall_arn" in firewall_data' |
| 445 |
- '"firewall_id" in firewall_data' |
| 446 |
- '"firewall_metadata" in complex_firewall.firewall' |
| 447 |
- '"firewall_name" in firewall_data' |
| 448 |
- '"firewall_policy_arn" in firewall_data' |
| 449 |
- '"firewall_policy_change_protection" in firewall_data' |
| 450 |
- '"subnet_change_protection" in firewall_data' |
| 451 |
- '"subnet_mappings" in firewall_data' |
| 452 |
- '"tags" in firewall_data' |
| 453 |
- '"vpc_id" in firewall_data' |
| 454 |
- firewall_data.delete_protection == true |
| 455 |
- firewall_data.description == 'An updated Description' |
| 456 |
- firewall_data.firewall_arn == complex_firewall_arn |
| 457 |
- firewall_data.firewall_id == complex_firewall_id |
| 458 |
- firewall_data.firewall_name == complex_firewall_name |
| 459 |
- firewall_data.firewall_policy_arn == default_policy_arns[2] |
| 460 |
- firewall_data.firewall_policy_change_protection == false |
| 461 |
- firewall_data.subnet_change_protection == false |
| 462 |
- firewall_data.subnet_mappings | length == 3 |
| 463 |
- '"subnet_id" in firewall_data.subnet_mappings[0]' |
| 464 |
- subnet_id_a_1a in subnet_ids |
| 465 |
- subnet_id_a_2 in subnet_ids |
| 466 |
- subnet_id_a_3 in subnet_ids |
| 467 |
- firewall_data.vpc_id == vpc_id_a |
| 468 |
- firewall_data.tags == second_tags |
| 469 |
- '"configuration_sync_state_summary" in firewall_metadata' |
| 470 |
- '"status" in firewall_metadata' |
| 471 |
- '"sync_states" in firewall_metadata' |
| 472 |
- firewall_metadata.status == "READY" |
| 473 |
- firewall_metadata.configuration_sync_state_summary == "IN_SYNC" |
| 474 |
vars: |
| 475 |
firewall_data: '{{ complex_firewall.firewall.firewall }}' |
| 476 |
firewall_metadata: '{{ complex_firewall.firewall.firewall_metadata }}' |
| 477 |
subnet_ids: '{{ firewall_data.subnet_mappings | map(attribute="subnet_id") | list }}' |
| 478 |
|
| 479 |
- name: 'Update a complex firewall (idempotency)' |
| 480 |
networkfirewall: |
| 481 |
name: '{{ complex_firewall_name }}' |
| 482 |
state: present |
| 483 |
description: "An updated Description" |
| 484 |
policy: '{{ default_policy_arns[2] }}' |
| 485 |
policy_change_protection: False |
| 486 |
subnet_change_protection: False |
| 487 |
subnets: |
| 488 |
- '{{ subnet_id_a_1a }}' |
| 489 |
- '{{ subnet_id_a_2 }}' |
| 490 |
- '{{ subnet_id_a_3 }}' |
| 491 |
tags: '{{ second_tags }}' |
| 492 |
register: complex_firewall |
| 493 |
|
| 494 |
- assert: |
| 495 |
that: |
| 496 |
- complex_firewall is not changed |
| 497 |
- '"firewall" in complex_firewall' |
| 498 |
- '"firewall" in complex_firewall.firewall' |
| 499 |
- '"delete_protection" in firewall_data' |
| 500 |
- '"description" in firewall_data' |
| 501 |
- '"firewall_arn" in firewall_data' |
| 502 |
- '"firewall_id" in firewall_data' |
| 503 |
- '"firewall_metadata" in complex_firewall.firewall' |
| 504 |
- '"firewall_name" in firewall_data' |
| 505 |
- '"firewall_policy_arn" in firewall_data' |
| 506 |
- '"firewall_policy_change_protection" in firewall_data' |
| 507 |
- '"subnet_change_protection" in firewall_data' |
| 508 |
- '"subnet_mappings" in firewall_data' |
| 509 |
- '"tags" in firewall_data' |
| 510 |
- '"vpc_id" in firewall_data' |
| 511 |
- firewall_data.delete_protection == true |
| 512 |
- firewall_data.description == 'An updated Description' |
| 513 |
- firewall_data.firewall_arn == complex_firewall_arn |
| 514 |
- firewall_data.firewall_id == complex_firewall_id |
| 515 |
- firewall_data.firewall_name == complex_firewall_name |
| 516 |
- firewall_data.firewall_policy_arn == default_policy_arns[2] |
| 517 |
- firewall_data.firewall_policy_change_protection == false |
| 518 |
- firewall_data.subnet_change_protection == false |
| 519 |
- firewall_data.subnet_mappings | length == 3 |
| 520 |
- '"subnet_id" in firewall_data.subnet_mappings[0]' |
| 521 |
- subnet_id_a_1a in subnet_ids |
| 522 |
- subnet_id_a_2 in subnet_ids |
| 523 |
- subnet_id_a_3 in subnet_ids |
| 524 |
- firewall_data.vpc_id == vpc_id_a |
| 525 |
- firewall_data.tags == second_tags |
| 526 |
- '"configuration_sync_state_summary" in firewall_metadata' |
| 527 |
- '"status" in firewall_metadata' |
| 528 |
- '"sync_states" in firewall_metadata' |
| 529 |
- firewall_metadata.status == "READY" |
| 530 |
- firewall_metadata.configuration_sync_state_summary == "IN_SYNC" |
| 531 |
vars: |
| 532 |
firewall_data: '{{ complex_firewall.firewall.firewall }}' |
| 533 |
firewall_metadata: '{{ complex_firewall.firewall.firewall_metadata }}' |
| 534 |
subnet_ids: '{{ firewall_data.subnet_mappings | map(attribute="subnet_id") | list }}' |
| 535 |
|
| 536 |
|
| 537 |
################################################################### |
| 538 |
# Delete firewall |
| 539 |
# |
| 540 |
# This is *very* slow, so we don't wait on this one. The simple test will |
| 541 |
# check that waiting for deletion behaves properly. What we are however |
| 542 |
# checking is that deletion protection updates happen prior to attempting to |
| 543 |
# delete the firewall. |
| 544 |
|
| 545 |
- name: '(CHECK) Delete complex firewall - no wait' |
| 546 |
check_mode: True |
| 547 |
networkfirewall: |
| 548 |
name: '{{ complex_firewall_name }}' |
| 549 |
delete_protection: False |
| 550 |
state: absent |
| 551 |
wait: False |
| 552 |
register: complex_firewall |
| 553 |
|
| 554 |
- name: 'Delete complex firewall - no wait' |
| 555 |
networkfirewall: |
| 556 |
name: '{{ complex_firewall_name }}' |
| 557 |
delete_protection: False |
| 558 |
state: absent |
| 559 |
wait: False |
| 560 |
register: complex_firewall |
| 561 |
|
| 562 |
- assert: |
| 563 |
that: |
| 564 |
- complex_firewall is changed |
| 565 |
|
| 566 |
# We need to wait for the state to change |
| 567 |
- pause: |
| 568 |
seconds: 4 |
| 569 |
|
| 570 |
- name: 'Check firewall is not gone (expected to be in a pending state)' |
| 571 |
networkfirewall_info: |
| 572 |
arn: '{{ complex_firewall_arn }}' |
| 573 |
register: complex_firewall_info |
| 574 |
|
| 575 |
- assert: |
| 576 |
that: |
| 577 |
- complex_firewall_info is successful |
| 578 |
- complex_firewall_info.firewalls | length == 1 |
| 579 |
|
| 580 |
- name: '(CHECK) Delete complex firewall (idempotency)' |
| 581 |
check_mode: True |
| 582 |
networkfirewall: |
| 583 |
name: '{{ complex_firewall_name }}' |
| 584 |
delete_protection: False |
| 585 |
state: absent |
| 586 |
wait: False |
| 587 |
register: complex_firewall |
| 588 |
|
| 589 |
- assert: |
| 590 |
that: |
| 591 |
- complex_firewall is not changed |
| 592 |
|
| 593 |
- name: 'Delete complex firewall (idempotency)' |
| 594 |
networkfirewall: |
| 595 |
name: '{{ complex_firewall_name }}' |
| 596 |
delete_protection: False |
| 597 |
state: absent |
| 598 |
wait: False |
| 599 |
register: complex_firewall |
| 600 |
|
| 601 |
- assert: |
| 602 |
that: |
| 603 |
- complex_firewall is not changed |
| 604 |
|
| 605 |
always: |
| 606 |
- name: 'Cleanup complex firewall' |
| 607 |
networkfirewall: |
| 608 |
name: '{{ complex_firewall_name }}' |
| 609 |
state: absent |
| 610 |
delete_protection: False |
| 611 |
wait: False |
| 612 |
ignore_errors: True |