I am using below code to deploy Azure API mangement via terraform. It seems all resources gets deployed however only the API management resource i cant see it getting created and the terraform code keeps on running.
provider “azurerm” {
features {
}
}
resource “azurerm_resource_group” “windows-function-rg” {
name = var.resource_group_name
location = “west europe”
tags = {
“Environment” = “Dev”
“CostResponsible” = “IT”
“projectName” = “crm-cost-estimate”
“aks-managed-cluster-name” = “unknown”
}
}
resource “azurerm_virtual_network” “demo-vnet” {
name = “vnet-apigw-002”
address_space = [“xxxxxx”]
resource_group_name = azurerm_resource_group.windows-function-rg.name
location = azurerm_resource_group.windows-function-rg.location
}
resource “azurerm_subnet” “api-subnet” {
address_prefixes = [“yyyyy”]
name = “snet-apigw-002”
resource_group_name = azurerm_resource_group.windows-function-rg.name
virtual_network_name = azurerm_virtual_network.demo-vnet.name
}
resource “azurerm_subnet” “fa-subnet” {
address_prefixes = [“zzzzz”]
name = “azdlgleuw-fa-fasub-002”
resource_group_name = azurerm_resource_group.windows-function-rg.name
virtual_network_name = azurerm_virtual_network.demo-vnet.name
delegation {
name = “delegation”
service_delegation {
name = “Microsoft.Web/serverFarms”
actions = [“Microsoft.Network/virtualNetworks/subnets/join/action”]
}
}
}
resource “azurerm_subnet” “pe-subnet” {
address_prefixes = [“aaaaaaaaa”]
name = “pep-privateepsub”
resource_group_name = azurerm_resource_group.windows-function-rg.name
virtual_network_name = azurerm_virtual_network.demo-vnet.name
}
resource “azurerm_network_security_group” “apim-nsg” {
name = “nsg-apisubnsg”
location = azurerm_resource_group.windows-function-rg.location
resource_group_name = azurerm_resource_group.windows-function-rg.name
security_rule {
name = “apim-in”
priority = 100
direction = “Inbound”
access = “Allow”
protocol = “Tcp”
source_port_range = “*”
destination_port_range = “3443”
source_address_prefix = “ApiManagement”
destination_address_prefix = “VirtualNetwork”
}
}
resource “azurerm_subnet_network_security_group_association” “apim-subnet-nsg” {
subnet_id = azurerm_subnet.api-subnet.id
network_security_group_id = azurerm_network_security_group.apim-nsg.id
}
resource “azurerm_public_ip” “pubpip” {
allocation_method = “Static”
location = azurerm_resource_group.windows-function-rg.location
name = “pip-publicip”
resource_group_name = azurerm_resource_group.windows-function-rg.name
sku = “Standard”
domain_name_label = “apim-func”
}
resource “azurerm_private_dns_zone” “apidns” {
name = “privatelink.azurewebsites.net”
resource_group_name = azurerm_resource_group.windows-function-rg.name
}
resource “azurerm_private_dns_zone_virtual_network_link” “example” {
name = “test”
resource_group_name = azurerm_resource_group.windows-function-rg.name
private_dns_zone_name = azurerm_private_dns_zone.apidns.name
virtual_network_id = azurerm_virtual_network.demo-vnet.id
registration_enabled = true
}
resource “azurerm_private_dns_a_record” “apiprivatedns” {
name = “gateway”
zone_name = azurerm_private_dns_zone.apidns.name
resource_group_name = azurerm_resource_group.windows-function-rg.name
ttl = 300
records = [“aaaaa”]
}
resource “azurerm_api_management” “apim” {
name = “apim-apimngname”
resource_group_name = azurerm_resource_group.windows-function-rg.name
location = azurerm_resource_group.windows-function-rg.location
publisher_name = “sharat”
publisher_email = “abc@gmail.com”
virtual_network_type = “Internal”
sku_name = “Developer_1”
virtual_network_configuration {
subnet_id = azurerm_subnet.api-subnet.id
}
depends_on = [azurerm_subnet_network_security_group_association.apim-subnet-nsg]
public_ip_address_id = azurerm_public_ip.pubpip.id
}
resource “azurerm_api_management_api” “sharatapimgmntapi” {
name = “sharattes-import-api-002”
resource_group_name = azurerm_resource_group.windows-function-rg.name
api_management_name = azurerm_api_management.apim.name
revision = “1”
display_name = “sharat-latestAPI”
path = “extranet/v1”
protocols = [“https”]
import {
content_format = “openapi”
content_value = file(“${path.module}/ExtranetAPIopenapi.yaml”)
}
}
resource “azurerm_api_management_api_policy” “example” {
api_name = azurerm_api_management_api.sharatapimgmntapi.name
api_management_name = azurerm_api_management.apim.name
resource_group_name = azurerm_resource_group.windows-function-rg.name
xml_content = <<XML
XML
}