From 56bbdb958c67a6f8c9a66f0850793398d4355329 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Tue, 18 Feb 2025 14:45:38 +0800 Subject: [PATCH 1/2] Add example for Microsoft.Network/privateEndpoints@2022-01-01 --- .../main.tf | 209 ++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 examples/Microsoft.Network_privateEndpoints@2022-01-01/main.tf diff --git a/examples/Microsoft.Network_privateEndpoints@2022-01-01/main.tf b/examples/Microsoft.Network_privateEndpoints@2022-01-01/main.tf new file mode 100644 index 00000000..dd75eceb --- /dev/null +++ b/examples/Microsoft.Network_privateEndpoints@2022-01-01/main.tf @@ -0,0 +1,209 @@ +terraform { + required_providers { + azapi = { + source = "Azure/azapi" + } + azurerm = { + source = "hashicorp/azurerm" + } + } +} + +provider "azurerm" { + features { + } +} + +provider "azapi" { + skip_provider_registration = false +} + +variable "resource_name" { + type = string + default = "acctest0001" +} + +variable "location" { + type = string + default = "westeurope" +} + +data "azurerm_client_config" "current" { +} + +data "azapi_resource" "subscription" { + type = "Microsoft.Resources/subscriptions@2021-01-01" + resource_id = "/subscriptions/${data.azurerm_client_config.current.subscription_id}" + response_export_values = ["*"] +} + +resource "azapi_resource" "resourceGroup" { + type = "Microsoft.Resources/resourceGroups@2020-06-01" + name = var.resource_name + location = var.location +} + +resource "azapi_resource" "virtualNetwork" { + type = "Microsoft.Network/virtualNetworks@2022-07-01" + parent_id = azapi_resource.resourceGroup.id + name = var.resource_name + location = var.location + body = { + properties = { + addressSpace = { + addressPrefixes = [ + "10.5.0.0/16", + ] + } + dhcpOptions = { + dnsServers = [ + ] + } + subnets = [ + ] + } + } + schema_validation_enabled = false + response_export_values = ["*"] + lifecycle { + ignore_changes = [body.properties.subnets] + } +} + +resource "azapi_resource" "publicIPAddress" { + type = "Microsoft.Network/publicIPAddresses@2022-07-01" + parent_id = azapi_resource.resourceGroup.id + name = var.resource_name + location = var.location + body = { + properties = { + ddosSettings = { + protectionMode = "VirtualNetworkInherited" + } + idleTimeoutInMinutes = 4 + publicIPAddressVersion = "IPv4" + publicIPAllocationMethod = "Static" + } + sku = { + name = "Standard" + tier = "Regional" + } + } + schema_validation_enabled = false + response_export_values = ["*"] +} + +resource "azapi_resource" "loadBalancer" { + type = "Microsoft.Network/loadBalancers@2022-07-01" + parent_id = azapi_resource.resourceGroup.id + name = var.resource_name + location = var.location + body = { + properties = { + frontendIPConfigurations = [ + { + name = var.resource_name + properties = { + publicIPAddress = { + id = azapi_resource.publicIPAddress.id + } + } + }, + ] + } + sku = { + name = "Standard" + tier = "Regional" + } + } + schema_validation_enabled = false + response_export_values = ["*"] +} + +resource "azapi_resource" "subnet" { + type = "Microsoft.Network/virtualNetworks/subnets@2022-07-01" + parent_id = azapi_resource.virtualNetwork.id + name = var.resource_name + body = { + properties = { + addressPrefix = "10.5.4.0/24" + delegations = [ + ] + privateEndpointNetworkPolicies = "Enabled" + privateLinkServiceNetworkPolicies = "Disabled" + serviceEndpointPolicies = [ + ] + serviceEndpoints = [ + ] + } + } + schema_validation_enabled = false + response_export_values = ["*"] +} + +resource "azapi_resource" "privateLinkService" { + type = "Microsoft.Network/privateLinkServices@2022-07-01" + parent_id = azapi_resource.resourceGroup.id + name = var.resource_name + location = var.location + body = { + properties = { + autoApproval = { + subscriptions = [ + ] + } + enableProxyProtocol = false + fqdns = [ + ] + ipConfigurations = [ + { + name = "primaryIpConfiguration-230630033653892379" + properties = { + primary = true + privateIPAddress = "" + privateIPAddressVersion = "IPv4" + privateIPAllocationMethod = "Dynamic" + subnet = { + id = azapi_resource.subnet.id + } + } + }, + ] + loadBalancerFrontendIpConfigurations = [ + { + id = azapi_resource.loadBalancer.output.properties.frontendIPConfigurations[0].id + }, + ] + visibility = { + subscriptions = [ + ] + } + } + } + schema_validation_enabled = false + response_export_values = ["*"] +} + +resource "azapi_resource" "privateEndpoint" { + type = "Microsoft.Network/privateEndpoints@2022-07-01" + parent_id = azapi_resource.resourceGroup.id + name = var.resource_name + location = var.location + body = { + properties = { + privateLinkServiceConnections = [ + { + name = azapi_resource.privateLinkService.name + properties = { + privateLinkServiceId = azapi_resource.privateLinkService.id + } + } + ] + subnet = { + id = azapi_resource.subnet.id + } + } + } + schema_validation_enabled = false + response_export_values = ["*"] +} From a6455bc56807f8525de6495d4fd6fc315c3d6642 Mon Sep 17 00:00:00 2001 From: Heng Lu <79895375+ms-henglu@users.noreply.github.com> Date: Thu, 20 Feb 2025 14:42:15 +0800 Subject: [PATCH 2/2] Remove azurerm provider and related data sources --- .../main.tf | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/examples/Microsoft.Network_privateEndpoints@2022-01-01/main.tf b/examples/Microsoft.Network_privateEndpoints@2022-01-01/main.tf index dd75eceb..f958468d 100644 --- a/examples/Microsoft.Network_privateEndpoints@2022-01-01/main.tf +++ b/examples/Microsoft.Network_privateEndpoints@2022-01-01/main.tf @@ -3,14 +3,6 @@ terraform { azapi = { source = "Azure/azapi" } - azurerm = { - source = "hashicorp/azurerm" - } - } -} - -provider "azurerm" { - features { } } @@ -28,15 +20,6 @@ variable "location" { default = "westeurope" } -data "azurerm_client_config" "current" { -} - -data "azapi_resource" "subscription" { - type = "Microsoft.Resources/subscriptions@2021-01-01" - resource_id = "/subscriptions/${data.azurerm_client_config.current.subscription_id}" - response_export_values = ["*"] -} - resource "azapi_resource" "resourceGroup" { type = "Microsoft.Resources/resourceGroups@2020-06-01" name = var.resource_name