auth0 / terraform-provider-auth0

The Auth0 Terraform Provider is the official plugin for managing Auth0 tenant configuration through the Terraform tool.
https://registry.terraform.io/providers/auth0/auth0/latest/docs
Mozilla Public License 2.0
167 stars 86 forks source link

Predictable order for "auth0 tf generate" #1071

Closed anderaus closed 2 weeks ago

anderaus commented 2 weeks ago

Checklist

Describe the problem you'd like to have solved

It seems the output from auth0 tf generate in auth0_generated.tf is in random order (per resource type). Is there a way to get the output in predictable order? Or at least in the same order on every execution?

We are currently not applying Terraform plans, but use auth0 tf generate to created "backups" of our auth0 configuration. We're making changes directly in the Auth0 UI, but want to re-generate the Terraform plan after each manual change so we're able to diff the changes and keep track of the history in source control (until we have the proper CI in place to start using Terraform plans for all changes).

Describe the ideal solution

The content of auth0_generated.tf is created in the same order every time we execute it on the same tenant

Alternatives and current workarounds

I considered creating a tf file for every single resource type separately. If I script this and output it to separate folders, I should get an end result that can be commited to source control, repeated and diff'ed, but it's a hacky workaround. Example: auth0 tf generate -r auth0_action -o tenant1_auth0_action_tf auth0 tf generate -r auth0_client -o tenant1_auth0_client_tf ... repeat for each resource type

Additional context

No response

acwest commented 2 weeks ago

you should probably file this issue against the auth0-cli repo. As that is where the generate command is actually run. I will investigate whether it can be fixed there, much of the functionality for this is actually implemented by the terraform cli, but it may be possible to fix the ordering...