forked from trussworks/terraform-aws-wafv2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for blocking ip sets and include terratests
- Loading branch information
Michael Kania
committed
Aug 20, 2020
1 parent
31c0af1
commit 439114d
Showing
16 changed files
with
889 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.PHONY: ensure_pre_commit | ||
ensure_pre_commit: .git/hooks/pre-commit ## Ensure pre-commit is installed | ||
.git/hooks/pre-commit: /usr/local/bin/pre-commit | ||
pre-commit install | ||
pre-commit install-hooks | ||
|
||
.PHONY: pre_commit_tests | ||
pre_commit_tests: ensure_pre_commit ## Run pre-commit tests | ||
pre-commit run --all-files | ||
|
||
.PHONY: test | ||
test: pre_commit_tests | ||
scripts/make-test | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f .*.stamp | ||
rm -rf bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
resource "aws_wafv2_ip_set" "ipset" { | ||
name = "ip_set_${var.test_name}1" | ||
|
||
scope = "REGIONAL" | ||
ip_address_version = "IPV4" | ||
|
||
addresses = [ | ||
"1.2.3.4/32", | ||
"5.6.7.8/32" | ||
] | ||
} | ||
|
||
resource "aws_wafv2_ip_set" "ipset2" { | ||
name = "ip_set_${var.test_name}2" | ||
|
||
scope = "REGIONAL" | ||
ip_address_version = "IPV4" | ||
|
||
addresses = [ | ||
"9.10.11.12/32", | ||
"12.14.15.16/32" | ||
] | ||
} | ||
|
||
module "wafv2" { | ||
source = "../../" | ||
name = var.test_name | ||
|
||
scope = "REGIONAL" | ||
|
||
blocked_ip_sets = [ | ||
{ | ||
name = "ip_set_${var.test_name}1" | ||
priority = 1 | ||
ip_set_arn = aws_wafv2_ip_set.ipset.arn | ||
}, | ||
{ | ||
name = "ip_set_${var.test_name}2" | ||
priority = 2 | ||
ip_set_arn = aws_wafv2_ip_set.ipset.arn | ||
} | ||
|
||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
variable "test_name" { | ||
type = string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module "wafv2" { | ||
source = "../../" | ||
name = var.test_name | ||
|
||
scope = "REGIONAL" | ||
alb_arn = aws_lb.alb.arn | ||
} | ||
|
||
resource "aws_lb" "alb" { | ||
name = var.test_name | ||
internal = false | ||
load_balancer_type = "application" | ||
subnets = module.vpc.public_subnets | ||
} | ||
|
||
module "vpc" { | ||
source = "terraform-aws-modules/vpc/aws" | ||
version = "~> 2" | ||
name = var.test_name | ||
cidr = "10.0.0.0/16" | ||
azs = var.vpc_azs | ||
public_subnets = [ | ||
"10.0.101.0/24", | ||
"10.0.102.0/24", | ||
"10.0.103.0/24" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
variable "test_name" { | ||
type = string | ||
} | ||
|
||
variable "vpc_azs" { | ||
type = list(string) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/trussworks/terraform-aws-wafv2 | ||
|
||
go 1.14 | ||
|
||
require github.com/gruntwork-io/terratest v0.28.13 |
Oops, something went wrong.