Skip to content

Commit d6d38d8

Browse files
authored
fix: Updated capacity of upload rule group to support more upload paths. (TBE-137) (#24)
- fix: Set rule groups to create new groups before destroying. - fix: Use a suffix for rule groups.
1 parent 800ee6c commit d6d38d8

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ to match your desired configuration. For example, to create a new distribution
1313

1414
```hcl
1515
module "cloudfront_waf" {
16-
source = "github.com/codeforamerica/tofu-modules-aws-cloudfront-waf?ref=1.8.0"
16+
source = "github.com/codeforamerica/tofu-modules-aws-cloudfront-waf?ref=1.8.1"
1717
1818
project = "my-project"
1919
environment = "dev"
@@ -76,7 +76,7 @@ distribution at `www.my-project.org`, you could use the following:
7676
7777
```hcl
7878
module "cloudfront_waf" {
79-
source = "github.com/codeforamerica/tofu-modules-aws-cloudfront-waf?ref=1.8.0"
79+
source = "github.com/codeforamerica/tofu-modules-aws-cloudfront-waf?ref=1.8.1"
8080
8181
project = "my-project"
8282
environment = "dev"
@@ -91,7 +91,6 @@ module "cloudfront_waf" {
9191

9292
## Inputs
9393

94-
9594
| Name | Description | Type | Default | Required |
9695
|----------------------|---------------------------------------------------------------------------------------------------------------------------|----------------|---------------|----------|
9796
| domain | Primary domain for the distribution. The hosted zone for this domain should be in the same account. | `string` | n/a | yes |
@@ -126,7 +125,7 @@ Simply specify the headers you want to add in a map. For example:
126125

127126
```hcl
128127
module "cloudfront_waf" {
129-
source = "github.com/codeforamerica/tofu-modules-aws-cloudfront-waf?ref=1.8.0"
128+
source = "github.com/codeforamerica/tofu-modules-aws-cloudfront-waf?ref=1.8.1"
130129
131130
project = "my-project"
132131
environment = "dev"
@@ -162,7 +161,7 @@ resource "aws_wafv2_ip_set" "security_scanners" {
162161
}
163162
164163
module "cloudfront_waf" {
165-
source = "github.com/codeforamerica/tofu-modules-aws-cloudfront-waf?ref=1.8.0"
164+
source = "github.com/codeforamerica/tofu-modules-aws-cloudfront-waf?ref=1.8.1"
166165
167166
project = "my-project"
168167
environment = "staging"
@@ -201,7 +200,7 @@ For example, to rate limit requests to 300 over a 5-minute period:
201200

202201
```hcl
203202
module "cloudfront_waf" {
204-
source = "github.com/codeforamerica/tofu-modules-aws-cloudfront-waf?ref=1.8.0"
203+
source = "github.com/codeforamerica/tofu-modules-aws-cloudfront-waf?ref=1.8.1"
205204
206205
project = "my-project"
207206
environment = "staging"
@@ -247,7 +246,7 @@ ensure it comes after the common and SQLi rule sets.
247246
248247
```hcl
249248
module "cloudfront_waf" {
250-
source = "github.com/codeforamerica/tofu-modules-aws-cloudfront-waf?ref=1.8.0"
249+
source = "github.com/codeforamerica/tofu-modules-aws-cloudfront-waf?ref=1.8.1"
251250
252251
project = "my-project"
253252
environment = "staging"
@@ -289,7 +288,7 @@ conditions that must be met for the request to be allowed through.
289288
290289
```hcl
291290
module "cloudfront_waf" {
292-
source = "github.com/codeforamerica/tofu-modules-aws-cloudfront-waf?ref=1.8.0"
291+
source = "github.com/codeforamerica/tofu-modules-aws-cloudfront-waf?ref=1.8.1"
293292
294293
project = "my-project"
295294
environment = "staging"

uploads.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
resource "aws_wafv2_rule_group" "uploads" {
22
for_each = length(var.upload_paths) > 0 ? toset(["this"]) : toset([])
33

4-
name = "${local.prefix}-waf-allow-uploads"
5-
scope = "CLOUDFRONT"
6-
capacity = 11
4+
name_prefix = "${local.prefix}-waf-uploads-"
5+
scope = "CLOUDFRONT"
6+
capacity = 9 * length(var.upload_paths)
77

88
visibility_config {
99
cloudwatch_metrics_enabled = true
10-
metric_name = "${local.prefix}-waf-allow-uploads"
10+
metric_name = "${local.prefix}-waf-uploads"
1111
sampled_requests_enabled = true
1212
}
1313

@@ -266,4 +266,8 @@ resource "aws_wafv2_rule_group" "uploads" {
266266
sampled_requests_enabled = true
267267
}
268268
}
269+
270+
lifecycle {
271+
create_before_destroy = true
272+
}
269273
}

webhooks.tf

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
resource "aws_wafv2_rule_group" "webhooks" {
22
for_each = length(var.webhooks) > 0 ? toset(["this"]) : toset([])
33

4-
name = "${local.prefix}-webhooks"
5-
scope = "CLOUDFRONT"
6-
capacity = 50
4+
name_prefix = "${local.prefix}-webhooks"
5+
scope = "CLOUDFRONT"
6+
capacity = 50
77

88
visibility_config {
99
cloudwatch_metrics_enabled = true
@@ -208,4 +208,8 @@ resource "aws_wafv2_rule_group" "webhooks" {
208208
}
209209
}
210210
}
211+
212+
lifecycle {
213+
create_before_destroy = true
214+
}
211215
}

0 commit comments

Comments
 (0)