diff --git a/monte_carlo/client/monte_carlo_client.go b/monte_carlo/client/monte_carlo_client.go index 45c6634..d2c056a 100644 --- a/monte_carlo/client/monte_carlo_client.go +++ b/monte_carlo/client/monte_carlo_client.go @@ -98,6 +98,9 @@ type GetWarehouse struct { Uuid string `json:"uuid"` Type string `json:"type"` } `json:"connections"` + DataCollector struct { + Uuid string `json:"uuid"` + } `json:"dataCollector"` } `json:"getWarehouse"` } diff --git a/monte_carlo/resources/bigquery_warehouse.go b/monte_carlo/resources/bigquery_warehouse.go index f910390..b53c201 100644 --- a/monte_carlo/resources/bigquery_warehouse.go +++ b/monte_carlo/resources/bigquery_warehouse.go @@ -167,6 +167,20 @@ func (r *BigQueryWarehouseResource) Read(ctx context.Context, req resource.ReadR return } + readDataCollectorUuid := getResult.GetWarehouse.DataCollector.Uuid + confDataCollectorUuid := data.DataCollectorUuid.ValueString() + if readDataCollectorUuid != confDataCollectorUuid { + resp.Diagnostics.AddError( + fmt.Sprintf("Obtained BigQuery warehouse with [uuid: %s] but its Data Collector UUID does not match with "+ + "configured value [obtained: %s, configured: %s]. BigQuery warehouse might have been moved to other "+ + "Data Collector externally", data.Uuid.ValueString(), readDataCollectorUuid, confDataCollectorUuid), + "Since its not possible for this provider to update Data Collector of BigQuery warehouse, this resource "+ + "cannot continue to function properly. It is recommended to change Data Collector UUID for this "+ + "resource directly in the Terraform configuration", + ) + return + } + readConnectionUuid := types.StringNull() readServiceAccountKey := types.StringNull() for _, connection := range getResult.GetWarehouse.Connections {