【发布时间】:2021-06-18 22:45:09
【问题描述】:
我正在尝试将谷歌云装甲添加到我的 Terraform 项目中,该项目使用 Kubernetes 部署应用程序。我按照这个例子。但是,就我而言,我想创建以下规则: https://github.com/hashicorp/terraform-provider-google/blob/master/examples/cloud-armor/main.tf
关闭所有端口上所有 IP 的所有流量,但打开端口 80 和 443 上所有 IP 的流量
- 然后我在
terraform/kubernetes目录下添加了一个也叫web_application_firewall.tf的文件,配置如下:
# Cloud Armor Security policies
resource "google_compute_security_policy" "web-app-firewall" {
name = "armor-security-policy"
description = "Web application security policy to close all traffics for all IPs on all ports but open traffic for all IPs on port 80 and 443"
# Reject all traffics for all IPs on all ports
rule {
description = "Default rule, higher priority overrides it"
action = "deny(403)"
priority = "2147483647"
match {
versioned_expr = "SRC_IPS_V1"
config {
src_ip_ranges = ["*"]
}
}
}
# Open traffic for all IPs on port 80 and 443
#rule {
# description = "allow traffic for all IPs on port 80 and 443"
# action = "allow"
# priority = "1000"
# match {
# versioned_expr = "SRC_IPS_V1"
# config {
# src_ip_ranges = ["*"]
# }
# }
#}
}
resource "google_compute_firewall" "firewall-allow-ports" {
name = "firewall-allow-ports"
network = google_compute_network.default.name
allow {
protocol = "icmp"
}
allow {
protocol = "tcp"
ports = ["80"]
}
source_tags = ["web"]
}
resource "google_compute_network" "default" {
name = "test-network"
}
在这里,我停用了端口 445,但重新部署后,我仍然可以访问网络应用程序。你能告诉我我在这里做错了什么吗?提前谢谢你。
【问题讨论】:
-
你解决过这个问题吗?我真的来这里发布一个类似的问题。
-
@shuti 你在测试前等了几分钟吗?你用的是哪个地形?在您的 terraform 清单中,您还评论了
allow traffic部分?
标签: kubernetes google-cloud-platform terraform google-kubernetes-engine google-cloud-armor