Conversation
ModifyPlan on all three schema config resources now warns when modifying a connection that has already synced data, as changes may trigger expensive resyncs. Connection sync status is cached per connection_id (1min TTL) to avoid redundant API calls when multiple resources share a connection. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fivetran-renat-sh
left a comment
There was a problem hiding this comment.
Looks good overall. Thank you!
Would be good to add E2E test to check against real-world API
| }, | ||
| "exclude_mode": actionSchema.StringAttribute{ | ||
| Optional: true, | ||
| Description: "The exclude mode for the schema reload. Accepted values: PRESERVE, EXCLUDE. Default: PRESERVE.", |
There was a problem hiding this comment.
Would be god to describe what is the difference between PRESERVE and EXCLUDE, and what are scenarios to use each of them
| - `is_historical_sync` (Boolean) The boolean specifying whether the connector should be triggered to re-sync all historical data. If you set this parameter to TRUE, the next scheduled sync will be historical. If the value is FALSE or not specified, the connector will not re-sync historical data. NOTE: When the value is TRUE, only the next scheduled sync will be historical, all subsequent ones will be incremental. This parameter is set to FALSE once the historical sync is completed. | ||
| - `setup_state` (String) The current setup state of the connector. The available values are: <br /> - incomplete - the setup config is incomplete, the setup tests never succeeded `connected` - the connector is properly set up, `broken` - the connector setup config is broken. | ||
| - `sync_state` (String) The current sync state of the connector. The available values are: `scheduled` - the sync is waiting to be run, `syncing` - the sync is currently running, `paused` - the sync is currently paused, `rescheduled` - the sync is waiting until more API calls are available in the source service. | ||
| - `tasks` (Attributes Set) The collection of tasks for the connector. (see [below for nested schema](#nestedatt--status--tasks)) | ||
| - `update_state` (String) The current data update state of the connector. The available values are: `on_schedule` - the sync is running smoothly, no delays, `delayed` - the data is delayed for a longer time than expected for the update. | ||
| - `warnings` (Attributes Set) The collection of warnings for the connector. (see [below for nested schema](#nestedatt--status--warnings)) |
There was a problem hiding this comment.
Please revert connection -> connector change (let's may be revert connection.md, connections.md, destination.md, destinations.md). Descriptions should be fixed, but it's unrelated to this PR activity
| # All schemas are enabled except these: | ||
| disabled_schemas = ["staging", "temp"] | ||
|
|
||
| depends_on = [fivetran_connector.pg] |
There was a problem hiding this comment.
Is this supposed to depend on schema reload instead? Like
| depends_on = [fivetran_connector.pg] | |
| depends_on = [fivetran_connection_schema_reload.reload] |
Because currently it is the same as in the old way, where fivetran_connector_schema_config is dependent on fivetran_connector
|
|
||
| The modular resources detect drift at every level: | ||
|
|
||
| - A schema disabled externally → `disabled_schemas` grows, plan shows the change |
There was a problem hiding this comment.
| - A schema disabled externally → `disabled_schemas` grows, plan shows the change | |
| - A schema is disabled externally → `disabled_schemas` grows, plan shows the change |
| - A schema disabled externally → `disabled_schemas` grows, plan shows the change | ||
| - A new table appears disabled → `disabled_tables` grows, plan shows the change | ||
| - A column gets hashed externally (when `hashed_columns` is managed) → drift detected | ||
| - A managed item is dropped from the source → it disappears from the list, plan shows the change |
There was a problem hiding this comment.
| - A managed item is dropped from the source → it disappears from the list, plan shows the change | |
| - Schema/table/column is dropped from the source → it disappears from the list, plan shows the change |
|
|
||
| - **`disabled_tables`** — listed tables are **disabled**, all other tables are **enabled** | ||
| - **`enabled_tables`** — listed tables are **enabled**, all other tables are **disabled** | ||
|
|
There was a problem hiding this comment.
Looks like better to emphasize that choice is strictly dependent on connection's schema_change_handling, that disabled_tables is used in case of ALLOW_ALL, and enabled_tables is used in case of BLOCK_ALL or ALLOW_COLUMNS
There was a problem hiding this comment.
No it's actually not.
You can define exact set of disabled or enabled tables/columns/schemas without reffering to the policy.
Policy regulates how Fivetran handles new elements that comes from source.
It's up to you as a TF user which list you want to use (maybe the one that is shorter).
But the behavior differs a bit. For example if we specify "enabled_tables" with "ALLOW_ALL - if the new table appears in schema - it will produce a drift on next plan. And if you use disabled_tables with ALLOW_ALL - no drifts. So it's fully up to you.
| Do(ctx) | ||
| if detailsErr == nil && detailsResponse.Code != "NotFound_SchemaConfig" { | ||
| return | ||
| } |
There was a problem hiding this comment.
If API returns 500 we should return immediately as well
| data connectionSchemaTablesConfigModel, | ||
| tables map[string]*connections.ConnectionSchemaConfigTableResponse, |
There was a problem hiding this comment.
| data connectionSchemaTablesConfigModel, | |
| tables map[string]*connections.ConnectionSchemaConfigTableResponse, | |
| localData connectionSchemaTablesConfigModel, | |
| upstreamTables map[string]*connections.ConnectionSchemaConfigTableResponse, |
| d.EnabledTables = buildOrderedSet(collectTableNames(tables, true), d.EnabledTables) | ||
| } else { | ||
| // Import: populate based on API policy | ||
| if schemaResp.Data.SchemaChangeHandling == "ALLOW_ALL" || schemaResp.Data.SchemaChangeHandling == "ALLOW_COLUMNS" { |
There was a problem hiding this comment.
From docs/resources/connection_schema_tables_config.md :
disabled_tables(List of String) Set of table names to disable. Use when the connection's schema_change_handling is ALLOW_ALL.enabled_tables(List of String) Set of table names to enable. Use when the connection's schema_change_handling is BLOCK_ALL or ALLOW_COLUMNS.
So it is probably expected to be:
| if schemaResp.Data.SchemaChangeHandling == "ALLOW_ALL" || schemaResp.Data.SchemaChangeHandling == "ALLOW_COLUMNS" { | |
| if schemaResp.Data.SchemaChangeHandling == "ALLOW_ALL" { |
|
|
||
| - **`disabled_columns`** — listed columns are **disabled**, all other columns are **enabled** | ||
| - **`enabled_columns`** — listed columns are **enabled**, all other columns are **disabled** | ||
|
|
There was a problem hiding this comment.
Need to mention that terraform import populates disabled_columns and does not populate enabled_columns
Summary
Introduces a modular, hierarchical approach to managing Fivetran connection schema configuration as an alternative to the monolithic
fivetran_connector_schema_configresource. The new resources allow independent management of schemas, tables, and columns with proper dependency ordering, concurrency safety, and drift detection.New Resources
fivetran_connection_schemas_configschema_change_handlingpolicy and schema-level enable/disablefivetran_connection_schema_tables_configfivetran_connection_table_columns_configNew Action
fivetran_connection_schema_reloadKey Design Decisions
disabled_*/enabled_*): the list you choose defines the complete desired state — listed items get one state, everything else gets the opposite. This eliminates ambiguity about unmanaged items.schema_change_handlingpolicy. Changing the policy inconnection_schemas_configdoes not break downstream table/column resources.sync_mode,hashed_columns, andprimary_key_columnsare only tracked when explicitly configured. When omitted, external changes to these settings are ignored.core.SchemaLocks): serializes all schema-modifying API calls for the sameconnection_idto prevent optimistic lock conflicts.enabled_patch_settingsvalidation: checks that system tables/columns can be modified before sending the PATCH request, reporting all blocked items in a single error.connection_table_columns_configuses the dedicated column list endpoint (GET .../columns) since schema details only returns previously configured columns.FastStringSetType: custom attribute type backed bytftypes.ListwithListSemanticEqualsfor O(n) set comparison, solving the O(n²) performance problem withtypes.Setat scale.Test Coverage
enabled_patch_settingsvalidation.TestSchemaManagementFullFlow): exercises the complete lifecycle — connection creation → schema reload via lifecycle action → 3 schemas × 3 tables configuration withlocals-driven config → column-level settings with hashing and PKs → unpause viaconnector_schedule. Stateful mock verifies every mutation.Documentation
subcategory: "Preview"for_eachexamplestfplugindocsFiles
New:
fivetran/framework/resources/connection_schemas_config.gofivetran/framework/resources/connection_schema_tables_config.gofivetran/framework/resources/connection_table_columns_config.gofivetran/framework/actions/connection_schema_reload.gofivetran/framework/core/schema_locks.gofivetran/framework/core/fivetrantypes/fast_string_set.goModified:
fivetran/framework/provider.go— registered new resources and action