【问题标题】:How to set the DNS name to Azure vm using terraform如何使用 terraform 将 DNS 名称设置为 Azure vm
【发布时间】:2021-12-27 10:52:21
【问题描述】:

我可以使用 terraform 在 azure 上部署 VM,但我发现在配置 DNS 名称后未设置? 在使用 enter image description here Terraform 配置 vm 时,我不确定如何在 azure 门户上创建 DNS

我真正需要的是在 azure 上以这种格式部署 VM 时生成的主机名。服务器名称以及 france.central.azure.com enter image description here

【问题讨论】:

    标签: azure-devops terraform


    【解决方案1】:

    如果您的虚拟机有静态 IP 地址。您可以使用以下示例添加 A 记录以指向您的实例。

    resource "azurerm_resource_group" "example" {
      name     = "example-resources"
      location = "us-east-1"
    }
    
    resource "azurerm_dns_zone" "example" {
      name                = "yourdomain.com"
      resource_group_name = azurerm_resource_group.example.name
    }
    
    resource "azurerm_dns_a_record" "example" {
      name                = "your a record name"
      zone_name           = azurerm_dns_zone.example.name
      resource_group_name = azurerm_resource_group.example.name
      ttl                 = 300
      records             = ["<Insert your Instance-ip>"]
    }

    【讨论】:

    • 已通过使用资源“azurerm_public_ip”“myterraformpublicip”{ name =“myPublicIP”位置 =“francecentral”resource_group_name = azurerm_resource_group.myterraformgroup.name allocation_method =“静态”域名称标签 =“星座”标签修复{ environment = "Terraform 演示" } }
    猜你喜欢
    • 1970-01-01
    • 2019-07-12
    • 2018-05-03
    • 2021-10-14
    • 2013-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多