I am in the process of making it so that my team uses Terraform to carry out Auth0 changes instead of doing so in the browser. I made modules for email templates and custom_text_prompts and successfully tested, meaning I can now edit these resources through vs code and terraform apply and the changes show up in the dashboard. However,my module for custom actions has not been so successful: I tried to do a terraform apply for various custom actions and get ‘│ Error: 409 Conflict: That action name has already been taken.
│
│ with module.test_action.auth0_action.this,
│ on modules\custom_actions\main.tf line 11, in resource “auth0_action” “this”:
│ 11: resource “auth0_action” “this” {
│‘. The block in the main.tf where it is invoked is ‘module “test_action” {
source = “./modules/custom_actions”
name = “test”
code = file(“scripts/test_action.js”)
runtime = “node18”
trigger_id = “pre-user-registration”
trigger_version = “v2”
}‘, my main.tf file in the ‘custom actions’ folder is ‘terraform {
required_version = “>= 1.5.0”
required_providers {
auth0 = {
source = “auth0/auth0”
version = “>= 1.0.0”
}
}
}
resource “auth0_action” “this” {
name = var.name
code = var.code
runtime = var.runtime
deploy = var.deploy
supported_triggers {
id = var.trigger_id
version = var.trigger_version
}
Use for_each with list of objects
dynamic “dependencies” {
for_each = var.dependencies
content {
name = dependencies.value.name
version = dependencies.value.version
}
}
# Similarly for secrets
dynamic “secrets” {
for_each = var.secrets
content {
name = secrets.value.name
value = secrets.value.value
}
}
}‘ and my variables.tf file for it is ‘variable “name” {
type = string
description = “Name of the custom action”
}
variable “code” {
type = string
description = “The code of the custom action”
}
variable “runtime” {
type = string
default = “node18”
description = “Node runtime (node12, node16, node18, node22)”
}
variable “deploy” {
type = bool
default = true
}
variable “trigger_id” {
type = string
description = “ID of the trigger, e.g., ‘post-login’”
}
variable “trigger_version” {
type = string
default = “v3”
description = “Version of the trigger, e.g., ‘v3’”
}
variable “dependencies” {
description = “List of dependencies”
type = list(object({
name = string
version = string
}))
default =
}
variable “secrets” {
description = “List of secrets”
type = list(object({
name = string
value = string
}))
default =
}‘