| 1 |
#################################### |
| 2 |
# Create and test rule group |
| 3 |
#################################### |
| 4 |
- name: check_mode create rule group |
| 5 |
wafv2_rule_group: |
| 6 |
name: "{{ rule_group_name }}" |
| 7 |
state: present |
| 8 |
description: hallo eins |
| 9 |
scope: REGIONAL |
| 10 |
capacity: 500 |
| 11 |
rules: |
| 12 |
- name: eins |
| 13 |
priority: 1 |
| 14 |
action: |
| 15 |
allow: {} |
| 16 |
visibility_config: |
| 17 |
sampled_requests_enabled: yes |
| 18 |
cloud_watch_metrics_enabled: yes |
| 19 |
metric_name: fsd |
| 20 |
statement: |
| 21 |
byte_match_statement: |
| 22 |
search_string: ansible.com |
| 23 |
positional_constraint: CONTAINS |
| 24 |
field_to_match: |
| 25 |
single_header: |
| 26 |
name: host |
| 27 |
text_transformations: |
| 28 |
- type: LOWERCASE |
| 29 |
priority: 0 |
| 30 |
cloudwatch_metrics: yes |
| 31 |
tags: |
| 32 |
A: B |
| 33 |
C: D |
| 34 |
register: out |
| 35 |
check_mode: yes |
| 36 |
|
| 37 |
- name: check_mode verify create |
| 38 |
assert: |
| 39 |
that: |
| 40 |
- out is changed |
| 41 |
|
| 42 |
- name: create rule group |
| 43 |
wafv2_rule_group: |
| 44 |
name: "{{ rule_group_name }}" |
| 45 |
state: present |
| 46 |
description: hallo eins |
| 47 |
scope: REGIONAL |
| 48 |
capacity: 500 |
| 49 |
rules: |
| 50 |
- name: eins |
| 51 |
priority: 1 |
| 52 |
action: |
| 53 |
allow: {} |
| 54 |
visibility_config: |
| 55 |
sampled_requests_enabled: yes |
| 56 |
cloud_watch_metrics_enabled: yes |
| 57 |
metric_name: fsd |
| 58 |
statement: |
| 59 |
byte_match_statement: |
| 60 |
search_string: ansible.com |
| 61 |
positional_constraint: CONTAINS |
| 62 |
field_to_match: |
| 63 |
single_header: |
| 64 |
name: host |
| 65 |
text_transformations: |
| 66 |
- type: LOWERCASE |
| 67 |
priority: 0 |
| 68 |
cloudwatch_metrics: yes |
| 69 |
tags: |
| 70 |
A: B |
| 71 |
C: D |
| 72 |
register: out |
| 73 |
|
| 74 |
- name: verify create |
| 75 |
assert: |
| 76 |
that: |
| 77 |
- out is changed |
| 78 |
|
| 79 |
- name: rule group info |
| 80 |
wafv2_rule_group_info: |
| 81 |
name: "{{ rule_group_name }}" |
| 82 |
scope: REGIONAL |
| 83 |
register: out |
| 84 |
|
| 85 |
- name: verify one rule |
| 86 |
assert: |
| 87 |
that: |
| 88 |
- out.rules | count == 1 |
| 89 |
|
| 90 |
- name: immutable create rule group |
| 91 |
wafv2_rule_group: |
| 92 |
name: "{{ rule_group_name }}" |
| 93 |
state: present |
| 94 |
description: hallo eins |
| 95 |
scope: REGIONAL |
| 96 |
capacity: 500 |
| 97 |
rules: |
| 98 |
- name: eins |
| 99 |
priority: 1 |
| 100 |
action: |
| 101 |
allow: {} |
| 102 |
visibility_config: |
| 103 |
sampled_requests_enabled: yes |
| 104 |
cloud_watch_metrics_enabled: yes |
| 105 |
metric_name: fsd |
| 106 |
statement: |
| 107 |
byte_match_statement: |
| 108 |
search_string: ansible.com |
| 109 |
positional_constraint: CONTAINS |
| 110 |
field_to_match: |
| 111 |
single_header: |
| 112 |
name: host |
| 113 |
text_transformations: |
| 114 |
- type: LOWERCASE |
| 115 |
priority: 0 |
| 116 |
cloudwatch_metrics: yes |
| 117 |
tags: |
| 118 |
A: B |
| 119 |
C: D |
| 120 |
register: out |
| 121 |
|
| 122 |
- name: verify immutable create |
| 123 |
assert: |
| 124 |
that: |
| 125 |
- out is not changed |
| 126 |
|
| 127 |
- name: change description |
| 128 |
wafv2_rule_group: |
| 129 |
name: "{{ rule_group_name }}" |
| 130 |
state: present |
| 131 |
description: hallo eins zwei |
| 132 |
scope: REGIONAL |
| 133 |
capacity: 500 |
| 134 |
rules: |
| 135 |
- name: eins |
| 136 |
priority: 1 |
| 137 |
action: |
| 138 |
allow: {} |
| 139 |
visibility_config: |
| 140 |
sampled_requests_enabled: yes |
| 141 |
cloud_watch_metrics_enabled: yes |
| 142 |
metric_name: fsd |
| 143 |
statement: |
| 144 |
byte_match_statement: |
| 145 |
search_string: ansible.com |
| 146 |
positional_constraint: CONTAINS |
| 147 |
field_to_match: |
| 148 |
single_header: |
| 149 |
name: host |
| 150 |
text_transformations: |
| 151 |
- type: LOWERCASE |
| 152 |
priority: 0 |
| 153 |
cloudwatch_metrics: yes |
| 154 |
tags: |
| 155 |
A: B |
| 156 |
C: D |
| 157 |
register: out |
| 158 |
|
| 159 |
- name: verify change |
| 160 |
assert: |
| 161 |
that: |
| 162 |
- out is changed |
| 163 |
|
| 164 |
- name: iummutable change description |
| 165 |
wafv2_rule_group: |
| 166 |
name: "{{ rule_group_name }}" |
| 167 |
state: present |
| 168 |
description: hallo eins zwei |
| 169 |
scope: REGIONAL |
| 170 |
capacity: 500 |
| 171 |
rules: |
| 172 |
- name: eins |
| 173 |
priority: 1 |
| 174 |
action: |
| 175 |
allow: {} |
| 176 |
visibility_config: |
| 177 |
sampled_requests_enabled: yes |
| 178 |
cloud_watch_metrics_enabled: yes |
| 179 |
metric_name: fsd |
| 180 |
statement: |
| 181 |
byte_match_statement: |
| 182 |
search_string: ansible.com |
| 183 |
positional_constraint: CONTAINS |
| 184 |
field_to_match: |
| 185 |
single_header: |
| 186 |
name: host |
| 187 |
text_transformations: |
| 188 |
- type: LOWERCASE |
| 189 |
priority: 0 |
| 190 |
cloudwatch_metrics: yes |
| 191 |
tags: |
| 192 |
A: B |
| 193 |
C: D |
| 194 |
register: out |
| 195 |
|
| 196 |
- name: verify no change |
| 197 |
assert: |
| 198 |
that: |
| 199 |
- out is not changed |
| 200 |
|
| 201 |
- name: add rule |
| 202 |
wafv2_rule_group: |
| 203 |
name: "{{ rule_group_name }}" |
| 204 |
state: present |
| 205 |
description: hallo eins zwei |
| 206 |
scope: REGIONAL |
| 207 |
capacity: 500 |
| 208 |
rules: |
| 209 |
- name: eins |
| 210 |
priority: 1 |
| 211 |
action: |
| 212 |
allow: {} |
| 213 |
visibility_config: |
| 214 |
sampled_requests_enabled: yes |
| 215 |
cloud_watch_metrics_enabled: yes |
| 216 |
metric_name: fsd |
| 217 |
statement: |
| 218 |
byte_match_statement: |
| 219 |
search_string: ansible.com |
| 220 |
positional_constraint: CONTAINS |
| 221 |
field_to_match: |
| 222 |
single_header: |
| 223 |
name: host |
| 224 |
text_transformations: |
| 225 |
- type: LOWERCASE |
| 226 |
priority: 0 |
| 227 |
- name: zwei |
| 228 |
priority: 2 |
| 229 |
action: |
| 230 |
block: {} |
| 231 |
visibility_config: |
| 232 |
sampled_requests_enabled: yes |
| 233 |
cloud_watch_metrics_enabled: yes |
| 234 |
metric_name: ddos |
| 235 |
statement: |
| 236 |
or_statement: |
| 237 |
statements: |
| 238 |
- byte_match_statement: |
| 239 |
search_string: ansible.com |
| 240 |
positional_constraint: CONTAINS |
| 241 |
field_to_match: |
| 242 |
single_header: |
| 243 |
name: host |
| 244 |
text_transformations: |
| 245 |
- type: LOWERCASE |
| 246 |
priority: 0 |
| 247 |
- xss_match_statement: |
| 248 |
field_to_match: |
| 249 |
body: {} |
| 250 |
text_transformations: |
| 251 |
- type: NONE |
| 252 |
priority: 0 |
| 253 |
cloudwatch_metrics: yes |
| 254 |
tags: |
| 255 |
A: B |
| 256 |
C: D |
| 257 |
register: out |
| 258 |
|
| 259 |
- name: verify change |
| 260 |
assert: |
| 261 |
that: |
| 262 |
- out is changed |
| 263 |
|
| 264 |
- name: immutable add rule |
| 265 |
wafv2_rule_group: |
| 266 |
name: "{{ rule_group_name }}" |
| 267 |
state: present |
| 268 |
description: hallo eins zwei |
| 269 |
scope: REGIONAL |
| 270 |
capacity: 500 |
| 271 |
rules: |
| 272 |
- name: eins |
| 273 |
priority: 1 |
| 274 |
action: |
| 275 |
allow: {} |
| 276 |
visibility_config: |
| 277 |
sampled_requests_enabled: yes |
| 278 |
cloud_watch_metrics_enabled: yes |
| 279 |
metric_name: fsd |
| 280 |
statement: |
| 281 |
byte_match_statement: |
| 282 |
search_string: ansible.com |
| 283 |
positional_constraint: CONTAINS |
| 284 |
field_to_match: |
| 285 |
single_header: |
| 286 |
name: host |
| 287 |
text_transformations: |
| 288 |
- type: LOWERCASE |
| 289 |
priority: 0 |
| 290 |
- name: zwei |
| 291 |
priority: 2 |
| 292 |
action: |
| 293 |
block: {} |
| 294 |
visibility_config: |
| 295 |
sampled_requests_enabled: yes |
| 296 |
cloud_watch_metrics_enabled: yes |
| 297 |
metric_name: ddos |
| 298 |
statement: |
| 299 |
or_statement: |
| 300 |
statements: |
| 301 |
- byte_match_statement: |
| 302 |
search_string: ansible.com |
| 303 |
positional_constraint: CONTAINS |
| 304 |
field_to_match: |
| 305 |
single_header: |
| 306 |
name: host |
| 307 |
text_transformations: |
| 308 |
- type: LOWERCASE |
| 309 |
priority: 0 |
| 310 |
- xss_match_statement: |
| 311 |
field_to_match: |
| 312 |
body: {} |
| 313 |
text_transformations: |
| 314 |
- type: NONE |
| 315 |
priority: 0 |
| 316 |
cloudwatch_metrics: yes |
| 317 |
tags: |
| 318 |
A: B |
| 319 |
C: D |
| 320 |
register: out |
| 321 |
|
| 322 |
- name: verify no change |
| 323 |
assert: |
| 324 |
that: |
| 325 |
- out is not changed |
| 326 |
|
| 327 |
- name: change rule |
| 328 |
wafv2_rule_group: |
| 329 |
name: "{{ rule_group_name }}" |
| 330 |
state: present |
| 331 |
description: hallo eins zwei |
| 332 |
scope: REGIONAL |
| 333 |
capacity: 500 |
| 334 |
rules: |
| 335 |
- name: eins |
| 336 |
priority: 1 |
| 337 |
action: |
| 338 |
allow: {} |
| 339 |
visibility_config: |
| 340 |
sampled_requests_enabled: yes |
| 341 |
cloud_watch_metrics_enabled: yes |
| 342 |
metric_name: fsd |
| 343 |
statement: |
| 344 |
byte_match_statement: |
| 345 |
search_string: ansible.com |
| 346 |
positional_constraint: CONTAINS |
| 347 |
field_to_match: |
| 348 |
single_header: |
| 349 |
name: host |
| 350 |
text_transformations: |
| 351 |
- type: LOWERCASE |
| 352 |
priority: 0 |
| 353 |
- name: zwei |
| 354 |
priority: 3 |
| 355 |
action: |
| 356 |
block: {} |
| 357 |
visibility_config: |
| 358 |
sampled_requests_enabled: yes |
| 359 |
cloud_watch_metrics_enabled: yes |
| 360 |
metric_name: ddos |
| 361 |
statement: |
| 362 |
or_statement: |
| 363 |
statements: |
| 364 |
- byte_match_statement: |
| 365 |
search_string: ansible.com |
| 366 |
positional_constraint: CONTAINS |
| 367 |
field_to_match: |
| 368 |
single_header: |
| 369 |
name: host |
| 370 |
text_transformations: |
| 371 |
- type: LOWERCASE |
| 372 |
priority: 0 |
| 373 |
- xss_match_statement: |
| 374 |
field_to_match: |
| 375 |
body: {} |
| 376 |
text_transformations: |
| 377 |
- type: NONE |
| 378 |
priority: 0 |
| 379 |
cloudwatch_metrics: yes |
| 380 |
tags: |
| 381 |
A: B |
| 382 |
C: D |
| 383 |
register: out |
| 384 |
|
| 385 |
- name: verify change |
| 386 |
assert: |
| 387 |
that: |
| 388 |
- out is changed |
| 389 |
|
| 390 |
- name: immutable change rule |
| 391 |
wafv2_rule_group: |
| 392 |
name: "{{ rule_group_name }}" |
| 393 |
state: present |
| 394 |
description: hallo eins zwei |
| 395 |
scope: REGIONAL |
| 396 |
capacity: 500 |
| 397 |
rules: |
| 398 |
- name: eins |
| 399 |
priority: 1 |
| 400 |
action: |
| 401 |
allow: {} |
| 402 |
visibility_config: |
| 403 |
sampled_requests_enabled: yes |
| 404 |
cloud_watch_metrics_enabled: yes |
| 405 |
metric_name: fsd |
| 406 |
statement: |
| 407 |
byte_match_statement: |
| 408 |
search_string: ansible.com |
| 409 |
positional_constraint: CONTAINS |
| 410 |
field_to_match: |
| 411 |
single_header: |
| 412 |
name: host |
| 413 |
text_transformations: |
| 414 |
- type: LOWERCASE |
| 415 |
priority: 0 |
| 416 |
- name: zwei |
| 417 |
priority: 3 |
| 418 |
action: |
| 419 |
block: {} |
| 420 |
visibility_config: |
| 421 |
sampled_requests_enabled: yes |
| 422 |
cloud_watch_metrics_enabled: yes |
| 423 |
metric_name: ddos |
| 424 |
statement: |
| 425 |
or_statement: |
| 426 |
statements: |
| 427 |
- byte_match_statement: |
| 428 |
search_string: ansible.com |
| 429 |
positional_constraint: CONTAINS |
| 430 |
field_to_match: |
| 431 |
single_header: |
| 432 |
name: host |
| 433 |
text_transformations: |
| 434 |
- type: LOWERCASE |
| 435 |
priority: 0 |
| 436 |
- xss_match_statement: |
| 437 |
field_to_match: |
| 438 |
body: {} |
| 439 |
text_transformations: |
| 440 |
- type: NONE |
| 441 |
priority: 0 |
| 442 |
cloudwatch_metrics: yes |
| 443 |
tags: |
| 444 |
A: B |
| 445 |
C: D |
| 446 |
register: out |
| 447 |
|
| 448 |
- name: verify no change |
| 449 |
assert: |
| 450 |
that: |
| 451 |
- out is not changed |
| 452 |
|
| 453 |
- name: change rule again |
| 454 |
wafv2_rule_group: |
| 455 |
name: "{{ rule_group_name }}" |
| 456 |
state: present |
| 457 |
description: hallo eins zwei |
| 458 |
scope: REGIONAL |
| 459 |
capacity: 500 |
| 460 |
rules: |
| 461 |
- name: zwei |
| 462 |
priority: 1 |
| 463 |
action: |
| 464 |
block: {} |
| 465 |
visibility_config: |
| 466 |
sampled_requests_enabled: yes |
| 467 |
cloud_watch_metrics_enabled: yes |
| 468 |
metric_name: ddos |
| 469 |
statement: |
| 470 |
or_statement: |
| 471 |
statements: |
| 472 |
- byte_match_statement: |
| 473 |
search_string: ansible.com |
| 474 |
positional_constraint: CONTAINS |
| 475 |
field_to_match: |
| 476 |
single_header: |
| 477 |
name: host |
| 478 |
text_transformations: |
| 479 |
- type: LOWERCASE |
| 480 |
priority: 0 |
| 481 |
- xss_match_statement: |
| 482 |
field_to_match: |
| 483 |
body: {} |
| 484 |
text_transformations: |
| 485 |
- type: NONE |
| 486 |
priority: 0 |
| 487 |
- name: eins |
| 488 |
priority: 2 |
| 489 |
action: |
| 490 |
allow: {} |
| 491 |
visibility_config: |
| 492 |
sampled_requests_enabled: yes |
| 493 |
cloud_watch_metrics_enabled: yes |
| 494 |
metric_name: fsd |
| 495 |
statement: |
| 496 |
byte_match_statement: |
| 497 |
search_string: ansible.com |
| 498 |
positional_constraint: CONTAINS |
| 499 |
field_to_match: |
| 500 |
single_header: |
| 501 |
name: host |
| 502 |
text_transformations: |
| 503 |
- type: LOWERCASE |
| 504 |
priority: 0 |
| 505 |
cloudwatch_metrics: yes |
| 506 |
tags: |
| 507 |
A: B |
| 508 |
C: D |
| 509 |
register: out |
| 510 |
|
| 511 |
- name: verify change |
| 512 |
assert: |
| 513 |
that: |
| 514 |
- out is changed |
| 515 |
|
| 516 |
- name: add one rule |
| 517 |
wafv2_rule_group: |
| 518 |
name: "{{ rule_group_name }}" |
| 519 |
state: present |
| 520 |
description: hallo eins zwei |
| 521 |
scope: REGIONAL |
| 522 |
capacity: 500 |
| 523 |
purge_rules: no |
| 524 |
rules: |
| 525 |
- name: allow-admin-svg |
| 526 |
priority: 3 |
| 527 |
action: |
| 528 |
allow: {} |
| 529 |
visibility_config: |
| 530 |
sampled_requests_enabled: yes |
| 531 |
cloud_watch_metrics_enabled: yes |
| 532 |
metric_name: allow-admin-svg |
| 533 |
statement: |
| 534 |
byte_match_statement: |
| 535 |
search_string: admin.svg |
| 536 |
positional_constraint: CONTAINS |
| 537 |
field_to_match: |
| 538 |
uri_path: {} |
| 539 |
text_transformations: |
| 540 |
- type: LOWERCASE |
| 541 |
priority: 0 |
| 542 |
cloudwatch_metrics: yes |
| 543 |
tags: |
| 544 |
A: B |
| 545 |
C: D |
| 546 |
register: out |
| 547 |
|
| 548 |
- name: verify change |
| 549 |
assert: |
| 550 |
that: |
| 551 |
- out is changed |
| 552 |
|
| 553 |
- name: rule group info |
| 554 |
wafv2_rule_group_info: |
| 555 |
name: "{{ rule_group_name }}" |
| 556 |
scope: REGIONAL |
| 557 |
register: out |
| 558 |
|
| 559 |
- name: verify create |
| 560 |
assert: |
| 561 |
that: |
| 562 |
- out.rules | count == 3 |
| 563 |
|
| 564 |
- name: immutable add one rule |
| 565 |
wafv2_rule_group: |
| 566 |
name: "{{ rule_group_name }}" |
| 567 |
state: present |
| 568 |
description: hallo eins zwei |
| 569 |
scope: REGIONAL |
| 570 |
capacity: 500 |
| 571 |
purge_rules: no |
| 572 |
rules: |
| 573 |
- name: allow-admin-svg |
| 574 |
priority: 3 |
| 575 |
action: |
| 576 |
allow: {} |
| 577 |
visibility_config: |
| 578 |
sampled_requests_enabled: yes |
| 579 |
cloud_watch_metrics_enabled: yes |
| 580 |
metric_name: allow-admin-svg |
| 581 |
statement: |
| 582 |
byte_match_statement: |
| 583 |
search_string: admin.svg |
| 584 |
positional_constraint: CONTAINS |
| 585 |
field_to_match: |
| 586 |
uri_path: {} |
| 587 |
text_transformations: |
| 588 |
- type: LOWERCASE |
| 589 |
priority: 0 |
| 590 |
cloudwatch_metrics: yes |
| 591 |
tags: |
| 592 |
A: B |
| 593 |
C: D |
| 594 |
register: out |
| 595 |
|
| 596 |
- name: verify no change |
| 597 |
assert: |
| 598 |
that: |
| 599 |
- out is not changed |
| 600 |
|
| 601 |
- name: purge rules |
| 602 |
wafv2_rule_group: |
| 603 |
name: "{{ rule_group_name }}" |
| 604 |
state: present |
| 605 |
description: hallo eins zwei |
| 606 |
scope: REGIONAL |
| 607 |
capacity: 500 |
| 608 |
purge_rules: yes |
| 609 |
rules: |
| 610 |
- name: allow-admin-svg |
| 611 |
priority: 3 |
| 612 |
action: |
| 613 |
allow: {} |
| 614 |
visibility_config: |
| 615 |
sampled_requests_enabled: yes |
| 616 |
cloud_watch_metrics_enabled: yes |
| 617 |
metric_name: allow-admin-svg |
| 618 |
statement: |
| 619 |
byte_match_statement: |
| 620 |
search_string: admin.svg |
| 621 |
positional_constraint: CONTAINS |
| 622 |
field_to_match: |
| 623 |
uri_path: {} |
| 624 |
text_transformations: |
| 625 |
- type: LOWERCASE |
| 626 |
priority: 0 |
| 627 |
cloudwatch_metrics: yes |
| 628 |
tags: |
| 629 |
A: B |
| 630 |
C: D |
| 631 |
register: out |
| 632 |
|
| 633 |
- name: verify change |
| 634 |
assert: |
| 635 |
that: |
| 636 |
- out is changed |
| 637 |
|
| 638 |
- name: absent one rule rules |
| 639 |
wafv2_rule_group: |
| 640 |
name: "{{ rule_group_name }}" |
| 641 |
state: absent |
| 642 |
description: hallo eins zwei |
| 643 |
scope: REGIONAL |
| 644 |
rules: |
| 645 |
- name: allow-admin-svg |
| 646 |
priority: 3 |
| 647 |
action: |
| 648 |
allow: {} |
| 649 |
visibility_config: |
| 650 |
sampled_requests_enabled: yes |
| 651 |
cloud_watch_metrics_enabled: yes |
| 652 |
metric_name: allow-admin-svg |
| 653 |
statement: |
| 654 |
byte_match_statement: |
| 655 |
search_string: admin.svg |
| 656 |
positional_constraint: CONTAINS |
| 657 |
field_to_match: |
| 658 |
uri_path: {} |
| 659 |
text_transformations: |
| 660 |
- type: LOWERCASE |
| 661 |
priority: 0 |
| 662 |
register: out |
| 663 |
|
| 664 |
- name: verify change |
| 665 |
assert: |
| 666 |
that: |
| 667 |
- out is changed |
| 668 |
|
| 669 |
- name: rule group info |
| 670 |
wafv2_rule_group_info: |
| 671 |
name: "{{ rule_group_name }}" |
| 672 |
scope: REGIONAL |
| 673 |
register: out |
| 674 |
|
| 675 |
- name: verify change |
| 676 |
assert: |
| 677 |
that: |
| 678 |
- out.rules | count == 0 |