imperva / terraform-provider-incapsula

This package is a plugin for Terraform, and is designed to be used to auto-provision sites in Incapsula via Incapsula’s API from the terraform cli/yaml configurations.
Mozilla Public License 2.0
44 stars 72 forks source link

Got "Invalid site cname" while using for_each to batch deploy sites. #39

Closed wade-schee closed 3 years ago

wade-schee commented 4 years ago

I used _foreach to batch deploy sites after passing _incapsulasite a map of csvdecode processed csv file.

locals {
  site_data = csvdecode(file(var.path))
}

resource "incapsula_site" "example-site" {
  for_each = {
    for site in local.site_data :
    site.domain => site
  }
  domain                 = each.value.domain
  account_id             = var.account
  send_site_setup_emails = "false"
  site_ip                = each.value.site_ip
  force_ssl              = each.value.force_ssl

}

And got error message like:

{"res":2,"res_message":"Invalid input","debug_info":{"id-info":"13023","Invalid site cname":"foo.bar.com"}}

If the site_ip column at the csv file contained either valid or invalid cname.

However, this error won't occur by neither assigning only ip addresses to the csv file at site_ip column, nor directly assigning canme address to resource section.(like site_ip="foo.bar.com" )

anandkunal commented 4 years ago

Hi @wade-schee, were you able to get a solution for this? You may need to contact support for this one.

joeymoore commented 3 years ago

@wade-schee if you did not figure this out, I have tested successfully with the below example #localcsv locals { csv_data = <<-CSV local_id,domain,site_ip 1,tf1.dev.impervademo.com,"209.22.1.2" 2,tf2.dev.impervademo.com,"209.22.2.2" 3,tf3.dev.impervademo.com,"209.22.3.2" 4,tf4.dev.impervademo.com,"209.22.4.2" CSV

site = csvdecode(local.csv_data) } resource "incapsula_site" "example-sites" { for_each = { for site in local.site : site.local_id => site} domain = each.value.domain account_id = "0000" site_ip = each.value.site_ip }