Skip to content

Commit 48e157b

Browse files
authored
Set Computed field to true for common.Resource account_id attribute (#3310)
* Set `Computed` field to `true` in `common/resource.go` for `account_id` * Add unit test to test NoDiff on `account_id` for `databricks_mws_private_access_settings`
1 parent a53018e commit 48e157b

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

common/resource.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ var NoAuth string = "default auth: cannot configure default credentials, " +
443443
func AddAccountIdField(s map[string]*schema.Schema) map[string]*schema.Schema {
444444
s["account_id"] = &schema.Schema{
445445
Type: schema.TypeString,
446+
Computed: true,
446447
Optional: true,
447448
Deprecated: "Configuring `account_id` at the resource-level is deprecated; please specify it in the `provider {}` configuration block instead",
448449
}

mws/resource_mws_private_access_settings_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package mws
33
import (
44
"testing"
55

6+
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
7+
68
"github.com/databricks/databricks-sdk-go/apierr"
79
"github.com/databricks/databricks-sdk-go/experimental/mocks"
810
"github.com/databricks/databricks-sdk-go/service/provisioning"
@@ -247,3 +249,26 @@ func TestResourcePASDelete_Error(t *testing.T) {
247249
qa.AssertErrorStartsWith(t, err, "Internal error happened")
248250
assert.Equal(t, "abc/pas_id", d.Id())
249251
}
252+
253+
func TestResourcePASUpdateAccountIdNoDiff(t *testing.T) {
254+
qa.ResourceFixture{
255+
Resource: ResourceMwsPrivateAccessSettings(),
256+
ID: "abc",
257+
InstanceState: map[string]string{
258+
"account_id": "foo",
259+
"private_access_settings_name": "pas_name",
260+
"public_access_enabled": "false",
261+
"region": "eu-west-1",
262+
"private_access_level": "ENDPOINT",
263+
},
264+
ExpectedDiff: map[string]*terraform.ResourceAttrDiff{
265+
"private_access_settings_id": {Old: "", New: "", NewComputed: true, NewRemoved: false, RequiresNew: false, Sensitive: false},
266+
},
267+
HCL: `
268+
private_access_settings_name = "pas_name"
269+
public_access_enabled = false
270+
region = "eu-west-1"
271+
private_access_level = "ENDPOINT"
272+
`,
273+
}.ApplyNoError(t)
274+
}

0 commit comments

Comments
 (0)