Closed Flaaj closed 4 weeks ago
Hi, @Flaaj is the "Marketing Opt-Ins Form" created via UI, or is it created from scratch with Terraform?
@kushalshit27 We used to add this manually in the UI, but since we have multiple tenants, we want to move to terraform. The code snippet from above is my attempt at doing this.
To generate the terraform config for nodes property I exported the existing form from the UI and pasted it here. I couldn't find any documentation regarding what properties are allowed in the "nodes" field so i figured that maybe it's the same or similar to what is currently used by the UI.
I also checked if it's correct according to the example and it seems like it should work.
I can't figure out why the errors are saying that for instance I can't have "components" property in nodes[0]. It's like this in the example
Hi, @Flaaj Can you please try this ?
resource "auth0_form" "marketing_opt_ins_form" {
name = "New-Marketing Opt-Ins Form"
start = jsonencode({
coordinates = {
x = 0
y = 0
}
next_node = "step_yxSb"
})
nodes = jsonencode([{
alias = "OptIns Screen"
config = {
components = [
{
category = "BLOCK"
config = {
content = "<p>We'll send you marketing emails. Agree?</p>"
}
id = "rich_text_iieY"
type = "RICH_TEXT"
},
{
category = "FIELD"
config = {
text = "<p>Yes and continue</p>"
}
id = "legal_0ekb"
required = false
sensitive = false
type = "LEGAL"
},
{
category = "FIELD"
config = {
text = "<p>No and continue</p>"
}
id = "legal_Bcln"
required = false
sensitive = false
type = "LEGAL"
},
{
category = "BLOCK"
config = {
text = "Submit"
}
id = "next_button_MoC0"
type = "NEXT_BUTTON"
}]
next_node = "$ending"
}
coordinates = {
x = 500
y = 0
}
id = "step_yxSb"
type = "STEP"
}])
ending = jsonencode({
coordinates = {
x = 1250
y = 0
}
resume_flow = true
})
languages {
default = "en"
primary = "en"
}
}
Foms resources are complex due to their nested JSON nature. I recommend using UI first to create a form. Then, if it looks good, export it as a Terraform file; the generated Terraform is ready to be used on any tenant without using UI.
@kushalshit27 Hey, thank you very much, this worked. I don't understand though why? Can you point to a line in my code that caused an error?
Also, how can I export as terraform file? I only have option to export as json.
This issue persists for IMAGE Component, it seems to be not supported yet from terraform:
{
id= "image_YTvB"
type= "IMAGE"
config= {
src = "someURL"
width = 200
height = 76
position ="CENTER"
}
category = "BLOCK"
},
Heres the error when adding an Image component to Form:
Error: 400 Bad Request: Payload validation error: 'None of the valid schemas were met' on property nodes[0] ({description}). Inner errors: [ Payload validation error: 'Additional properties not allowed: components' on property nodes[0].config ({description}). (also) Payload validation error: 'Invalid value "STEP"' on property nodes[0].type. (also) Payload validation error: 'Additional properties not allowed: next_node,components' on property nodes[0].config ({description}). (also) Payload validation error: 'None of the valid schemas were met' on property nodes[0].config.components[0] ({description}). Inner errors: [ Payload validation error: 'None of the valid schemas were met' on property config.components[0] ({description}). Inner errors: [ Payload validation error: 'Additional properties not allowed: width,src,position,height' on property config ({description}). (also) Payload validation error: 'Invalid value "IMAGE"' on property type. (also) Payload validation error: 'Additional properties not allowed: width' on property config ({description}). ]. (also) Payload validation error: 'None of the valid schemas were met' on property config.components[0] ({description}). Inner errors: [ Payload validation error: 'Additional properties not allowed: width,src,position,height' on property config ({description}). (also) Payload validation error: 'Invalid value "IMAGE"' on property type. ]. ]. ].
Hi, @Flaaj Thanks for updating, we will check that.
Please use Terraform version 1.9.x for better support of jsonencode
[This resource can be imported using the form ID.]
main.tf
terraform {
required_providers {
auth0 = {
source = "auth0/auth0"
version = ">= 1.7.1"
}
}
}
import {
id = "ap_ojkKbiPMG6J5E5VCKdeCzK"
to = auth0_form. my_form
}
run command:
terraform plan -generate-config-out=terraform_generated.tf
terraform_generated.tf
will contain Exported auth0_form.my_form
resource.
Checklist
Description
I tried adding a form through terraform.
this is the config:
Terraform errored, giving below error message.
It seems like I can't use any property name. Is it a bug or am I doing something wrong?
Expectation
The plan should succeed.
Reproduction
Auth0 Terraform Provider version
1.7.1
Terraform version
1.2.0