skip to content
Alvin Lucillo

Importing auth0 trigger action error

/ 2 min read

Importing existing auth0 resources into your terraform project can be quite tricky. For example, there’s a recent problem I encountered when importing post-login trigger action. To give context, actions are serverless scripts that run when a trigger happens, for example, when a user successfully logs in (i.e., post-login). In the example below, action1 was already imported, and post_login was imported.

Based on auth0_trigger_action doc from terraform, I ran this command:

terraform import "auth0_trigger_actions.post_login" "post-login::actual-action-id-here"
auth0_trigger_actions.post_login: Refreshing state... [id=post-login::actual-action-id-here]
 Error: 400 Bad Request: invalid ListActionBindingsRequest.TriggerType: value must not be in list [UNSPECIFIED]

The error says the trigger type must not be in the list. That doesn’t make sense. But I noticed that the documentation references a resource I’m not using. What I actually need to reference is auth0_trigger_actions (there’s an s). Based on that doc, I should use the command below. That worked.

terraform import "auth0_trigger_actions.post_login" "post-login"
auth0_trigger_actions.post_login: Importing from ID "post-login"...
auth0_trigger_actions.post_login: Import prepared!
  Prepared auth0_trigger_actions for import
auth0_trigger_actions.post_login: Refreshing state... [id=post-login]

Import successful!

post-login is the actual ID for the auth0_trigger_actions resource post_login. Terraform imports all associations to that trigger type by doing that.

Terraform files:

// already imported
resource "auth0_action" "action1" {
  code    = "some code here..."
  deploy  = true
  name    = "action1"
  supported_triggers {
    id      = "post-login"
    version = "v3"
  }
}

// to be imported
resource "auth0_trigger_actions" "post_login" {
  trigger = "post-login"
  actions {
    display_name = "postlogin"
    id           = auth0_action.action1.id
  }
}