forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path__main__.py
79 lines (72 loc) · 2.64 KB
/
__main__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Copyright 2016-2020, Pulumi Corporation. All rights reserved.
import json
import pulumi_azure as azure
from pulumi import export, get_project, get_stack
# Create a resource group to deploy all ARM template resources into.
resource_group = azure.core.ResourceGroup('test')
# Specifies an ordinary JSON ARM template.
template = {
"$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",
"dnsLabelPrefix": f"{get_project()}-{get_stack()}",
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"apiVersion": "2019-04-01",
"location": "[variables('location')]",
"sku": {
"name": "[parameters('storageAccountType')]",
},
},
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2019-09-01",
"name": "[variables('publicIPAddressName')]",
"location": "[variables('location')]",
"properties": {
"publicIPAllocationMethod": "[variables('publicIPAddressType')]",
"dnsSettings": {
"domainNameLabel": "[variables('dnsLabelPrefix')]",
},
},
},
],
"outputs": {
"storageAccountName": {
"type": "string",
"value": "[variables('storageAccountName')]",
},
}
}
# Create an ARM template deployment using the ordinary JSON ARM template as specified above. This could be read from disk, of course.
arm_deployment = azure.core.TemplateDeployment('test-dep',
resource_group_name=resource_group.name,
template_body=json.dumps(template),
parameters={
'storageAccountType': 'Standard_GRS'
},
deployment_mode='Incremental',
)
# Finally, export the allocated storage account name.
export('storageAccountName', arm_deployment.outputs['storage_account_name'])