Safe Removal of Null Values from an Auth0 Terraform Export File

Overview

Resources containing parameters with null values, empty arrays, or empty strings cause the generated Auth0 Terraform export file to become excessively long. This is because the auth0-cli export command relies on: terraform plan -generate-config-out=auth0_generated.tf, which is a Terraform Core feature that does not omit optional attributes that are unset in the API. Post-process the generated file and remove unused attributes.

Applies To

  • Terraform
  • Auth0
  • auth0-cli

Cause

The auth0-cli tool relies on the terraform plan -generate-config-out=auth0_generated.tf command to export a tenant. This Terraform Core feature does not omit optional attributes that lack settings in the API. Instead, the feature emits the attributes explicitly as null, empty strings, or empty lists based on the provider schema. The newer Terraform Plugin Framework cannot fully control this behavior from the provider side. Terraform treats null, "", and [] as distinct values, preventing providers from safely collapsing or omitting them unless the API semantics are identical. HashiCorp intends the generated configuration to serve as a starting point rather than production-ready code and recommends manually simplifying the file.

Solution

What steps safely remove null values from an Auth0 Terraform export file?

 

Post-process the generated file to remove unused attributes by executing a stream editor command that strips out lines that explicitly set attributes to null, and then run a Terraform plan to verify the configuration.

  1. Run the following command on generated files to strip out lines where the configuration explicitly sets attributes to null:
sed -i '' -E '/^[[:space:]]+[a-z_]+[[:space:]]*=[[:space:]]*null$/d' auth0_generated.tf
  1. Run terraform plan to confirm the configuration contains no unintended differences.

Recommended content

No recommended content found...