signalsciences / terraform-provider-sigsci

Signal sciences terraform provider
MIT License
26 stars 30 forks source link

Error: invalid character '<' looking for beginning of value #202

Closed jbartus closed 9 months ago

jbartus commented 10 months ago

sometimes when running this tf code

resource "sigsci_site" "demo_site" {
  display_name = "demosite"
  short_name   = "demosite"
  agent_level  = "block"
}

resource "sigsci_edge_deployment" "ngwaf_edge_demo" {
  site_short_name = sigsci_site.demo_site.short_name
}

I get the following error:

│ Error: invalid character '<' looking for beginning of value
│ 
│   with sigsci_edge_deployment.ngwaf_edge_demo,
│   on ngwaf.tf line 12, in resource "sigsci_edge_deployment" "ngwaf_edge_demo":
│   12: resource "sigsci_edge_deployment" "ngwaf_edge_demo" {
│ 
╵

here's my terraform and provider versions

jbartus@XFHFH62963 fsly-demo % tf version
Terraform v1.6.2
on darwin_arm64
+ provider registry.terraform.io/fastly/fastly v5.6.0
+ provider registry.terraform.io/hashicorp/google v5.3.0
+ provider registry.terraform.io/signalsciences/sigsci v2.1.3

if I simply wait a minute or two the problem goes away, I can re-run terraform apply and it will complete the setup.

the problem reproduces even with -parallelism=1

rickardkarlsson commented 10 months ago

I also experience the same problem. It's quite frustrating to create new sites. When it mostly don't work. Is there any solution to fix this?

DanInProgress commented 10 months ago

Also just got bit by this and a script was in use that ensures that TF_CLI_ARGS_apply=" -parallelism=1" is always set.

For others running into this issue:

if terraform plan is now showing:

-/+ destroy and then create replacement

Terraform will perform the following actions:

  # module.public_website.sigsci_edge_deployment.ngwaf_edge_site_service is tainted, so must be replaced
-/+ resource "sigsci_edge_deployment" "ngwaf_edge_site_service" {
      ~ id              = "<site-short-name>" -> (known after apply)
        # (1 unchanged attribute hidden)
    }

double check the signal sciences dashboard

if it already exists, skip this issue the second time around by using terraform import like this:

SITE_SHORT_NAME="<site-short-name>" # e.g. `public-website`
TF_RESOURCE_ADDR="<address>" # e.g. `module.public_website.sigsci_edge_deployment.ngwaf_edge_site_service`
terraform state rm -backup <please-make-a-backup.tfstate> "$TF_RESOURCE_ADDR"
terraform import "$TF_RESOURCE_ADDR" "$SITE_SHORT_NAME"

looks like terraform import isn't documented for sigsci_edge_deployment, so I opened #203 to review all docs for similar issues

jbartus commented 9 months ago

done like 15 - 20 builds the last two days and haven't seen the error again

lra commented 5 months ago

We are getting this error randomly using Terraform v1.7.5 on darwin_arm64 and signalsciences/sigsci v2.1.7. Mayb the API is randomly failing? It could be returning something that's not a json when erroring out, leading to this message. e.g. https://austindewey.com/2020/12/11/troubleshooting-invalid-character-looking-for-beginning-of-value/