hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.32k stars 1.73k forks source link

Salesforce BigQuery Transfer | Parameter Issue #18506

Closed RomeoAva closed 2 months ago

RomeoAva commented 3 months ago

Community Note

Terraform Version & Provider Version(s)

Terraform v1.5.7 on MacOS

Affected Resource(s)

google_bigquery_data_transfer_config

Terraform Configuration

terraform {
  backend "gcs" {
    bucket = ""
    prefix = "terraform/state"
  }

  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "5.34.0"
    }
    random = {
      source = "hashicorp/random"
    }
  }
}

Debug Output

No response

Expected Behavior

Hello, I am trying to create a Salesforce Transfer for BQ using Terraform. Here is my current config to create that ressource:

resource "google_bigquery_data_transfer_config" "query_config" {
  display_name           = "import_salesforce"
  location               = "US"
  data_source_id         = "salesforce"
  destination_dataset_id = "analysis"
  params = {
    "connector.authentication.oauth.clientId"     = ""
    "connector.authentication.oauth.clientSecret" = ""
    "connector.authentication.username"           = ""
    "connector.authentication.password"           = ""
    "connector.authentication.securityToken"      = ""
    "assets"                                      = ["Project_ABC"]
  }
}

Actual Behavior

When specifying a list in the assets parameter, terraform tells me:

 Inappropriate value for attribute "params": element "assets": string required.

When I try to convert it to a String, the transfer is created but on BigQuery I get the following error:

Incorrect assets set in transfer config : string_value: "Project_ABC" , assets should be a non-empty list of strings.

I also tried to json_encode the list, but same result on BQ side:

Incorrect assets set in transfer config : string_value: "[\"Project_ABC\"]" , assets should be a non-empty list of strings.

Steps to reproduce

  1. terraform apply

Important Factoids

No response

References

No response

b/348691952

ggtisc commented 3 months ago

Confirmed issue!

According to Google Cloud documentation in the bq section describes the next format for the assets param:

params='{"assets":["Account"]

But after running a terraform apply it returns the next error:

Inappropriate value for attribute "params": element "assets": string required.

wj-chen commented 2 months ago

Wrapping just the assets list in jsonencode can get through the type validation. Can you try and see?

"assets" = jsonencode(["Project_ABC"])
RomeoAva commented 2 months ago

Wrapping just the assets list in jsonencode can get through the type validation. Can you try and see?

"assets" = jsonencode(["Project_ABC"])

Hi, like mentioned in the last point of my « Actual Behavior » section, I tried that and it doesn’t work.

wj-chen commented 2 months ago

Thanks for the clarification. I see what you meant now - the transfer config could be created through Terraform but the actual transfer would fail for that error you mentioned. We'll continue to look into it.

wj-chen commented 2 months ago

PR has been merged and should be released to the Google provider as part of v5.40.0. A working config would be:

resource "google_bigquery_data_transfer_config" "salesforce_config" {
  display_name           = "import_salesforce"
  location               = "US"
  data_source_id         = "salesforce"
  destination_dataset_id = "analysis"
  params = {
    "connector.authentication.oauth.clientId"     = ""
    "connector.authentication.oauth.clientSecret" = ""
    "connector.authentication.username"           = ""
    "connector.authentication.password"           = ""
    "connector.authentication.securityToken"      = ""
    "assets"                                      = "[\"Project_ABC\",\"Project_XYZ\"]"
  }
}
RomeoAva commented 2 months ago

PR has been merged and should be released to the Google provider as part of v5.40.0. A working config would be:

resource "google_bigquery_data_transfer_config" "salesforce_config" {
  display_name           = "import_salesforce"
  location               = "US"
  data_source_id         = "salesforce"
  destination_dataset_id = "analysis"
  params = {
    "connector.authentication.oauth.clientId"     = ""
    "connector.authentication.oauth.clientSecret" = ""
    "connector.authentication.username"           = ""
    "connector.authentication.password"           = ""
    "connector.authentication.securityToken"      = ""
    "assets"                                      = "[Project_ABC, Project_XYZ]"
  }
}

Thanks for the work and help !

github-actions[bot] commented 1 month ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.