Pass terraform variable into json

Hi HCP fellas,
I have a case where I need to create packer image following this link
I want to perform all the steps with Terraform but I need to pass terraform variable into json file for the packer image.

In my case below doesn’t pass the variable into the json and I don’t know what I’m missing

data “azuread_client_config” “current” {}

resource “azuread_application” “packer” {
display_name = “test-packer-spn”
owners = [data.azuread_client_config.current.object_id]

resource “azuread_service_principal” “example” {
application_id = azuread_application.packer.application_id
app_role_assignment_required = false
owners = [data.azuread_client_config.current.object_id]
resource “azuread_service_principal_password” “example” {
service_principal_id = azuread_service_principal.example.object_id

resource “azurerm_resource_group” “example” {
name = “myPackerImages”
location = “eastus”

locals {
data = jsondecode(file(“./ubuntu.json”))
client_id = “azuread_application.packer.application_id”
client_secret = “azuread_service_principal_password.example.value”
tenant_id = “var.tenant_id”
subscription_id = “var.subscription_id”

resource “null_resource” “provisioner” {
provisioner “local-exec” {
command = “packer.exe build ${}”

Hey fella :slight_smile:,
you could use templatefile function (see an example here).