Terraform - Passing type Object as a parameter to Azure Template Deployment


I am tying to to provision Azure AD Domain Service using Terraform by giving Terraform the Azure ARM template, this is because Terrafrom does not support provisioning Azure AD Domain Service natively.

I have exported the ARM Template and it's parameters, one of the parameters is called "notificationSettings" which is a type Object and looks like below :

"notificationSettings": { "value": { "notifyGlobalAdmins": "Enabled", "notifyDcAdmins": "Enabled", "additionalRecipients": [] } }

Other parameters are all strings and I can pass them without any issue, for example:

"apiVersion" = "2017-06-01"

I have tried passing this object to parameters like below :

"notificationSettings" = [{ "notifyGlobalAdmins" = "Enabled" "notifyDcAdmins" ="Enabled" "additionalRecipients" = [] }]

However, when I execute terrafrom apply, terrafrom complains and say:


Inappropriate value for attribute "parameters": element "notificationSettings": string required.


How do I pass parameters type of Object to template body?

I have also tried giving the entire ARM json parameter as a file to terrafrom by using parameters_body option like below :

parameters_body = "${file("${path.module}/temp/params.json")}"

however, I am getting the followig error when executing the terrafrom script:


The request content was invalid and could not be deserialized: 'Error converting value "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#" to type 'Microsoft.WindowsAzure.ResourceStack.Frontdoor.Data.Definitions.DeploymentParameterDefinition'. Path 'properties.parameters.$schema', line 1, position 2952.'.


Below is the params.json file:

{ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "", "parameters": { "apiVersion": { "value": "2017-06-01" }, "sku": { "value": "Standard" "location": { "value": "westus" }, "notificationSettings": { "value": { "notifyGlobalAdmins": "Enabled", "notifyDcAdmins": "Enabled", "additionalRecipients": [] } }, "subnetName": { "value": "xxxx" }, "vnetName": { "value": "xxxx" }, "vnetAddressPrefixes": { "value": [ "" ] }, "subnetAddressPrefix": { "value": "" }, "nsgName": { "value": "xxxxx" } } }

There is a way to pass arbitrary data structures from Terraform to ARM.

There are two ways to pass data to the ARM template within the azure_template_deployment provider

<ul><li>use the parameters block, which is limited to string parameters only</li> <li>use the parameters_body block, which is pretty much arbitrary JSON.</li> </ul>

I find the easiest way to use the parameters block is to create a local variable with the structure I require, then call jsonencode on it. I also like to keep the ARM template in a separate file and pull it in via a file() call, reducing the complexity of the terraform.

locals { location = "string" members = [ "array", "of", "members" ] enabled = true tags = { "key" = "value", "simple" = "store" } # this is the format required by ARM templates parameters_body = { location = { value = "${local.location}" }, properties = { value = { users = { members = "${local.members}" } boolparameter = "${local.enabled}" } } tags = { value = "${module.global.tags}" } } } resource "azurerm_template_deployment" "sample" { name = "sample" resource_group_name = "rg" deployment_mode = "Incremental" template_body = "${file("${path.module}/arm/sample_arm.json")}" parameter_body = "${jsonencode(local.parameters_body)}" }

The only caveat I've found is that the bool parameters pass as a string, so declare them as a string in the ARM parameters section, then use a ARM function to convert to bool

"parameters: { "boolParameter": { "type": "string" } }, "variables": { "boolVariable": "[bool(parameters('boolParameter'))]" }, "resources": [ ... "boolArm": "[variables('boolVariable')]", ... ]



  • Terraform - Passing type Object as a parameter to Azure Template Deployment
  • Device Orientation not getting.
  • How to get rid of Function calls are not supported in decorators in Angular aot compiling?
  • How do i get my CSV file?
  • Select unselected m2m instance in django model form
  • change(rewrite) json object's property value in JavaScript
  • conditional plot linetype in ggplot2
  • How application get update from apple store?
  • How does Android handle unsupported languages?
  • Python Django ImportError: No module named website
  • summarize data from csv using R
  • slide Wipe effects with ImageMagick tool and ffmpeg
  • How to access WPF class library from Silverlight using iron python. Is it possible?
  • PHPMailer do not work properly sometimes on gmail port 465 or 587 on localhost
  • How to pass a bitfield (by reference) to a function?
  • JavaFX resize children relative to parent
  • Any VBA code to align the picture from PowerPoint?
  • WSO2 Identity Server + Rest STS Client (without ESB)
  • Git for windows has stopped working
  • Use awk to convert GPS Position to Latitude & Longitude
  • SpringBoot don't replacen System variable {user.home} in Spring Tool Suite Version: 3.8.4.RELEA
  • How to fetch asset modification history in hyperledger fabric
  • How to get the Owner of the ContextMenu (from Silverlight 4 toolkit)?
  • Keep rows with certain values always at the bottom while sorting in jquery tablesorter plugin
  • Copy and paste data from multiple workbooks to a worksheet in another Workbook
  • 'Edit' function for forum posts and such
  • Annotate objects in a queryset with next and previous object ids
  • How to use Kaminari pagination gem with Sinatra and Mongoid?
  • JQuery: Infinite input select
  • Print Longitude and Latitude in textbox Android
  • how to run ejabberd with Erlang on Heroku?
  • How to specify generic type when the type is only known at runtime?
  • iphone image to video issue in video speed
  • How do I add a mouse over tooltip to an Image using .DrawImage()
  • Google App Engine Datastore: Dealing with eventual consistency
  • ssh remote server login script
  • XEP-0166: Jingle protocol implementation for voice/video chat in iOS
  • How to call different template for different category archive page in woocommerce