airbytehq / terraform-provider-airbyte

Terraform Provider for Airbyte API
https://api.airbyte.com/
MIT License
42 stars 19 forks source link

source_googlesheets_resource validation switched between the types of credentials #123

Closed josedaniel-escribano-clarity closed 1 month ago

josedaniel-escribano-clarity commented 1 month ago

Not an expert in GO neither in terraform, but I am getting this error during the configuration of the source_googlesheets_resource, with a configuration like (sensitive data is masked):

resource "airbyte_source_google_sheets" "gsheets_test" {
    configuration = {
        source_id = "gsheets_source_id"
        source_type = "google-sheets"
        credentials = {
            service_account_key_authentication = {
                service_account_info = "{   \"type\": \"service_account\",   \"project_id\": \"project_id\",   \"private_key_id\": \"private_key_id\",   \"private_key\": \"-----BEGIN PRIVATE KEY-----\\private_key\\n-----END PRIVATE KEY-----\\n\",   \"client_email\": \"email@google.iam.gserviceaccount.com\",   \"client_id\": \"client_id\",   \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",   \"token_uri\": \"https://oauth2.googleapis.com/token\",   \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",   \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509email@google.iam.gserviceaccount.com\" }"
            }
        }
        spreadsheet_id = "https://docs.google.com/spreadsheets/d/spreadsheet_id",
        names_conversion = false
    }
    name = "Gsheet Name"
    workspace_id = "test"
}

I am getting the following error:

│ Error: Invalid Attribute Type
│ 
│   with airbyte_source_google_sheets.gsheets_test,
│   on main.tf line 4, in resource "airbyte_source_google_sheets" "gsheets_test":
│    4: resource "airbyte_source_google_sheets" "gsheets_test" {
│ 
│ Attribute configuration.credentials value must have exactly one child attribute defined, got:
│ {"source_google_sheets_authentication_authenticate_via_google_o_auth":<null>,"source_google_sheets_authentication_service_account_key_authentication":<null>,"source_google_sheets_update_authentication_authenticate_via_google_o_auth":<null>,"source_google_sheets_update_authentication_service_account_key_authentication":<null>}

And for what I see in the source code in line 74 we define the type of authenticate_via_google_o_auth credentials and we validate in line 93 with the type of service_account_key_authentication credentials. We can see the opposite in line 97 where we define the type of service_account_key_authentication credentials and we validate in line 107 with the type of authenticate_via_google_o_auth credentials.

If I am not mistaken we are validating the credentials wrongly 😅 I'll also appreciate an example with fake data so we can see how to use the connection properly 🙂

Thanks lots!

josedaniel-escribano-clarity commented 1 month ago

Looks like i was using an old version of the provider! Sorry for the noise!