Actions are secure, tenant-specific, versioned functions written in Node.js that execute at certain points during the Auth0 runtime. Actions are used to customize and extend Auth0's capabilities with custom logic.
resource "auth0_action" "my_action" {
name = format("Test Action %s", timestamp())
runtime = "node18"
deploy = true
code = <<-EOT
/**
* Handler that will be called during the execution of a PostLogin flow.
*
* @param {Event} event - Details about the user and the context in which they are logging in.
* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login.
*/
exports.onExecutePostLogin = async (event, api) => {
console.log(event);
};
EOT
supported_triggers {
id = "post-login"
version = "v3"
}
dependencies {
name = "lodash"
version = "latest"
}
dependencies {
name = "request"
version = "latest"
}
secrets {
name = "FOO"
value = "Foo"
}
secrets {
name = "BAR"
value = "Bar"
}
}
code
(String) The source code of the action.name
(String) The name of the action.supported_triggers
(Block List, Min: 1, Max: 1) List of triggers that this action supports. At this time, an action can only target a single trigger at a time. Read Retrieving the set of triggers available within actions to retrieve the latest trigger versions supported. (see below for nested schema)dependencies
(Block Set) List of third party npm modules, and their versions, that this action depends on. (see below for nested schema)deploy
(Boolean) Deploying an action will create a new immutable version of the action. If the action is currently bound to a trigger, then the system will begin executing the newly deployed version of the action immediately.runtime
(String) The Node runtime. Defaults to node18
. Possible values are: node16
(not recommended), or node18
(recommended).secrets
(Block List) List of secrets that are included in an action or a version of an action. Partial management of secrets is not supported. (see below for nested schema)id
(String) The ID of this resource.version_id
(String) Version ID of the action. This value is available if deploy
is set to true.supported_triggers
Required:
id
(String) The trigger ID.version
(String) The trigger version. This regulates which runtime
versions are supported.dependencies
Required:
name
(String) Dependency name, e.g. lodash
.version
(String) Dependency version, e.g. latest
or 4.17.21
.secrets
Required:
name
(String) Secret name.value
(String, Sensitive) Secret value.Import is supported using the following syntax:
# This resource can be imported by specifying the action ID.
#
# Example:
terraform import auth0_action.my_action "12f4f21b-017a-319d-92e7-2291c1ca36c4"