Aquesta és una revisió antiga del document
Terraform, conditionals, state and VM
azure public ip
- public IP = external access to resources
- SND
- Estáticas/Dinámicas
- Acceso a recursos
resource "azurerm_network_interface" "web_server_nic" {
name = "${var.web_server_name}-nic"
location = "${var.web_server_location}"
resource_group_name = "${azurerm_resource_group.web_server_rg.name}"
ip_configuration {
name = "${var.web_server_name}-ip"
subnet_id = "${azurerm_subnet.web_server_subnet.id}"
private_ip_address_allocation = "dynamic"
public_ip_address_id = "${azurerm_public_ip.web_server_public_ip.id}"
}
}
resource "azurerm_public_ip" "web_server_public_ip" {
name = "${var.web_server_name}-public-ip"
location = "${var.web_server_location}"
resource_group_name = "${azurerm_resource_group.web_server_rg.name}"
public_ip_address_allocation = "dynamic"
}
conditionals
"web_server_location" = "westus2" "web_server_rg" = "web-rg" "resource_prefix" = "web-server" "web_server_address_space" = "1.0.0.0/22" "web_server_address_prefix" = "1.0.1.0/24" "web_server_name" = "web-01" "environment" = "production"
variable "environment" {}
resource "azurerm_public_ip" "web_server_public_ip" {
name = "${var.web_server_name}-public-ip"
location = "${var.web_server_location}"
resource_group_name = "${azurerm_resource_group.web_server_rg.name}"
public_ip_address_allocation = "${var.environment == "production" ? "static" : "dynamic" }"
}