Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs and examples #1143

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/resources/action.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Actions are secure, tenant-specific, versioned functions written in Node.js that
## Example Usage

```terraform
// Note : we are unable to delete an action bound to a trigger
// So, first try to import the auth0_trigger_action with the corresponding trigger id
// and delete the imported auth0_trigger_action's resource to delete the action.
resource "auth0_action" "my_action" {
name = format("Test Action %s", timestamp())
runtime = "node18"
Expand Down
30 changes: 28 additions & 2 deletions docs/resources/email_provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,35 @@ resource "auth0_email_provider" "ms365_email_provider" {

# This is an example on how to set up the email provider with a custom action.
# Make sure a corresponding action exists with custom-email-provider as supported triggers
resource "auth0_action" "send_custom_email" {
name = "Custom Email Provider"
runtime = "node18"
deploy = true
code = <<-EOT
/**
* Handler to be executed while sending an email notification.
*
* @param {Event} event - Details about the user and the context in which they are logging in.
* @param {CustomEmailProviderAPI} api - Methods and utilities to help change the behavior of sending a email notification.
*/
exports.onExecuteCustomEmailProvider = async (event, api) => {
// Code goes here
console.log(event);
return;
};
EOT


supported_triggers {
id = "custom-email-provider"
version = "v1"
}
}

resource "auth0_email_provider" "custom_email_provider" {
name = "custom"
enabled = true
depends_on = [auth0_action.send_custom_email] # Ensure the action is created first with `custom-email-provider` as the supported_triggers
name = "custom" # Indicates a custom implementation
enabled = true # Disable the default email provider
default_from_address = "[email protected]"
credentials {}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/trigger_action.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ resource "auth0_trigger_action" "post_login_alert_action" {
### Required

- `action_id` (String) The ID of the action to bind to the trigger.
- `trigger` (String) The ID of the trigger to bind with. Available options: `post-login`, `credentials-exchange`, `pre-user-registration`, `post-user-registration`, `post-change-password`, `send-phone-message`, `password-reset-post-challenge`.
- `trigger` (String) The ID of the trigger to bind with. Available options: `post-login`, `credentials-exchange`, `pre-user-registration`, `post-user-registration`, `post-change-password`, `send-phone-message`, `password-reset-post-challenge`, `custom-email-provider`.

### Optional

Expand Down
3 changes: 3 additions & 0 deletions examples/resources/auth0_action/resource.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Note : we are unable to delete an action bound to a trigger
// So, first try to import the auth0_trigger_action with the corresponding trigger id
// and delete the imported auth0_trigger_action's resource to delete the action.
resource "auth0_action" "my_action" {
name = format("Test Action %s", timestamp())
runtime = "node18"
Expand Down
30 changes: 28 additions & 2 deletions examples/resources/auth0_email_provider/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,35 @@ resource "auth0_email_provider" "ms365_email_provider" {

# This is an example on how to set up the email provider with a custom action.
# Make sure a corresponding action exists with custom-email-provider as supported triggers
resource "auth0_action" "send_custom_email" {
name = "Custom Email Provider"
runtime = "node18"
deploy = true
code = <<-EOT
/**
* Handler to be executed while sending an email notification.
*
* @param {Event} event - Details about the user and the context in which they are logging in.
* @param {CustomEmailProviderAPI} api - Methods and utilities to help change the behavior of sending a email notification.
*/
exports.onExecuteCustomEmailProvider = async (event, api) => {
// Code goes here
console.log(event);
return;
};
EOT


supported_triggers {
id = "custom-email-provider"
version = "v1"
}
}

resource "auth0_email_provider" "custom_email_provider" {
name = "custom"
enabled = true
depends_on = [auth0_action.send_custom_email] # Ensure the action is created first with `custom-email-provider` as the supported_triggers
name = "custom" # Indicates a custom implementation
enabled = true # Disable the default email provider
default_from_address = "[email protected]"
credentials {}
}
3 changes: 2 additions & 1 deletion internal/auth0/action/resource_trigger_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ func NewTriggerActionResource() *schema.Resource {
"post-change-password",
"send-phone-message",
"password-reset-post-challenge",
"custom-email-provider",
}, false),
Description: "The ID of the trigger to bind with. Available options: `post-login`, `credentials-exchange`, `pre-user-registration`, `post-user-registration`, `post-change-password`, `send-phone-message`, `password-reset-post-challenge`.",
Description: "The ID of the trigger to bind with. Available options: `post-login`, `credentials-exchange`, `pre-user-registration`, `post-user-registration`, `post-change-password`, `send-phone-message`, `password-reset-post-challenge`, `custom-email-provider`.",
},
"action_id": {
Type: schema.TypeString,
Expand Down
Loading