fivetran / terraform-provider-fivetran

Terraform Provider for Fivetran
https://fivetran.com
Apache License 2.0
40 stars 23 forks source link

Provider produced inconsistent result after apply - config block #294

Closed barabasakos closed 3 months ago

barabasakos commented 5 months ago

Describe the bug google_play (Google Playstore) and itunes_connect (Apple store) config block makes the terraform recreate the Fivetran connector and destination. Not just that, but it requires a manual intervention upon recreation, I have to verify it manually as the Connector state will be paused/incomplete and the Destination broken.

To Reproduce Define integration_key and/or bucket under the config block of the "fivetran_connector" resource in terraform

resource "fivetran_connector" "connector" {
  group_id = fivetran_destination.dest.group_id
  service  = var.fivetran_connector_type
  destination_schema {
    name = var.project_name
  }
  config {
    integration_key = var.integration_key
    bucket          = var.bucket_key
  }
}

Expected behavior Only change the fivetran resources if there is an actual change in the terraform and not on every single run even if nothing has changed.

Logs & Output

 Error: Provider produced inconsistent result after apply
│
│ When applying changes to module.fivetran.fivetran_connector.connector, provider
│ "module.fivetran.provider[\"registry.terraform.io/fivetran/fivetran\"]"
│ produced an unexpected new value: .config.integration_key: inconsistent values
│ for sensitive attribute.
│
│ This is a bug in the provider, which should be reported in the provider's own
│ issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to module.fivetran.fivetran_connector.connector, provider
│ "module.fivetran.provider[\"registry.terraform.io/fivetran/fivetran\"]"
│ produced an unexpected new value: .config.bucket: was cty.StringVal(""), but
│ now null.
│
│ This is a bug in the provider, which should be reported in the provider's own
│ issue tracker.

Plugin version: Terraform v1.3.6

Additional context The same error (or at least very similar) happens on other connector types as well, but Playstore being the worst(requires multiple manual steps after it recreates the resources on every run) and Appstore only requiring a manual verification step.

beevital commented 5 months ago

@barabasakos integration_key issue should be fixed in v.1.1.21 as I've added more precise handling for sensitive fields. Please test it on v1.1.21.

As for bucket - you've passed an empty string value, API considering it as an empty value and doesn't return in response. I think I could provide a common solution for such case.

beevital commented 5 months ago

Next release scheduled for tomorrow.

barabasakos commented 5 months ago

Terraform v1.3.6

Still the same issue + error with integration_key, the empty string issue was a layer 7 error.


module.fivetran.fivetran_connector.connector: Creating...
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to module.fivetran.fivetran_connector.connector, provider
│ "module.fivetran.provider[\"registry.terraform.io/fivetran/fivetran\"]"
│ produced an unexpected new value: .config.integration_key: inconsistent values
│ for sensitive attribute.
│
│ This is a bug in the provider, which should be reported in the provider's own
│ issue tracker.

edit: The resource shows up as tainted, after manually untainting it, same plan/apply output, the resource (in appstore's case) does seem to be recreated.

beevital commented 5 months ago

@barabasakos check v1.1.22, fix for this issue was included to the release.

barabasakos commented 5 months ago

@beevital , updated to v1.1.22 Playstore: The connector is being updated in-place (no manual steps are needed in the GUI anymore)

The integration_key being a sensitive value message is gone, the following is my error output:

Error: Provider produced inconsistent result after apply │ │ When applying changes to module.fivetran.fivetran_connector.connector, provider │ "module.fivetran.provider[\"registry.terraform.io/fivetran/fivetran\"]" │ produced an unexpected new value: .config.timeframe_months: was │ cty.StringVal("ALL_TIME"), but now null. │ │ This is a bug in the provider, which should be reported in the provider's own │ issue tracker.

Which comes from the config block inside the fivetran_connector: timeframe_months = "ALL_TIME"

beevital commented 5 months ago

@barabasakos I've just tested the following configuration:

resource "fivetran_connector" "connector" {
  group_id = "1k56c2c4xlti6"
  service  = "itunes_connect"
  destination_schema {
    name = "itunes_connect_vmosin_test"
  }
  config {
    timeframe_months = "ALL_TIME"
  }
}

And no issues reproduced:

Terraform used the selected providers to generate the following execution plan. Resource
actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # fivetran_connector.connector will be created
  + resource "fivetran_connector" "connector" {
      + connected_by       = (known after apply)
      + created_at         = (known after apply)
      + group_id           = "1k56c2c4xlti6"
      + id                 = (known after apply)
      + name               = (known after apply)
      + run_setup_tests    = (known after apply)
      + service            = "itunes_connect"
      + trust_certificates = (known after apply)
      + trust_fingerprints = (known after apply)

      + config {
          + abs_connection_string                               = (sensitive value)
          + abs_container_name                                  = (known after apply)
          + access_key                                          = (sensitive value)
          + access_key_id                                       = (sensitive value)
          + access_token                                        = (sensitive value)
          + account                                             = (known after apply)
          + account_id                                          = (known after apply)
          + account_key                                         = (sensitive value)
          + account_region                                      = (known after apply)
          + account_type                                        = (known after apply)
          + action_report_time                                  = (known after apply)
          + agent_config_method                                 = (known after apply)
          + agent_host                                          = (known after apply)
          + agent_ora_home                                      = (known after apply)
          + agent_password                                      = (sensitive value)
          + agent_port                                          = (known after apply)
          + agent_public_cert                                   = (known after apply)
          + agent_user                                          = (known after apply)
          + aggregation                                         = (known after apply)
          + always_encrypted                                    = (known after apply)
          + api_access_token                                    = (sensitive value)
          + api_environment                                     = (known after apply)
          + api_key                                             = (sensitive value)
          + api_quota                                           = (known after apply)
          + api_requests_per_minute                             = (known after apply)
          + api_secret                                          = (sensitive value)
          + api_token                                           = (sensitive value)
          + api_type                                            = (known after apply)
          + api_url                                             = (known after apply)
          + api_version                                         = (known after apply)
          + app_sync_mode                                       = (known after apply)
          + append_file_option                                  = (known after apply)
          + archive_pattern                                     = (known after apply)
          + are_soap_credentials_provided                       = (known after apply)
          + asm_option                                          = (known after apply)
          + asm_oracle_home                                     = (known after apply)
          + asm_password                                        = (sensitive value)
          + asm_tns                                             = (known after apply)
          + asm_user                                            = (known after apply)
          + auth                                                = (known after apply)
          + auth_environment                                    = (known after apply)
          + auth_mode                                           = (known after apply)
          + auth_type                                           = (known after apply)
          + authentication_method                               = (known after apply)
          + authorization_method                                = (known after apply)
          + aws_region_code                                     = (known after apply)
          + base_url                                            = (known after apply)
          + blockchain                                          = (known after apply)
          + bucket                                              = (known after apply)
          + bucket_name                                         = (known after apply)
          + bucket_service                                      = (known after apply)
          + certificate                                         = (sensitive value)
          + click_attribution_window                            = (known after apply)
          + client_id                                           = (sensitive value)
          + client_name                                         = (sensitive value)
          + client_secret                                       = (sensitive value)
          + cloud_storage_type                                  = (known after apply)
          + company_id                                          = (known after apply)
          + compression                                         = (known after apply)
          + config_method                                       = (known after apply)
          + config_type                                         = (known after apply)
          + connection_method                                   = (known after apply)
          + connection_string                                   = (sensitive value)
          + connection_type                                     = (known after apply)
          + consumer_group                                      = (known after apply)
          + consumer_key                                        = (sensitive value)
          + consumer_secret                                     = (sensitive value)
          + container_name                                      = (known after apply)
          + conversion_report_time                              = (known after apply)
          + conversion_window_size                              = (known after apply)
          + csv_definition                                      = (known after apply)
          + customer_id                                         = (known after apply)
          + customer_list_id                                    = (known after apply)
          + daily_api_call_limit                                = (known after apply)
          + data_access_method                                  = (known after apply)
          + data_center                                         = (known after apply)
          + database                                            = (known after apply)
          + dataset_id                                          = (known after apply)
          + datasource                                          = (known after apply)
          + date_granularity                                    = (known after apply)
          + delimiter                                           = (known after apply)
          + direct_capture_method                               = (known after apply)
          + distributed_connector_cluster_size                  = (known after apply)
          + domain                                              = (known after apply)
          + domain_host_name                                    = (known after apply)
          + domain_name                                         = (known after apply)
          + domain_type                                         = (known after apply)
          + email                                               = (known after apply)
          + empty_header                                        = (known after apply)
          + enable_all_dimension_combinations                   = (known after apply)
          + enable_archive_log_only                             = (known after apply)
          + enable_data_extensions_syncing                      = (known after apply)
          + enable_distributed_connector_mode                   = (known after apply)
          + enable_enrichments                                  = (known after apply)
          + enable_exports                                      = (known after apply)
          + enable_tde                                          = (known after apply)
          + encryption_key                                      = (sensitive value)
          + endpoint                                            = (known after apply)
          + engagement_attribution_window                       = (known after apply)
          + entity_id                                           = (known after apply)
          + environment                                         = (known after apply)
          + escape_char                                         = (known after apply)
          + escape_char_options                                 = (known after apply)
          + eu_region                                           = (known after apply)
          + export_storage_type                                 = (known after apply)
          + external_id                                         = (known after apply)
          + file_type                                           = (known after apply)
          + finance_account_sync_mode                           = (known after apply)
          + folder_id                                           = (known after apply)
          + ftp_host                                            = (known after apply)
          + ftp_password                                        = (sensitive value)
          + ftp_port                                            = (known after apply)
          + ftp_user                                            = (known after apply)
          + function                                            = (known after apply)
          + function_app                                        = (known after apply)
          + function_key                                        = (sensitive value)
          + function_name                                       = (known after apply)
          + function_trigger                                    = (sensitive value)
          + gcs_bucket                                          = (known after apply)
          + gcs_folder                                          = (known after apply)
          + group_name                                          = (known after apply)
          + hana_mode                                           = (known after apply)
          + has_manage_permissions                              = (known after apply)
          + home_folder                                         = (known after apply)
          + host                                                = (known after apply)
          + identity                                            = (known after apply)
          + include_ocapi_endpoints                             = (known after apply)
          + instance                                            = (known after apply)
          + integration_key                                     = (sensitive value)
          + is_account_level_connector                          = (known after apply)
          + is_auth2_enabled                                    = (known after apply)
          + is_custom_api_credentials                           = (known after apply)
          + is_external_activities_endpoint_selected            = (known after apply)
          + is_ftps                                             = (known after apply)
          + is_keypair                                          = (known after apply)
          + is_multi_entity_feature_enabled                     = (known after apply)
          + is_new_package                                      = (known after apply)
          + is_private_key_encrypted                            = (known after apply)
          + is_private_link_required                            = (known after apply)
          + is_public                                           = (known after apply)
          + is_sailthru_connect_enabled                         = (known after apply)
          + is_secure                                           = (known after apply)
          + is_sftp_creds_available                             = (known after apply)
          + is_single_table_mode                                = (known after apply)
          + is_vendor                                           = (known after apply)
          + key                                                 = (known after apply)
          + last_synced_changes__utc_                           = (known after apply)
          + latest_version                                      = (known after apply)
          + limit_for_api_calls_to_external_activities_endpoint = (known after apply)
          + list_strategy                                       = (known after apply)
          + login_password                                      = (sensitive value)
          + merchant_id                                         = (known after apply)
          + message_type                                        = (known after apply)
          + named_range                                         = (known after apply)
          + network_code                                        = (known after apply)
          + non_standard_escape_char                            = (known after apply)
          + null_sequence                                       = (known after apply)
          + oauth_token                                         = (sensitive value)
          + oauth_token_secret                                  = (sensitive value)
          + on_error                                            = (known after apply)
          + on_premise                                          = (known after apply)
          + organization                                        = (known after apply)
          + organization_id                                     = (known after apply)
          + passphrase                                          = (sensitive value)
          + password                                            = (sensitive value)
          + pat                                                 = (sensitive value)
          + path                                                = (known after apply)
          + pattern                                             = (known after apply)
          + pdb_name                                            = (known after apply)
          + pem_certificate                                     = (sensitive value)
          + port                                                = (known after apply)
          + post_click_attribution_window_size                  = (known after apply)
          + prebuilt_report                                     = (known after apply)
          + prefix                                              = (known after apply)
          + private_key                                         = (sensitive value)
          + product                                             = (known after apply)
          + project_id                                          = (known after apply)
          + public_key                                          = (known after apply)
          + publication_name                                    = (known after apply)
          + pull_archived_campaigns                             = (known after apply)
          + query_id                                            = (known after apply)
          + region                                              = (known after apply)
          + region_api_url                                      = (known after apply)
          + region_auth_url                                     = (known after apply)
          + region_token_url                                    = (known after apply)
          + replica_id                                          = (known after apply)
          + replication_slot                                    = (known after apply)
          + report_type                                         = (known after apply)
          + report_url                                          = (known after apply)
          + resource_url                                        = (known after apply)
          + rest_api_limit                                      = (known after apply)
          + role                                                = (known after apply)
          + role_arn                                            = (sensitive value)
          + rollback_window_size                                = (known after apply)
          + s3bucket                                            = (known after apply)
          + s3external_id                                       = (known after apply)
          + s3folder                                            = (known after apply)
          + s3role_arn                                          = (sensitive value)
          + sales_account_sync_mode                             = (known after apply)
          + sap_user                                            = (known after apply)
          + secret                                              = (sensitive value)
          + secret_key                                          = (sensitive value)
          + secrets                                             = (sensitive value)
          + security_protocol                                   = (known after apply)
          + server                                              = (known after apply)
          + server_url                                          = (known after apply)
          + service_version                                     = (known after apply)
          + sftp_host                                           = (known after apply)
          + sftp_is_key_pair                                    = (known after apply)
          + sftp_password                                       = (sensitive value)
          + sftp_port                                           = (known after apply)
          + sftp_user                                           = (known after apply)
          + share_url                                           = (known after apply)
          + sheet_id                                            = (known after apply)
          + shop                                                = (known after apply)
          + short_code                                          = (sensitive value)
          + should_sync_events_with_deleted_profiles            = (known after apply)
          + show_records_with_no_metrics                        = (known after apply)
          + sid                                                 = (known after apply)
          + site_id                                             = (known after apply)
          + skip_after                                          = (known after apply)
          + skip_before                                         = (known after apply)
          + soap_uri                                            = (known after apply)
          + source                                              = (known after apply)
          + sub_domain                                          = (known after apply)
          + subdomain                                           = (known after apply)
          + subscriber_name                                     = (known after apply)
          + support_connected_accounts_sync                     = (known after apply)
          + support_nested_columns                              = (known after apply)
          + swipe_attribution_window                            = (known after apply)
          + sync_data_locker                                    = (known after apply)
          + sync_format                                         = (known after apply)
          + sync_formula_fields                                 = (known after apply)
          + sync_metadata                                       = (known after apply)
          + sync_method                                         = (known after apply)
          + sync_mode                                           = (known after apply)
          + sync_mode_advertiser                                = (known after apply)
          + sync_mode_seat                                      = (known after apply)
          + sync_multiple_accounts                              = (known after apply)
          + sync_pack_mode                                      = (known after apply)
          + sync_pull_api                                       = (known after apply)
          + sync_type                                           = (known after apply)
          + target_entity_id                                    = (known after apply)
          + technical_account_id                                = (known after apply)
          + test_table_name                                     = (known after apply)
          + time_zone                                           = (known after apply)
          + timeframe_months                                    = "ALL_TIME"
          + tns                                                 = (known after apply)
          + token_key                                           = (sensitive value)
          + token_secret                                        = (sensitive value)
          + tunnel_host                                         = (known after apply)
          + tunnel_port                                         = (known after apply)
          + tunnel_user                                         = (known after apply)
          + unique_id                                           = (known after apply)
          + update_config_on_each_sync                          = (known after apply)
          + update_method                                       = (known after apply)
          + uri                                                 = (known after apply)
          + url_format                                          = (known after apply)
          + use_api_keys                                        = (known after apply)
          + use_customer_bucket                                 = (known after apply)
          + use_oracle_rac                                      = (known after apply)
          + use_pgp_encryption_options                          = (known after apply)
          + use_service_account                                 = (known after apply)
          + use_template_labels                                 = (known after apply)
          + use_webhooks                                        = (known after apply)
          + use_workspace                                       = (known after apply)
          + user                                                = (known after apply)
          + user_id                                             = (known after apply)
          + user_key                                            = (sensitive value)
          + user_name                                           = (known after apply)
          + username                                            = (known after apply)
          + view_attribution_window                             = (known after apply)
          + view_through_attribution_window_size                = (known after apply)
          + workspace_same_as_source                            = (known after apply)
        }

      + destination_schema {
          + name = "itunes_connect_vmosin_test"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

fivetran_connector.connector: Creating...
fivetran_connector.connector: Creation complete after 1s [id=stopped_bid]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
beevital commented 5 months ago

Are you sure you're not trying to setup timeframe_months for google_play - it doesn't support it. Connector doesn't return it in response, so terraform fails to validate state.

beevital commented 5 months ago

Actually - this logic is weird, and we should fail on attempt to configure fields that are not expected for connector.

knummert commented 5 months ago

Similar failures happen when using the fivetran_destination resource:

│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to fivetran_destination.databricks_sql_warehouse, provider "provider[\"registry.terraform.io/fivetran/fivetran\"]" produced an unexpected new value: .config.cloud_provider: was cty.StringVal("AWS"), but now null.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to fivetran_destination.databricks_sql_warehouse, provider "provider[\"registry.terraform.io/fivetran/fivetran\"]" produced an unexpected new value: .config.auth_type: was cty.StringVal("PERSONAL_ACCESS_TOKEN"), but now null.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
ACarter-Jones commented 5 months ago

Also getting a similar failure since the latest release:

│ 
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to fivetran_destination.databricks_dev, provider
│ "provider[\"registry.terraform.io/fivetran/fivetran\"]" produced an
│ unexpected new value: .config.data_set_location: was cty.StringVal("EU"),
│ but now null.
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
│ 
mnahkies commented 5 months ago

I'm seeing issues still as well:

When applying changes to <X>.fivetran_connector_schema_config.schema, provider 
"provider[\"registry.terraform.io/fivetran/fivetran\"]" produced an unexpected new value: .schemas["public"].tables: was null, 
but now cty.MapVal(map[string]cty.Value{"Communication":cty.ObjectVal(map[string]cty.Value{"columns":cty.NullVal(cty.Map(cty.Object(map[string]cty.Type{"enabled":cty.Bool, "hashed":cty.Bool}))), 
"enabled":cty.NullVal(cty.Bool), "sync_mode":cty.NullVal(cty.String)}),
"<Y>":cty.ObjectVal(map[string]cty.Value{"columns":cty.NullVal(cty.Map(cty.Object(map[string]cty.Type{"enabled":cty.Bool, "hashed":cty.Bool}))), "enabled":cty.NullVal(cty.Bool), "sync_mode":cty.NullVal(cty.String)}), 
beevital commented 3 months ago

I'm seeing issues still as well:

When applying changes to <X>.fivetran_connector_schema_config.schema, provider 
"provider[\"registry.terraform.io/fivetran/fivetran\"]" produced an unexpected new value: .schemas["public"].tables: was null, 
but now cty.MapVal(map[string]cty.Value{"Communication":cty.ObjectVal(map[string]cty.Value{"columns":cty.NullVal(cty.Map(cty.Object(map[string]cty.Type{"enabled":cty.Bool, "hashed":cty.Bool}))), 
"enabled":cty.NullVal(cty.Bool), "sync_mode":cty.NullVal(cty.String)}),
"<Y>":cty.ObjectVal(map[string]cty.Value{"columns":cty.NullVal(cty.Map(cty.Object(map[string]cty.Type{"enabled":cty.Bool, "hashed":cty.Bool}))), "enabled":cty.NullVal(cty.Bool), "sync_mode":cty.NullVal(cty.String)}), 

This is another issue with another resource.

beevital commented 3 months ago

@ACarter-Jones

When applying changes to fivetran_destination.databricks_dev, provider │ "provider[\"registry.terraform.io/fivetran/fivetran\"]" produced an │ unexpected new value: .config.data_set_location: was cty.StringVal("EU"), │ but now null.

Why you're trying to set data_set_location for databricks destination? https://fivetran.com/docs/rest-api/destinations/config#databricks

barabasakos commented 3 months ago

thank you @beevital !