【问题标题】:How to use Google gcloud commands with terraform scripts如何在 terraform 脚本中使用 Google gcloud 命令
【发布时间】:2021-10-29 02:48:09
【问题描述】:

我正在使用 terraform 脚本创建一个 AZURE DNS 区域和 NS 记录。

resource "azurerm_resource_group" "dns_management" {
name     = "dns-managment"
location = "West US"
}

resource "azurerm_dns_zone" "mydomaincom" {
name                = "mdomain.com"
resource_group_name = "${azurerm_resource_group.dns_management.name}"
}

resource "azurerm_dns_a_record" "projectmydomain" {
name                = "project"
zone_name           = "${azurerm_dns_zone.mydomaincom.name}"
resource_group_name = "${azurerm_resource_group.dns_management.name}"
ttl                 = 300
records             = ["127.0.0.1"]
}

我想将这些 AZURE NS 记录复制到 gcp 云 DNS 托管区域。我正在尝试使用 terraform 脚本使用 Gcloud commands 来做到这一点。如何在 Terraform 中使用 Gcloud 命令?

【问题讨论】:

  • 不清楚你在问什么。你的意思是你想在你的 Terraform HCL 中执行程序 gcloud 还是你想让 gcloud 读取/处理你的 Terraform HCL?编辑您的问题,以详细说明清楚地说明您的问题。
  • 我不知道这有多大帮助,但 Google Cloud SDK (gcloud) 和两个 GCP Terraform 提供程序(google 和 google-beta)都使用了 GCP REST API (更多关于here)。
  • 如果您希望为其生成此 IaC 的 Google Cloud Platform 项目中运行至少一个 Google Kubernetes Engine 集群,您还可以查看 Config Connector here。

标签: azure terraform gcloud google-cloud-dns azure-dns


【解决方案1】:

Google 和 Hashicorp 共同为 GCP 开发 Terraform 提供程序:

https://cloud.google.com/docs/terraform

gcloud 是 Google 的 GCP CLI,但它是不同于 Terraform 提供程序的工具。

您可以直接使用 Terraform 提供程序、gcloud、SDK 或 REST API 对 Cloud DNS 进行编程。

不幸的是,我怀疑虽然使用 Terraform 应该很熟悉,但它使用的 Google 提供程序和 Cloud DNS API 将与 Azure 等效项有很大不同,您必须学习如何将脚本映射到 GCP。

【讨论】:

  • Stills 没有办法将 terraform 与 gcloud 命令一起使用
  • 我只是想将 azure dns ns 记录复制到云 dns
猜你喜欢
  • 2021-08-13
  • 1970-01-01
  • 2016-07-25
  • 2020-09-19
  • 2020-06-12
  • 1970-01-01
  • 2021-08-30
  • 1970-01-01
  • 2016-10-01
相关资源
最近更新 更多