Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

From property in auth0_email_template resource is required, but it should allow empty string. #406

Closed
leonfs opened this issue Jun 14, 2021 · 2 comments

Comments

@leonfs
Copy link

leonfs commented Jun 14, 2021

Description

At the moment, the auth0_email_template resource enforces the from property as required, which is the expected behaviour, but this field should allow an empty string, as this is the only configuration value possible when not using custom email providers.

See: https://github.com/alexkappa/terraform-provider-auth0/blob/master/auth0/resource_auth0_email_template.go#L48

Terraform Version

Terraform 0.15.3
+ provider.auth0 0.21.0

Affected Resource(s)

  • auth0_email_template

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a [Github Gist](https://gist.github.com/) instead.

Expected Behavior

For an email template using Auth0 email provider to be created when the from property is an empty string.

Actual Behavior

Failure to create resource because when the from property is not set, the API validates it is missing. But when it is set, and the Auth0 email provider is used (instead of a custom one), the API doesn't allow for this field to have a custom value.

@leonfs leonfs changed the title From property from the EmailTemplate resource is required, but it should allow empty string. From property in EmailTemplate resource is required, but it should allow empty string. Jun 14, 2021
@leonfs leonfs changed the title From property in EmailTemplate resource is required, but it should allow empty string. From property in auth0_email_template resource is required, but it should allow empty string. Jun 14, 2021
@fearnyritchiebros
Copy link

This actually isn't a problem with the Terraform Provider; the problem actually stems from one of it's dependencies.

Under the hood, this Provider uses the Auth0 Go SDK to make calls to the Auth0 Management API.

It turns out that the EmailTemplate Struct makes use of the omitempty tag. This means that any fields that are empty will be omitted from the request that is sent to the Management API.

I noticed the Management API returns this error only for POST and PUT requests, but not for PATCH requests.

The Auth0 Go SDK uses PATCH requests to update the templates; this means that until a PR is released to fix this problem, you can work around this problem by either creating the email templates outside of Terraform and them importing them into Terraform, or you can create them with a non-empty string using Terraform, them modify the configuration and immediately run Terraform again.

The second run should update the templates using a PATCH request, and thus not throw an error.

I'll eventually make a PR to fix this problem if I can find the time and someone else doesn't beat me to it.

@sergiught
Copy link
Collaborator

This relates to several other issues that are present within the provider and I have captured this along with the others within auth0/terraform-provider-auth0#14.

As this repo has moved over at https://github.com/auth0/terraform-provider-auth0 please open new issues over there from now on.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants