terraform-provider-auth0 icon indicating copy to clipboard operation
terraform-provider-auth0 copied to clipboard

Resources are recreated constantly after migrating to >= 1.0.0 (v1.1.1 in our case)

Open alabro-bm opened this issue 1 year ago • 1 comments

Checklist

  • [X] I have looked into the README and have not found a suitable solution or answer.
  • [X] I have looked into the documentation and have not found a suitable solution or answer.
  • [X] I have searched the issues and have not found a suitable solution or answer.
  • [X] I have upgraded to the latest version of this provider and the issue still persists.
  • [X] I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • [X] I agree to the terms within the Auth0 Code of Conduct.

Description

After we updated to a version bigger than 1.0.0 we started getting issues where almost all resources would be recreated and it generates them as new resources without deleting the old ones. Looks like it cannot connect the resources that are currently present in the state and figure out that they are already created.

My latest changes involved creating a new role with a couple of permissions against the only api that we have. The result is Plan: 28 to add, 1 to change, 0 to destroy.

To be more precise it targets the auth0_actions (creates new ones), auth0_client (also creates new ones ignoring the old ones), as well as auth0_client_credentials and auth0_client_grant.

Note that we store the state in s3. We have two different states for dev environment and staging environment.

This caused a lot of issues during the migration, we had to delete one by one all the old resources and leave the newly generated ones. This requires that we update our clientIds as well so its not something that we want to constantly do.

Expectation

Resources are updated instead of creating new ones and not deleting the old ones.

Reproduction

  1. Existing repo with older version
  2. Updating to version 1 and above. Or even adding scopes and roles to an existing v1.1.1.
  3. Existing resources are ignored and recreated as new ones

Auth0 Terraform Provider version

1.1.1, 1.1.0

Terraform version

v1.6.5, v1.5.4

alabro-bm avatar Dec 12 '23 14:12 alabro-bm

We've had similar issues occur where we noticed duplicate Auth0 applications/clients were created, where these applications are managed via the Auth0 terraform provider. Unfortunately we noticed this quite a while after they were created so weren't able to identify the root cause or steps to reproduce (Auth0 doesn't show created at timestamp for applications unless the creation logs are still retained, which meant we couldn't link to specific change/deployment and check the TF plan/apply output).

These duplications happened prior to us moving to v1 of the Terraform provider and we've only noticed on applications so could be a separate issue but I figured it is worth mentioning here as it is relatively similar.

milkmansrevenge avatar Feb 01 '24 15:02 milkmansrevenge

Hi @alabro-bm,

I hope you're having a great day!

Regarding the issue at hand, it seems that the problem isn't stemming from a migration of versions but rather from Terraform's state management. I suggest taking a closer look at the Terraform state management process, as the recreation of resources isn't occurring due to any changes made.

If you have any questions or need further clarification, please don't hesitate to ask.

Thank you.

developerkunal avatar May 31 '24 13:05 developerkunal

Hi @alabro-bm ,

I hope you're having a pleasant day!

I just wanted to inform you that I'll be closing this issue shortly. However, if you have any more issues or questions, please feel free to open a new one. I'm here to assist you further.

Best regards,

developerkunal avatar Jun 03 '24 05:06 developerkunal