Closed viveklak closed 3 years ago
Converting sub resources in arm templates to code requires establishing links back to the parent, e.g.:
{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "variables": { "profileName": "test-profile", "endpointName": "test-endpoint", "skuName": "Standard_Microsoft" }, "resources": [ { "name": "[variables('profileName')]", "type": "Microsoft.Cdn/profiles", "location": "northcentralus", "apiVersion": "2019-04-15", "sku": { "name": "[variables('skuName')]" }, "resources": [ { "apiVersion": "2019-04-15", "dependsOn": [ "[resourceId('Microsoft.Cdn/profiles', variables('profileName'))]" ], "location": "northcentralus", "name": "[variables('endpointName')]", "type": "endpoints", "properties": { "originHostHeader": "astorageaccount.a33.web.core.windows.net", "isHttpAllowed": true, "isHttpsAllowed": true, "queryStringCachingBehavior": "IgnoreQueryString", "contentTypesToCompress": [ "text/plain", "text/html" ], "isCompressionEnabled": true, "origins": [ { "name": "origin", "properties": { "hostName": "astorageaccount.a33.web.core.windows.net" } } ] }, "resources":[ { "apiVersion": "2019-04-15", "name": "Custom Domain", "type": "customDomains", "properties": { "hostName": "custom.domain.com" } } ] } ] } ], "outputs": { } }
should convert to
import * as azure_nextgen from "@pulumi/azure-nextgen"; import * as pulumi from "@pulumi/pulumi"; const endpointNameVar = "test-endpoint"; const profileNameVar = "test-profile"; const config = new pulumi.Config(); const resourceGroupNameParam = config.require("resourceGroupNameParam"); const skuNameVar = "Standard_Microsoft"; const profileResource = new azure_nextgen.cdn.v20190415.Profile("profileResource", { location: "northcentralus", profileName: profileNameVar, resourceGroupName: resourceGroupNameParam, sku: { name: skuNameVar, }, }); const endpointResource = new azure_nextgen.cdn.v20190415.Endpoint("endpointResource", { contentTypesToCompress: [ "text/plain", "text/html", ], endpointName: endpointNameVar, profileName: profileResource.name, // missing link back to parent isCompressionEnabled: true, isHttpAllowed: true, isHttpsAllowed: true, location: "northcentralus", originHostHeader: "astorageaccount.a33.web.core.windows.net", origins: [{ hostName: "astorageaccount.a33.web.core.windows.net", name: "origin", }], queryStringCachingBehavior: "IgnoreQueryString", resourceGroupName: resourceGroupNameParam, }); const customDomainResource = new azure_nextgen.cdn.v20190415.CustomDomain("customDomainResource", { customDomainName: `Custom Domain`, hostName: "custom.domain.com", resourceGroupName: resourceGroupNameParam, profileName: profileResource.name, // missing link back to parent endpointName: endpointResource.name, // missing link back to parent });
Note the missing link back to parent items which are currently missing in the generated code.
missing link back to parent
Converting sub resources in arm templates to code requires establishing links back to the parent, e.g.:
should convert to
Note the
missing link back to parent
items which are currently missing in the generated code.