@@ -461,7 +461,9 @@ func TestAccWAFV2RuleGroup_ByteMatchStatement_fieldToMatch(t *testing.T) {
461
461
"statement.0.byte_match_statement.0.field_to_match.0.all_query_arguments.#" : "1" ,
462
462
"statement.0.byte_match_statement.0.field_to_match.0.body.#" : "0" ,
463
463
"statement.0.byte_match_statement.0.field_to_match.0.cookies.#" : "0" ,
464
+ "statement.0.byte_match_statement.0.field_to_match.0.header_order.#" : "0" ,
464
465
"statement.0.byte_match_statement.0.field_to_match.0.headers.#" : "0" ,
466
+ "statement.0.byte_match_statement.0.field_to_match.0.ja3_fingerprint.#" : "0" ,
465
467
"statement.0.byte_match_statement.0.field_to_match.0.json_body.#" : "0" ,
466
468
"statement.0.byte_match_statement.0.field_to_match.0.method.#" : "0" ,
467
469
"statement.0.byte_match_statement.0.field_to_match.0.query_string.#" : "0" ,
@@ -484,7 +486,9 @@ func TestAccWAFV2RuleGroup_ByteMatchStatement_fieldToMatch(t *testing.T) {
484
486
"statement.0.byte_match_statement.0.field_to_match.0.all_query_arguments.#" : "0" ,
485
487
"statement.0.byte_match_statement.0.field_to_match.0.body.#" : "1" ,
486
488
"statement.0.byte_match_statement.0.field_to_match.0.cookies.#" : "0" ,
489
+ "statement.0.byte_match_statement.0.field_to_match.0.header_order.#" : "0" ,
487
490
"statement.0.byte_match_statement.0.field_to_match.0.headers.#" : "0" ,
491
+ "statement.0.byte_match_statement.0.field_to_match.0.ja3_fingerprint.#" : "0" ,
488
492
"statement.0.byte_match_statement.0.field_to_match.0.json_body.#" : "0" ,
489
493
"statement.0.byte_match_statement.0.field_to_match.0.method.#" : "0" ,
490
494
"statement.0.byte_match_statement.0.field_to_match.0.query_string.#" : "0" ,
@@ -512,7 +516,9 @@ func TestAccWAFV2RuleGroup_ByteMatchStatement_fieldToMatch(t *testing.T) {
512
516
"statement.0.byte_match_statement.0.field_to_match.0.cookies.0.match_pattern.#" : "1" ,
513
517
"statement.0.byte_match_statement.0.field_to_match.0.cookies.0.match_pattern.0.included_cookies.0" : "test" ,
514
518
"statement.0.byte_match_statement.0.field_to_match.0.cookies.0.match_pattern.0.included_cookies.1" : "cookie_test" ,
519
+ "statement.0.byte_match_statement.0.field_to_match.0.header_order.#" : "0" ,
515
520
"statement.0.byte_match_statement.0.field_to_match.0.headers.#" : "0" ,
521
+ "statement.0.byte_match_statement.0.field_to_match.0.ja3_fingerprint.#" : "0" ,
516
522
"statement.0.byte_match_statement.0.field_to_match.0.json_body.#" : "0" ,
517
523
"statement.0.byte_match_statement.0.field_to_match.0.method.#" : "0" ,
518
524
"statement.0.byte_match_statement.0.field_to_match.0.query_string.#" : "0" ,
@@ -543,6 +549,32 @@ func TestAccWAFV2RuleGroup_ByteMatchStatement_fieldToMatch(t *testing.T) {
543
549
}),
544
550
),
545
551
},
552
+ {
553
+ Config : testAccRuleGroupConfig_byteMatchStatementFieldToMatchHeaderOrder (ruleGroupName ),
554
+ Check : resource .ComposeTestCheckFunc (
555
+ testAccCheckRuleGroupExists (ctx , resourceName , & v ),
556
+ acctest .MatchResourceAttrRegionalARN (resourceName , "arn" , "wafv2" , regexache .MustCompile (`regional/rulegroup/.+$` )),
557
+ resource .TestCheckResourceAttr (resourceName , "rule.#" , "1" ),
558
+ resource .TestCheckTypeSetElemNestedAttrs (resourceName , "rule.*" , map [string ]string {
559
+ "statement.#" : "1" ,
560
+ "statement.0.byte_match_statement.#" : "1" ,
561
+ "statement.0.byte_match_statement.0.field_to_match.#" : "1" ,
562
+ "statement.0.byte_match_statement.0.field_to_match.0.all_query_arguments.#" : "0" ,
563
+ "statement.0.byte_match_statement.0.field_to_match.0.body.#" : "0" ,
564
+ "statement.0.byte_match_statement.0.field_to_match.0.cookies.#" : "0" ,
565
+ "statement.0.byte_match_statement.0.field_to_match.0.header_order.#" : "1" ,
566
+ "statement.0.byte_match_statement.0.field_to_match.0.header_order.0.oversize_handling" : "MATCH" ,
567
+ "statement.0.byte_match_statement.0.field_to_match.0.headers.#" : "0" ,
568
+ "statement.0.byte_match_statement.0.field_to_match.0.ja3_fingerprint.#" : "0" ,
569
+ "statement.0.byte_match_statement.0.field_to_match.0.json_body.#" : "0" ,
570
+ "statement.0.byte_match_statement.0.field_to_match.0.method.#" : "0" ,
571
+ "statement.0.byte_match_statement.0.field_to_match.0.query_string.#" : "0" ,
572
+ "statement.0.byte_match_statement.0.field_to_match.0.single_header.#" : "0" ,
573
+ "statement.0.byte_match_statement.0.field_to_match.0.single_query_argument.#" : "0" ,
574
+ "statement.0.byte_match_statement.0.field_to_match.0.uri_path.#" : "0" ,
575
+ }),
576
+ ),
577
+ },
546
578
{
547
579
Config : testAccRuleGroupConfig_byteMatchStatementFieldToMatchHeadersMatchPatternAll (ruleGroupName ),
548
580
Check : resource .ComposeTestCheckFunc (
@@ -556,13 +588,15 @@ func TestAccWAFV2RuleGroup_ByteMatchStatement_fieldToMatch(t *testing.T) {
556
588
"statement.0.byte_match_statement.0.field_to_match.0.all_query_arguments.#" : "0" ,
557
589
"statement.0.byte_match_statement.0.field_to_match.0.body.#" : "0" ,
558
590
"statement.0.byte_match_statement.0.field_to_match.0.cookies.#" : "0" ,
591
+ "statement.0.byte_match_statement.0.field_to_match.0.header_order.#" : "0" ,
559
592
"statement.0.byte_match_statement.0.field_to_match.0.headers.#" : "1" ,
560
593
"statement.0.byte_match_statement.0.field_to_match.0.headers.0.oversize_handling" : "MATCH" ,
561
594
"statement.0.byte_match_statement.0.field_to_match.0.headers.0.match_scope" : "ALL" ,
562
595
"statement.0.byte_match_statement.0.field_to_match.0.headers.0.match_pattern.#" : "1" ,
563
596
"statement.0.byte_match_statement.0.field_to_match.0.headers.0.match_pattern.0.all.#" : "1" ,
564
597
"statement.0.byte_match_statement.0.field_to_match.0.headers.0.match_pattern.0.included_headers.#" : "0" ,
565
598
"statement.0.byte_match_statement.0.field_to_match.0.headers.0.match_pattern.0.excluded_headers.#" : "0" ,
599
+ "statement.0.byte_match_statement.0.field_to_match.0.ja3_fingerprint.#" : "0" ,
566
600
"statement.0.byte_match_statement.0.field_to_match.0.json_body.#" : "0" ,
567
601
"statement.0.byte_match_statement.0.field_to_match.0.method.#" : "0" ,
568
602
"statement.0.byte_match_statement.0.field_to_match.0.query_string.#" : "0" ,
@@ -585,6 +619,7 @@ func TestAccWAFV2RuleGroup_ByteMatchStatement_fieldToMatch(t *testing.T) {
585
619
"statement.0.byte_match_statement.0.field_to_match.0.all_query_arguments.#" : "0" ,
586
620
"statement.0.byte_match_statement.0.field_to_match.0.body.#" : "0" ,
587
621
"statement.0.byte_match_statement.0.field_to_match.0.cookies.#" : "0" ,
622
+ "statement.0.byte_match_statement.0.field_to_match.0.header_order.#" : "0" ,
588
623
"statement.0.byte_match_statement.0.field_to_match.0.headers.#" : "1" ,
589
624
"statement.0.byte_match_statement.0.field_to_match.0.headers.0.oversize_handling" : "MATCH" ,
590
625
"statement.0.byte_match_statement.0.field_to_match.0.headers.0.match_scope" : "ALL" ,
@@ -594,6 +629,7 @@ func TestAccWAFV2RuleGroup_ByteMatchStatement_fieldToMatch(t *testing.T) {
594
629
"statement.0.byte_match_statement.0.field_to_match.0.headers.0.match_pattern.0.included_headers.0" : "session" ,
595
630
"statement.0.byte_match_statement.0.field_to_match.0.headers.0.match_pattern.0.included_headers.1" : "session-id" ,
596
631
"statement.0.byte_match_statement.0.field_to_match.0.headers.0.match_pattern.0.excluded_headers.#" : "0" ,
632
+ "statement.0.byte_match_statement.0.field_to_match.0.ja3_fingerprint.#" : "0" ,
597
633
"statement.0.byte_match_statement.0.field_to_match.0.json_body.#" : "0" ,
598
634
"statement.0.byte_match_statement.0.field_to_match.0.method.#" : "0" ,
599
635
"statement.0.byte_match_statement.0.field_to_match.0.query_string.#" : "0" ,
@@ -616,6 +652,7 @@ func TestAccWAFV2RuleGroup_ByteMatchStatement_fieldToMatch(t *testing.T) {
616
652
"statement.0.byte_match_statement.0.field_to_match.0.all_query_arguments.#" : "0" ,
617
653
"statement.0.byte_match_statement.0.field_to_match.0.body.#" : "0" ,
618
654
"statement.0.byte_match_statement.0.field_to_match.0.cookies.#" : "0" ,
655
+ "statement.0.byte_match_statement.0.field_to_match.0.header_order.#" : "0" ,
619
656
"statement.0.byte_match_statement.0.field_to_match.0.headers.#" : "1" ,
620
657
"statement.0.byte_match_statement.0.field_to_match.0.headers.0.oversize_handling" : "MATCH" ,
621
658
"statement.0.byte_match_statement.0.field_to_match.0.headers.0.match_scope" : "ALL" ,
@@ -625,6 +662,7 @@ func TestAccWAFV2RuleGroup_ByteMatchStatement_fieldToMatch(t *testing.T) {
625
662
"statement.0.byte_match_statement.0.field_to_match.0.headers.0.match_pattern.0.excluded_headers.0" : "session" ,
626
663
"statement.0.byte_match_statement.0.field_to_match.0.headers.0.match_pattern.0.excluded_headers.1" : "session-id" ,
627
664
"statement.0.byte_match_statement.0.field_to_match.0.headers.0.match_pattern.0.included_headers.#" : "0" ,
665
+ "statement.0.byte_match_statement.0.field_to_match.0.ja3_fingerprint.#" : "0" ,
628
666
"statement.0.byte_match_statement.0.field_to_match.0.json_body.#" : "0" ,
629
667
"statement.0.byte_match_statement.0.field_to_match.0.method.#" : "0" ,
630
668
"statement.0.byte_match_statement.0.field_to_match.0.query_string.#" : "0" ,
@@ -651,7 +689,9 @@ func TestAccWAFV2RuleGroup_ByteMatchStatement_fieldToMatch(t *testing.T) {
651
689
"statement.0.byte_match_statement.0.field_to_match.0.all_query_arguments.#" : "0" ,
652
690
"statement.0.byte_match_statement.0.field_to_match.0.body.#" : "0" ,
653
691
"statement.0.byte_match_statement.0.field_to_match.0.cookies.#" : "0" ,
692
+ "statement.0.byte_match_statement.0.field_to_match.0.header_order.#" : "0" ,
654
693
"statement.0.byte_match_statement.0.field_to_match.0.headers.#" : "0" ,
694
+ "statement.0.byte_match_statement.0.field_to_match.0.ja3_fingerprint.#" : "0" ,
655
695
"statement.0.byte_match_statement.0.field_to_match.0.json_body.#" : "0" ,
656
696
"statement.0.byte_match_statement.0.field_to_match.0.method.#" : "1" ,
657
697
"statement.0.byte_match_statement.0.field_to_match.0.query_string.#" : "0" ,
@@ -674,7 +714,9 @@ func TestAccWAFV2RuleGroup_ByteMatchStatement_fieldToMatch(t *testing.T) {
674
714
"statement.0.byte_match_statement.0.field_to_match.0.all_query_arguments.#" : "0" ,
675
715
"statement.0.byte_match_statement.0.field_to_match.0.body.#" : "0" ,
676
716
"statement.0.byte_match_statement.0.field_to_match.0.cookies.#" : "0" ,
717
+ "statement.0.byte_match_statement.0.field_to_match.0.header_order.#" : "0" ,
677
718
"statement.0.byte_match_statement.0.field_to_match.0.headers.#" : "0" ,
719
+ "statement.0.byte_match_statement.0.field_to_match.0.ja3_fingerprint.#" : "0" ,
678
720
"statement.0.byte_match_statement.0.field_to_match.0.json_body.#" : "0" ,
679
721
"statement.0.byte_match_statement.0.field_to_match.0.method.#" : "0" ,
680
722
"statement.0.byte_match_statement.0.field_to_match.0.query_string.#" : "1" ,
@@ -697,7 +739,9 @@ func TestAccWAFV2RuleGroup_ByteMatchStatement_fieldToMatch(t *testing.T) {
697
739
"statement.0.byte_match_statement.0.field_to_match.0.all_query_arguments.#" : "0" ,
698
740
"statement.0.byte_match_statement.0.field_to_match.0.body.#" : "0" ,
699
741
"statement.0.byte_match_statement.0.field_to_match.0.cookies.#" : "0" ,
742
+ "statement.0.byte_match_statement.0.field_to_match.0.header_order.#" : "0" ,
700
743
"statement.0.byte_match_statement.0.field_to_match.0.headers.#" : "0" ,
744
+ "statement.0.byte_match_statement.0.field_to_match.0.ja3_fingerprint.#" : "0" ,
701
745
"statement.0.byte_match_statement.0.field_to_match.0.json_body.#" : "0" ,
702
746
"statement.0.byte_match_statement.0.field_to_match.0.method.#" : "0" ,
703
747
"statement.0.byte_match_statement.0.field_to_match.0.query_string.#" : "0" ,
@@ -721,7 +765,9 @@ func TestAccWAFV2RuleGroup_ByteMatchStatement_fieldToMatch(t *testing.T) {
721
765
"statement.0.byte_match_statement.0.field_to_match.0.all_query_arguments.#" : "0" ,
722
766
"statement.0.byte_match_statement.0.field_to_match.0.body.#" : "0" ,
723
767
"statement.0.byte_match_statement.0.field_to_match.0.cookies.#" : "0" ,
768
+ "statement.0.byte_match_statement.0.field_to_match.0.header_order.#" : "0" ,
724
769
"statement.0.byte_match_statement.0.field_to_match.0.headers.#" : "0" ,
770
+ "statement.0.byte_match_statement.0.field_to_match.0.ja3_fingerprint.#" : "0" ,
725
771
"statement.0.byte_match_statement.0.field_to_match.0.json_body.#" : "0" ,
726
772
"statement.0.byte_match_statement.0.field_to_match.0.method.#" : "0" ,
727
773
"statement.0.byte_match_statement.0.field_to_match.0.query_string.#" : "0" ,
@@ -745,7 +791,9 @@ func TestAccWAFV2RuleGroup_ByteMatchStatement_fieldToMatch(t *testing.T) {
745
791
"statement.0.byte_match_statement.0.field_to_match.0.all_query_arguments.#" : "0" ,
746
792
"statement.0.byte_match_statement.0.field_to_match.0.body.#" : "0" ,
747
793
"statement.0.byte_match_statement.0.field_to_match.0.cookies.#" : "0" ,
794
+ "statement.0.byte_match_statement.0.field_to_match.0.header_order.#" : "0" ,
748
795
"statement.0.byte_match_statement.0.field_to_match.0.headers.#" : "0" ,
796
+ "statement.0.byte_match_statement.0.field_to_match.0.ja3_fingerprint.#" : "0" ,
749
797
"statement.0.byte_match_statement.0.field_to_match.0.json_body.#" : "0" ,
750
798
"statement.0.byte_match_statement.0.field_to_match.0.method.#" : "0" ,
751
799
"statement.0.byte_match_statement.0.field_to_match.0.query_string.#" : "0" ,
@@ -3294,6 +3342,53 @@ resource "aws_wafv2_rule_group" "test" {
3294
3342
` , rName )
3295
3343
}
3296
3344
3345
+ func testAccRuleGroupConfig_byteMatchStatementFieldToMatchHeaderOrder (rName string ) string {
3346
+ return fmt .Sprintf (`
3347
+ resource "aws_wafv2_rule_group" "test" {
3348
+ capacity = 50
3349
+ name = %[1]q
3350
+ scope = "REGIONAL"
3351
+
3352
+ rule {
3353
+ name = "rule-1"
3354
+ priority = 1
3355
+
3356
+ action {
3357
+ allow {}
3358
+ }
3359
+
3360
+ statement {
3361
+ byte_match_statement {
3362
+ search_string = "host:user-agent:accept:authorization:referer"
3363
+ field_to_match {
3364
+ header_order {
3365
+ oversize_handling = "MATCH"
3366
+ }
3367
+ }
3368
+ text_transformation {
3369
+ priority = 0
3370
+ type = "NONE"
3371
+ }
3372
+ positional_constraint = "STARTS_WITH"
3373
+ }
3374
+ }
3375
+
3376
+ visibility_config {
3377
+ cloudwatch_metrics_enabled = false
3378
+ metric_name = "friendly-rule-metric-name"
3379
+ sampled_requests_enabled = false
3380
+ }
3381
+ }
3382
+
3383
+ visibility_config {
3384
+ cloudwatch_metrics_enabled = false
3385
+ metric_name = "friendly-metric-name"
3386
+ sampled_requests_enabled = false
3387
+ }
3388
+ }
3389
+ ` , rName )
3390
+ }
3391
+
3297
3392
func testAccRuleGroupConfig_byteMatchStatementFieldToMatchHeadersMatchPatternAll (rName string ) string {
3298
3393
return fmt .Sprintf (`
3299
3394
resource "aws_wafv2_rule_group" "test" {
0 commit comments