How to Associating alb with AWS WAF using terraform ?

438 views
Skip to first unread message

Abereham wodajie

unread,
Mar 22, 2017, 3:45:37 PM3/22/17
to Terraform


ource "aws_alb" "app" {
......

}


#waf
resource "aws_waf_byte_match_set" "byte_set" {
name = "tf_waf_byte_match_set"

byte_match_tuples {
text_transformation = "NONE"
target_string = "${var.aapi_key}"
positional_constraint = "EXACTLY"

field_to_match {
type = "HEADER"
data = "referer"
}
}
}

resource "aws_waf_rule" "wafrule" {
depends_on = ["aws_waf_byte_match_set.byte_set"]
name = "tfWAFRule"
metric_name = "tfWAFRule"

predicates {
data_id = "${aws_waf_byte_match_set.byte_set.id}"
negated = false
type = "ByteMatch"
}
}

resource "aws_waf_web_acl" "waf_acl" {
depends_on = ["aws_waf_byte_match_set.byte_set", "aws_waf_rule.wafrule"]
name = "tfWebACL"
metric_name = "tfWebACL"

default_action {
type = "BLOCK"
}

rules {
action {
type = "ALLOW"
}

priority = 1
rule_id = "${aws_waf_rule.wafrule.id}"
}
}
Reply all
Reply to author
Forward
0 new messages