If you're building Auth0 Applications for teams to use in their CI processes, you're likely granting most permissions (Scopes) against the Auth0 Management API, and removing some of them that you deem too dangerous.
The problem is, those Scopes keep changing as Auth0 adds new cool stuff, and keeping all of them up to date with new Scopes is a bit annoying, right?
So let's automate it. Here we use a data lookup to find all the Scopes that are possible to grant against the Auth0 Management API. We store all of them in a variable, and then use the !can(regex()) pattern to remove some of them (all the deletes).
That way, when folks need a CI, you can just reference this locals value, and you're done, forever. If new Scopes are created or removed, just run the terraform/tofu workspace again, and it'll find them, filter them, and assign them. And you can kick your feet up.
Here's the gist with code you can copy: https://gist.github.com/KyMidd/ddf51b2aa241db45532a54ebaf9ceb39
#LetsDoDevOps #Terraform #Tofu #Auth0 #Automation #DevOps