Pra*_*any 11 google-compute-engine google-cloud-platform terraform terraform-provider-gcp
有没有其他方法可以直接使用 terraform 启用这些规则,而无需在 GCP 中创建单独的防火墙规则,然后将标签附加到计算引擎
目前我正在这样做
resource "google_compute_firewall" "allow_http" {
name = "allow-http-rule"
network = "default"
allow {
ports = ["80"]
protocol = "tcp"
}
target_tags = ["allow-http"]
priority = 1000
}
Run Code Online (Sandbox Code Playgroud)
然后使用这个标签
resource "google_compute_instance" "app" {
...
tags = ["allow-http"]
}
Run Code Online (Sandbox Code Playgroud)
小智 4
参数参考提到了选项标签。您可以按如下方式使用它:
...
tags = ["http-server","https-server"]
...
Run Code Online (Sandbox Code Playgroud)
以同样的方式,您可以使用gcloud 计算实例添加标签来编辑这些值,如下所示:
要将标签添加到现有 VM 实例,请使用以下gcloud
命令:
gcloud compute instances add-tags [YOUR_INSTANCE_NAME] --tags http-server,https-server
Run Code Online (Sandbox Code Playgroud)
要在创建实例时添加标签,请在语句中包含该标志:
gcloud compute instances create [YOUR_INSTANCE_NAME] --tags http-server,https-server
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6212 次 |
最近记录: |