Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Added optional `cloud` argument to `databricks_current_config` data source to explicitly set the cloud type (`aws`, `azure`, `gcp`) instead of relying on host-based detection.

* Added `api` field to dual account/workspace resources (`databricks_user`, `databricks_service_principal`, `databricks_group`, `databricks_group_role`, `databricks_group_member`, `databricks_user_role`, `databricks_service_principal_role`, `databricks_user_instance_profile`, `databricks_group_instance_profile`, `databricks_metastore`, `databricks_metastore_assignment`, `databricks_metastore_data_access`, `databricks_storage_credential`, `databricks_service_principal_secret`, `databricks_access_control_rule_set`) to explicitly control whether account-level or workspace-level APIs are used. This enables support for unified hosts like `api.databricks.com` where the API level cannot be inferred from the host ([#5483](https://github.com/databricks/terraform-provider-databricks/pull/5483)).
* Allow in-place renames for `databricks_credential` and `databricks_external_location` resources ([#5538](https://github.com/databricks/terraform-provider-databricks/pull/5538)).

### Bug Fixes

Expand Down
4 changes: 3 additions & 1 deletion catalog/resource_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ var credentialSchema = common.StructToSchema(catalog.CredentialInfo{},
common.CustomizeSchemaPath(m, computed).SetComputed()
}

common.CustomizeSchemaPath(m, "name").SetForceNew()
common.CustomizeSchemaPath(m, "databricks_gcp_service_account").SetComputed()
common.CustomizeSchemaPath(m, "databricks_gcp_service_account", "email").SetComputed()
common.CustomizeSchemaPath(m, "databricks_gcp_service_account", "credential_id").SetComputed()
Expand Down Expand Up @@ -143,6 +142,9 @@ func ResourceCredential() common.Resource {
if !d.HasChangeExcept("owner") {
return nil
}
if d.HasChange("name") {
updateCredRequest.NewName = d.Get("name").(string)
}
if d.HasChange("read_only") {
updateCredRequest.ForceSendFields = append(updateCredRequest.ForceSendFields, "ReadOnly")
}
Expand Down
12 changes: 6 additions & 6 deletions catalog/resource_credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,20 @@ func TestCreateIsolatedCredential(t *testing.T) {
})
}

func TestUpdateCredentialSchemaForceNew(t *testing.T) {
func TestUpdateCredentialSchema(t *testing.T) {
qa.ResourceFixture{
MockWorkspaceClientFunc: func(w *mocks.MockWorkspaceClient) {
e := w.GetMockCredentialsAPI().EXPECT()
e.UpdateCredential(mock.Anything, catalog.UpdateCredentialRequest{
NameArg: "name",
NewName: "rename",
AwsIamRole: &catalog.AwsIamRole{
RoleArn: "arn:aws:iam::account:role/role",
},
Comment: "comment",
}).Return(&catalog.CredentialInfo{
Id: "1234-5678",
Name: "name",
Name: "rename",
AwsIamRole: &catalog.AwsIamRole{
RoleArn: "arn:aws:iam::account:role/role",
},
Expand All @@ -186,10 +187,9 @@ func TestUpdateCredentialSchemaForceNew(t *testing.T) {
Comment: "comment",
}, nil)
},
RequiresNew: true,
Resource: ResourceCredential(),
Update: true,
ID: "name",
Resource: ResourceCredential(),
Update: true,
ID: "name",
InstanceState: map[string]string{
"name": "name",
"purpose": "SERVICE",
Expand Down
8 changes: 6 additions & 2 deletions catalog/resource_external_location.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func ResourceExternalLocation() common.Resource {
return old == "false" && new == "true"
}
common.CustomizeSchemaPath(m, "url").SetRequired().SetCustomSuppressDiff(ucDirectoryPathSlashOnlySuppressDiff)
common.CustomizeSchemaPath(m, "name").SetRequired().SetForceNew().SetCustomSuppressDiff(common.EqualFoldDiffSuppress)
common.CustomizeSchemaPath(m, "name").SetRequired().SetCustomSuppressDiff(common.EqualFoldDiffSuppress)
common.CustomizeSchemaPath(m, "credential_name").SetRequired()
common.CustomizeSchemaPath(m, "isolation_mode").SetComputed()
common.CustomizeSchemaPath(m, "owner").SetComputed()
Expand Down Expand Up @@ -130,7 +130,6 @@ func ResourceExternalLocation() common.Resource {
return err
}
}

if !d.HasChangeExcept("owner") {
return nil
}
Expand All @@ -140,6 +139,11 @@ func ResourceExternalLocation() common.Resource {
updateExternalLocationRequest.ForceSendFields = append(updateExternalLocationRequest.ForceSendFields, value)
}
}

if d.HasChange("name") {
updateExternalLocationRequest.NewName = d.Get("name").(string)
}

// ugly hack until API is fixed
if updateExternalLocationRequest.FileEventQueue != nil {
if updateExternalLocationRequest.FileEventQueue.ManagedAqs != nil {
Expand Down
12 changes: 6 additions & 6 deletions catalog/resource_external_location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,17 +329,18 @@ func TestUpdateExternalLocationName(t *testing.T) {
Fixtures: []qa.HTTPFixture{
{
Method: "PATCH",
Resource: "/api/2.1/unity-catalog/external-locations/abc",
Resource: "/api/2.1/unity-catalog/external-locations/abc-old",
ExpectedRequest: catalog.UpdateExternalLocation{
Url: "s3://foo/bar",
NewName: "abc",
CredentialName: "bcd",
Comment: "def",
ReadOnly: false,
},
},
{
Method: "GET",
Resource: "/api/2.1/unity-catalog/external-locations/abc?",
Resource: "/api/2.1/unity-catalog/external-locations/abc-old?",
Response: catalog.ExternalLocationInfo{
Name: "abc",
Url: "s3://foo/bar",
Expand All @@ -348,10 +349,9 @@ func TestUpdateExternalLocationName(t *testing.T) {
},
},
},
Resource: ResourceExternalLocation(),
Update: true,
RequiresNew: true,
ID: "abc",
Resource: ResourceExternalLocation(),
Update: true,
ID: "abc-old",
InstanceState: map[string]string{
"name": "abc-old",
"url": "s3://foo/bar",
Expand Down
Loading