Skip to content

azurermResourceGroupTemplateDeployment

Manages a Resource Group Template Deployment.

\~> Note: This resource will automatically attempt to delete resources deployed by the ARM Template when it is deleted. This behavior can be disabled in the provider features block by setting the deleteNestedItemsDuringDeletion field to false within the templateDeployment block.

Example Usage

import * as cdktf from "cdktf";
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupTemplateDeploymentExample =
  new azurerm.resourceGroupTemplateDeployment.ResourceGroupTemplateDeployment(
    this,
    "example",
    {
      deployment_mode: "Incremental",
      name: "example-deploy",
      parameters_content:
        '${jsonencode({\n    "vnetName" = {\n      value = local.vnet_name\n    }\n  })}',
      resource_group_name: "example-group",
      template_content:
        '{\n    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",\n    "contentVersion": "1.0.0.0",\n    "parameters": {\n        "vnetName": {\n            "type": "string",\n            "metadata": {\n                "description": "Name of the VNET"\n            }\n        }\n    },\n    "variables": {},\n    "resources": [\n        {\n            "type": "Microsoft.Network/virtualNetworks",\n            "apiVersion": "2020-05-01",\n            "name": "[parameters(\'vnetName\')]",\n            "location": "[resourceGroup().location]",\n            "properties": {\n                "addressSpace": {\n                    "addressPrefixes": [\n                        "10.0.0.0/16"\n                    ]\n                }\n            }\n        }\n    ],\n    "outputs": {\n      "exampleOutput": {\n        "type": "string",\n        "value": "someoutput"\n      }\n    }\n}\n',
    }
  );
new cdktf.TerraformOutput(this, "arm_example_output", {
  value: `\${jsondecode(${azurermResourceGroupTemplateDeploymentExample.outputContent}).exampleOutput.value}`,
});
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const dataAzurermTemplateSpecVersionExample =
  new azurerm.dataAzurermTemplateSpecVersion.DataAzurermTemplateSpecVersion(
    this,
    "example",
    {
      name: "myTemplateForResourceGroup",
      resource_group_name: "myResourceGroup",
      version: "v3.4.0",
    }
  );
const azurermResourceGroupTemplateDeploymentExample =
  new azurerm.resourceGroupTemplateDeployment.ResourceGroupTemplateDeployment(
    this,
    "example_1",
    {
      deployment_mode: "Incremental",
      name: "example-deploy",
      resource_group_name: "example-group",
      template_spec_version_id: dataAzurermTemplateSpecVersionExample.id,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermResourceGroupTemplateDeploymentExample.overrideLogicalId("example");

Arguments Reference

The following arguments are supported:

  • deploymentMode - (Required) The Deployment Mode for this Resource Group Template Deployment. Possible values are complete (where resources in the Resource Group not specified in the ARM Template will be destroyed) and incremental (where resources are additive only).

\~> Note: If deploymentMode is set to complete then resources within this Resource Group which are not defined in the ARM Template will be deleted.

  • name - (Required) The name which should be used for this Resource Group Template Deployment. Changing this forces a new Resource Group Template Deployment to be created.

  • resourceGroupName - (Required) The name of the Resource Group where the Resource Group Template Deployment should exist. Changing this forces a new Resource Group Template Deployment to be created.


  • debugLevel - (Optional) The Debug Level which should be used for this Resource Group Template Deployment. Possible values are none, requestContent, responseContent and requestContent,ResponseContent.

  • templateContent - (Optional) The contents of the ARM Template which should be deployed into this Resource Group. Cannot be specified with templateSpecVersionId.

  • templateSpecVersionId - (Optional) The ID of the Template Spec Version to deploy. Cannot be specified with templateContent.

  • parametersContent - (Optional) The contents of the ARM Template parameters file - containing a JSON list of parameters.

-> An example of how to pass Terraform variables into an ARM Template can be seen in the example.

  • tags - (Optional) A mapping of tags which should be assigned to the Resource Group Template Deployment.

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

  • id - The ID of the Resource Group Template Deployment.

  • outputContent - The JSON Content of the Outputs of the ARM Template Deployment.

-> An example of how to consume ARM Template outputs in Terraform can be seen in the example.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 3 hours) Used when creating the Resource Group Template Deployment.
  • read - (Defaults to 5 minutes) Used when retrieving the Resource Group Template Deployment.
  • update - (Defaults to 3 hours) Used when updating the Resource Group Template Deployment.
  • delete - (Defaults to 3 hours) Used when deleting the Resource Group Template Deployment.

Import

Resource Group Template Deployments can be imported using the resourceId, e.g.

terraform import azurerm_resource_group_template_deployment.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Resources/deployments/template1