Summary
dbtcloud_environment currently has Default: int64default.StaticInt64(0) on connection_id. This causes Terraform to report an "inconsistent result after apply" error when the API auto-assigns a connection to the environment (returns a non-zero value) but Terraform's plan expected 0.
Problem
When a user creates an environment without explicitly setting connection_id, the provider sends 0 to the API. The API may auto-assign a connection and return a non-zero connection_id in the response. Because the Terraform plan expected 0 (from the schema default) but the applied state contains the real ID, Terraform raises:
Error: Provider produced inconsistent result after apply
Fix
- Remove
Default: int64default.StaticInt64(0) from the connection_id attribute
- In
Create, only send connection_id to the API when the plan value is non-null and non-unknown; otherwise send 0
- After create/read, always store the API's returned value (or null if nil) rather than defaulting to 0
- Update
Update to use null-safe comparison instead of direct value comparison for connection_id changes
Files
pkg/framework/objects/environment/schema.go — remove int64 default
pkg/framework/objects/environment/resource.go — null-safe create/update handling
Source
Developed on branch fix/provider-bug-wsargent.
Summary
dbtcloud_environmentcurrently hasDefault: int64default.StaticInt64(0)onconnection_id. This causes Terraform to report an "inconsistent result after apply" error when the API auto-assigns a connection to the environment (returns a non-zero value) but Terraform's plan expected 0.Problem
When a user creates an environment without explicitly setting
connection_id, the provider sends0to the API. The API may auto-assign a connection and return a non-zeroconnection_idin the response. Because the Terraform plan expected0(from the schema default) but the applied state contains the real ID, Terraform raises:Fix
Default: int64default.StaticInt64(0)from theconnection_idattributeCreate, only sendconnection_idto the API when the plan value is non-null and non-unknown; otherwise send0Updateto use null-safe comparison instead of direct value comparison forconnection_idchangesFiles
pkg/framework/objects/environment/schema.go— remove int64 defaultpkg/framework/objects/environment/resource.go— null-safe create/update handlingSource
Developed on branch
fix/provider-bug-wsargent.