Auth0 Terraform Provider (v1.0.0) 404 Error When Using the Resource "auth0_role_permissions"

Problem statement

When using Terraform commands such as ‘apply’, ‘refresh’, and ‘destroy’ in relation to Auth0 config, an error is thrown related to API permissions:

Error:404 Not Found: This permission does not exist:'https://my_api.com/ - sample:scope'

What’s the reason behind this error and how can it be resolved?

Cause

The Terraform provider can throw a 404 if certain resources have been manually removed/updated which causes the Terraform config to drift from the actual configured state of the Auth0 tenant. In this instance a permission had been deleted from an API in the Auth0 dashboard prior to running a Terraform command.

Solution

If using the Terraform Provider it is highly recommended to only use that tool to perform any updates to a given Auth0 tenant. Mixing Terraform and making manual changes to an Auth0 tenant can cause state drifts where the actual setup of the Auth0 tenant is no longer accurately reflected by the Terraform provider causing errors to be returned.

The solution to this 404 was to re-add the missing permission mentioned by the Terraform error description to the API in question. Once that had been re-added, Terraform was able to execute its commands as expected.