github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/website/source/docs/providers/azurerm/r/template_deployment.html.markdown (about)

     1  ---
     2  layout: "azurerm"
     3  page_title: "Azure Resource Manager: azurerm_template_deployment"
     4  sidebar_current: "docs-azurerm-resource-template-deployment"
     5  description: |-
     6    Create a template deployment of resources.
     7  ---
     8  
     9  # azurerm\_template\_deployment
    10  
    11  Create a template deployment of resources
    12  
    13  ## Example Usage
    14  
    15  ```hcl
    16  resource "azurerm_resource_group" "test" {
    17    name     = "acctestrg-01"
    18    location = "West US"
    19  }
    20  
    21  resource "azurerm_template_deployment" "test" {
    22    name                = "acctesttemplate-01"
    23    resource_group_name = "${azurerm_resource_group.test.name}"
    24  
    25    template_body = <<DEPLOY
    26  {
    27    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    28    "contentVersion": "1.0.0.0",
    29    "parameters": {
    30      "storageAccountType": {
    31        "type": "string",
    32        "defaultValue": "Standard_LRS",
    33        "allowedValues": [
    34          "Standard_LRS",
    35          "Standard_GRS",
    36          "Standard_ZRS"
    37        ],
    38        "metadata": {
    39          "description": "Storage Account type"
    40        }
    41      }
    42    },
    43    "variables": {
    44      "location": "[resourceGroup().location]",
    45      "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'storage')]",
    46      "publicIPAddressName": "[concat('myPublicIp', uniquestring(resourceGroup().id))]",
    47      "publicIPAddressType": "Dynamic",
    48      "apiVersion": "2015-06-15",
    49      "dnsLabelPrefix": "terraform-acctest"
    50    },
    51    "resources": [
    52      {
    53        "type": "Microsoft.Storage/storageAccounts",
    54        "name": "[variables('storageAccountName')]",
    55        "apiVersion": "[variables('apiVersion')]",
    56        "location": "[variables('location')]",
    57        "properties": {
    58          "accountType": "[parameters('storageAccountType')]"
    59        }
    60      },
    61      {
    62        "type": "Microsoft.Network/publicIPAddresses",
    63        "apiVersion": "[variables('apiVersion')]",
    64        "name": "[variables('publicIPAddressName')]",
    65        "location": "[variables('location')]",
    66        "properties": {
    67          "publicIPAllocationMethod": "[variables('publicIPAddressType')]",
    68          "dnsSettings": {
    69            "domainNameLabel": "[variables('dnsLabelPrefix')]"
    70          }
    71        }
    72      }
    73    ],
    74    "outputs": {
    75      "storageAccountName": {
    76        "type": "string",
    77        "value": "[variables('storageAccountName')]"
    78      }
    79    }
    80  }
    81  DEPLOY
    82  
    83    deployment_mode = "Incremental"
    84  }
    85  
    86  output "storageAccountName" {
    87    value = "${azurerm_template_deployment.test.outputs["storageAccountName"]}"
    88  }
    89  ```
    90  
    91  ## Argument Reference
    92  
    93  The following arguments are supported:
    94  
    95  * `name` - (Required) Specifies the name of the template deployment. Changing this forces a
    96      new resource to be created.
    97  * `resource_group_name` - (Required) The name of the resource group in which to
    98      create the template deployment.
    99  * `deployment_mode` - (Required) Specifies the mode that is used to deploy resources. This value could be either `Incremental` or `Complete`.
   100      Note that you will almost *always* want this to be set to `Incremental` otherwise the deployment will destroy all infrastructure not
   101      specified within the template, and Terraform will not be aware of this.
   102  * `template_body` - (Optional) Specifies the JSON definition for the template.
   103  * `parameters` - (Optional) Specifies the name and value pairs that define the deployment parameters for the template.
   104  
   105  ## Attributes Reference
   106  
   107  The following attributes are exported:
   108  
   109  * `id` - The Template Deployment ID.
   110  
   111  * `outputs` - A map of supported scalar output types returned from the deployment (currently, Azure Template Deployment outputs of type String, Int and Bool are supported, and are converted to strings - others will be ignored) and can be accessed using `.outputs["name"]`.
   112  
   113  ## Note
   114  
   115  Terraform does not know about the individual resources created by Azure using a deployment template and therefore cannot delete these resources during a destroy. Destroying a template deployment removes the associated deployment operations, but will not delete the Azure resources created by the deployment. In order to delete these resources, the containing resource group must also be destroyed. [More information](https://docs.microsoft.com/en-us/rest/api/resources/deployments#Deployments_Delete).