1
我创建了以下AWS WAF ACL,并且我想使用terraform将其与我的ALB相关联。有什么办法可以用terraform来完成吗? 我想阻止所有的请求,除了那些使用亚马逊Web服务Web应用程序防火墙,aws waf的秘密密钥。为此,我创建byte_set,AWS规则和访问控制列表,ACL有没有什么方法可以使用terraform将aws ELB/ALB与WAF ACL相关联?
resource "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.secret_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}"
}
}
格伦·比彻[下午10点06分] 它看起来像WAF支持是一种进展中的工作的ATM。这个拉取请求被合并; https://github.com/hashicorp/terraform/pull/13705 - 增加对区域WAF资源的支持(可以应用于ALB)。当合并Pull请求时,会在PR中产生冲突,实际上会允许Web_acl - > alb关联。 (https://github.com/hashicorp/terraform/pull/13712) –