Skip to content

Commit

Permalink
Merge pull request #2 from asicsdigital/terraform12
Browse files Browse the repository at this point in the history
Upgrade Module to Terraform 0.12.9
  • Loading branch information
Falpangaea authored Oct 1, 2019
2 parents b09547a + c691242 commit c178655
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dotenv
1 change: 1 addition & 0 deletions .terraform-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.12.9
6 changes: 5 additions & 1 deletion locals.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
locals {
x_manual_auth_secret_target_string = "${coalesce(var.x_manual_auth_secret, random_id.default_x_manual_auth_secret.b64)}"
x_manual_auth_secret_target_string = coalesce(
var.x_manual_auth_secret,
random_id.default_x_manual_auth_secret.b64,
)
}

15 changes: 8 additions & 7 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ resource "aws_wafregional_byte_match_set" "byte_match" {
name = "${var.waf_name_alpha}ByteMatch"

byte_match_tuples {
"field_to_match" {
field_to_match {
type = "HEADER"
data = "x-manual-auth"
}

positional_constraint = "EXACTLY"
text_transformation = "NONE"
target_string = "${local.x_manual_auth_secret_target_string}"
target_string = local.x_manual_auth_secret_target_string
}
}

Expand All @@ -23,14 +23,14 @@ resource "aws_wafregional_rule" "auth_rule" {
name = "${var.waf_name_alpha}Rule"

predicate {
data_id = "${aws_wafregional_byte_match_set.byte_match.id}"
data_id = aws_wafregional_byte_match_set.byte_match.id
negated = false
type = "ByteMatch"
}
}

resource "aws_wafregional_web_acl" "auth_acl" {
"default_action" {
default_action {
type = "BLOCK"
}

Expand All @@ -43,11 +43,12 @@ resource "aws_wafregional_web_acl" "auth_acl" {
}

priority = 1
rule_id = "${aws_wafregional_rule.auth_rule.id}"
rule_id = aws_wafregional_rule.auth_rule.id
}
}

resource "aws_wafregional_web_acl_association" "alb_association" {
resource_arn = "${var.alb_arn}"
web_acl_id = "${aws_wafregional_web_acl.auth_acl.id}"
resource_arn = var.alb_arn
web_acl_id = aws_wafregional_web_acl.auth_acl.id
}

3 changes: 2 additions & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# provide the secret, needed if it was randomly generated

output "x_manual_auth_target_string" {
value = "${local.x_manual_auth_secret_target_string}"
value = local.x_manual_auth_secret_target_string
description = "Secret that this WAF will check for in x-manual-auth header"
sensitive = true
}

output "test_authentication_curl_command" {
value = "curl -H \"x-manual-auth: ${local.x_manual_auth_secret_target_string}\" https://<your application hostname here>"
}

1 change: 1 addition & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ variable "x_manual_auth_secret" {
variable "waf_name_alpha" {
description = "Name for WAF resources. Note this needs to be alphanumeric only."
}

0 comments on commit c178655

Please sign in to comment.