billowy-television-23506
12/01/2018, 10:12 PMbig-piano-35669
azure.core.TemplateDeployment
resource type. See below for an example -- I will add this to the pulumi/examples repo momentarily.
This gives you an easy incremental path to migrating existing ARM templates; the typical workflow is to start by deploying them, then teasing out a resource or two at a time, from JSON into code. A transpiler would be great, and it's something we talk about from time to time, and aspire to build up organically as we convert more stacks (the same is true of AWS CloudFormation).
HTH!import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const resourceGroup = new azure.core.ResourceGroup("rg", { location: "WestUS" });
const armDeployment = new azure.core.TemplateDeployment("arm-dep", {
resourceGroupName: resourceGroup.name,
templateBody: JSON.stringify({
"$schema": "<https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#>",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountType": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS",
"Standard_ZRS"
],
"metadata": {
"description": "Storage Account type"
}
}
},
"variables": {
"location": "[resourceGroup().location]",
"storageAccountName": "[concat(uniquestring(resourceGroup().id), 'storage')]",
"publicIPAddressName": "[concat('myPublicIp', uniquestring(resourceGroup().id))]",
"publicIPAddressType": "Dynamic",
"apiVersion": "2015-06-15",
"dnsLabelPrefix": `${pulumi.getProject()}-${pulumi.getStack()}`
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"apiVersion": "[variables('apiVersion')]",
"location": "[variables('location')]",
"properties": {
"accountType": "[parameters('storageAccountType')]"
}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "[variables('apiVersion')]",
"name": "[variables('publicIPAddressName')]",
"location": "[variables('location')]",
"properties": {
"publicIPAllocationMethod": "[variables('publicIPAddressType')]",
"dnsSettings": {
"domainNameLabel": "[variables('dnsLabelPrefix')]"
}
}
}
],
"outputs": {
"storageAccountName": {
"type": "string",
"value": "[variables('storageAccountName')]"
}
}
}),
// these key-value pairs are passed into the ARM Template's `parameters` block
parameters: {
"storageAccountType": "Standard_GRS",
},
deploymentMode: "Incremental",
});
export const storageAccountName = armDeployment.outputs.apply(outs => outs["storageAccountName"]);
billowy-television-23506
12/02/2018, 12:08 AM