|
| 1 | +provider "aws" { |
| 2 | + region = "ap-northeast-2" |
| 3 | +} |
| 4 | + |
| 5 | +module "wafv2" { |
| 6 | + source = "../..//" |
| 7 | + |
| 8 | + enabled_web_acl_association = true |
| 9 | + resource_arn = [] |
| 10 | + |
| 11 | + enabled_logging_configuration = false |
| 12 | + |
| 13 | + name = "WebACL01" |
| 14 | + scope = "REGIONAL" |
| 15 | + default_action = "allow" |
| 16 | + rule = [ |
| 17 | + { |
| 18 | + name = "APIVersionRegexRule" |
| 19 | + priority = 10 |
| 20 | + action = "block" |
| 21 | + regex_match_statement = { |
| 22 | + field_to_match = { |
| 23 | + uri_path = {} |
| 24 | + } |
| 25 | + regex_string = "^/api/v[0-9]+/.*" |
| 26 | + text_transformation = [ |
| 27 | + { |
| 28 | + priority = 0 |
| 29 | + type = "LOWERCASE" |
| 30 | + } |
| 31 | + ] |
| 32 | + } |
| 33 | + visibility_config = { |
| 34 | + cloudwatch_metrics_enabled = true |
| 35 | + metric_name = "APIVersionRegexRule" |
| 36 | + sampled_requests_enabled = true |
| 37 | + } |
| 38 | + }, |
| 39 | + { |
| 40 | + name = "JWTTokenRegexRule" |
| 41 | + priority = 20 |
| 42 | + action = "allow" |
| 43 | + regex_match_statement = { |
| 44 | + field_to_match = { |
| 45 | + single_header = { |
| 46 | + name = "authorization" |
| 47 | + } |
| 48 | + } |
| 49 | + regex_string = "^Bearer [A-Za-z0-9\\-_]+\\.[A-Za-z0-9\\-_]+\\.[A-Za-z0-9\\-_]+$" |
| 50 | + text_transformation = [ |
| 51 | + { |
| 52 | + priority = 0 |
| 53 | + type = "NONE" |
| 54 | + } |
| 55 | + ] |
| 56 | + } |
| 57 | + visibility_config = { |
| 58 | + cloudwatch_metrics_enabled = true |
| 59 | + metric_name = "JWTTokenRegexRule" |
| 60 | + sampled_requests_enabled = true |
| 61 | + } |
| 62 | + }, |
| 63 | + { |
| 64 | + name = "SQLInjectionRegexRule" |
| 65 | + priority = 30 |
| 66 | + action = "block" |
| 67 | + regex_match_statement = { |
| 68 | + field_to_match = { |
| 69 | + query_string = {} |
| 70 | + } |
| 71 | + regex_string = ".*(select|union|insert|delete|drop).*" |
| 72 | + text_transformation = [ |
| 73 | + { |
| 74 | + priority = 0 |
| 75 | + type = "LOWERCASE" |
| 76 | + }, |
| 77 | + { |
| 78 | + priority = 1 |
| 79 | + type = "URL_DECODE" |
| 80 | + } |
| 81 | + ] |
| 82 | + } |
| 83 | + visibility_config = { |
| 84 | + cloudwatch_metrics_enabled = true |
| 85 | + metric_name = "SQLInjectionRegexRule" |
| 86 | + sampled_requests_enabled = true |
| 87 | + } |
| 88 | + }, |
| 89 | + { |
| 90 | + name = "EmailValidationRegexRule" |
| 91 | + priority = 40 |
| 92 | + action = "allow" |
| 93 | + regex_match_statement = { |
| 94 | + field_to_match = { |
| 95 | + single_query_argument = { |
| 96 | + name = "email" |
| 97 | + } |
| 98 | + } |
| 99 | + regex_string = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$" |
| 100 | + text_transformation = [ |
| 101 | + { |
| 102 | + priority = 0 |
| 103 | + type = "LOWERCASE" |
| 104 | + } |
| 105 | + ] |
| 106 | + } |
| 107 | + visibility_config = { |
| 108 | + cloudwatch_metrics_enabled = true |
| 109 | + metric_name = "EmailValidationRegexRule" |
| 110 | + sampled_requests_enabled = true |
| 111 | + } |
| 112 | + } |
| 113 | + ] |
| 114 | + visibility_config = { |
| 115 | + cloudwatch_metrics_enabled = false |
| 116 | + metric_name = "cloudwatch_metric_name" |
| 117 | + sampled_requests_enabled = false |
| 118 | + } |
| 119 | + tags = { |
| 120 | + Team = "Security" |
| 121 | + Owner = "Security" |
| 122 | + } |
| 123 | +} |
0 commit comments