本文說明如何使用 Terraform 在 Azure 中建立 Windows VM 叢集 (包含三個 Windows VM 執行個體)。使用random_pet 為Azure 資源群組名稱建立隨機值。 使用azurerm_resource_group 建立Azure 資源群組。 使用random_string 建立Windows VM 主機名稱的隨機值。 使用random_password 建立Windows VM 的隨機密碼。 使用計算...
variable"resource_group_location"{type=stringdefault="eastus"description="Location of the resource group."}variable"resource_group_name_prefix"{type=stringdefault="rg"description="Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."} ...
output "resource_group_name" { value = azurerm_resource_group.rg.name } output "windows_vm_public_names" { value = module.windows_server[*].public_ip_dns_name } output "vm_public_ip_addresses" { value = module.windows_server[*].public_ip_address } output "vm_private_ip_addresses" ...
azurerm_subnet_name.id resource_group_name = azurerm_resource_group.rg.name virtual_network_name = azurerm_virtual_network.test.name address_prefixes = ["10.0.2.0/24"] } resource "azurerm_public_ip" "test" { name = "publicIPForLB" location = azurerm_resource_group.rg.location resource...
azurerm_resource_group.demo azurerm_subnet.demo azurerm_virtual_network.demo 创建虚拟机 进入到目录virtual-machine目录,依然是先运行命令进行初始化。 terraform init 创建虚拟机的参数就会多一些,具体参数定义可以查看variables.tf,通过terraform.tfvars文件可以设置参数值,这里需要指定使用的订阅 ID。
笔者在前文《Terraform 简介》中简单介绍了 Terraform 相关的概念,本文让我们使用 Terraform 在 Azure 上创建一个虚机,以此来直观体验一下 Terraform 强大威力。说明:本文的演示环境为 ubuntu 16.04。 provider 与 resource 在Terraform 的配置文件中,比较常见的配置类型有 provider 和 resource。
"resource_type":"azurerm_linux_virtual_machine","resource_name":"res-3"},"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Network/networkInterfaces/vm-myResourceGroup-vm-d146": {"resource_id":"/subscriptions/00000000-0000-0000-0000-0000000000...
使用Terraform在Azure KeyVault中获取值 默认情况下,我们如果使用Terraform在Azure上部署VM资源,则必须在变量文件中以明文的方式提供对应的用户名和密码信息,从安全的角度讲,这种做法存在极大的安全隐患。为了这种安全隐患,我们可以选择将用户名和密码信息存储在Azure Keyvault中。在每次部署的时候,Terraform都会以加密的...
通过azure-cli创建虚拟机 安装azure-cli 我的电脑是MacOS,安装如下: $ brew update-reset $ brew install azure-cli $ which az /usr/local/bin/az $ az version { "azure-cli": "2.44.1", "azure-cli-core": "2.44.1", "azure-cli-telemetry": "1.0.8", ...
resource "azurerm_subnet" "infra_subnet" { name = var.subnet_name_DB virtual_network_name = azurerm_virtual_network.vnet.name resource_group_name = azurerm_resource_group.rg.name address_prefix = var.subnet_prefix_DB } 1. 2. 3. ...