Skip to content

Commit dd3766c

Browse files
rohankabra-dbnfx
andauthored
Added new feature (#2015)
* 1. Add support for gcp cmk 2. Add details to gcp guide for authentication with service account (SA-1) * Rename test name as suggested in the PR review * Update internal/acceptance/mws_customer_managed_keys_test.go to remove provider Co-authored-by: Serge Smertin <[email protected]> --------- Co-authored-by: Serge Smertin <[email protected]>
1 parent f7967ca commit dd3766c

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

docs/guides/gcp-workspace.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ After you’ve added Service Account to Databricks Accounts Console, please copy
9090

9191
Databricks account-level APIs can only be called by account owners and account admins, and can only be authenticated using Google-issued OIDC tokens. The simplest way to do this would be via [Google Cloud CLI](https://cloud.google.com/sdk/gcloud). The `gcloud` command is available after installing the SDK. Then run the following commands
9292

93-
* `gcloud auth application-default login` to authorise your user with Google Cloud Platform.
93+
* `gcloud auth application-default login` to authorise your user with Google Cloud Platform. (If you want to use your [service account's credentials instead](https://cloud.google.com/docs/authentication/provide-credentials-adc#local-key), set the environment variable `GOOGLE_APPLICATION_CREDENTIALS` to the path of the JSON file that contains your service account key)
9494
* `terraform init` to load Google and Databricks Terraform providers.
9595
* `terraform apply` to apply the configuration changes. Terraform will use your credential to impersonate the service account specified in `databricks_google_service_account` to call the Databricks account-level API.
9696

internal/acceptance/mws_customer_managed_keys_test.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"testing"
55
)
66

7-
func TestMwsAccCustomerManagedKeys(t *testing.T) {
7+
func TestMwsAccAwsCustomerManagedKeys(t *testing.T) {
88
accountLevel(t, step{
99
Template: `resource "databricks_mws_customer_managed_keys" "this" {
1010
account_id = "{env.DATABRICKS_ACCOUNT_ID}"
@@ -16,3 +16,15 @@ func TestMwsAccCustomerManagedKeys(t *testing.T) {
1616
}`,
1717
})
1818
}
19+
20+
func TestMwsAccGcpCustomerManagedKeysForStorage(t *testing.T) {
21+
accountLevel(t, step{
22+
Template: `resource "databricks_mws_customer_managed_keys" "this" {
23+
account_id = "{env.DATABRICKS_ACCOUNT_ID}"
24+
gcp_key_info {
25+
kms_key_id = "{env.TEST_GCP_KMS_KEY_ID}"
26+
}
27+
use_cases = ["STORAGE"]
28+
}`,
29+
})
30+
}

mws/resource_mws_customer_managed_keys.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,17 @@ type AwsKeyInfo struct {
1717
KeyRegion string `json:"key_region,omitempty" tf:"computed"`
1818
}
1919

20+
// GcpKeyInfo has information about the KMS key for BYOK
21+
type GcpKeyInfo struct {
22+
KmsKeyId string `json:"kms_key_id"`
23+
}
24+
2025
// CustomerManagedKey contains key information and metadata for BYOK for E2
26+
// You must specify either AwsKeyInfo for AWS or GcpKeyInfo for GCP, but not both
2127
type CustomerManagedKey struct {
2228
CustomerManagedKeyID string `json:"customer_managed_key_id,omitempty" tf:"computed"`
23-
AwsKeyInfo *AwsKeyInfo `json:"aws_key_info" tf:"force_new"`
29+
AwsKeyInfo *AwsKeyInfo `json:"aws_key_info,omitempty" tf:"force_new,conflicts:gcp_key_info"`
30+
GcpKeyInfo *GcpKeyInfo `json:"gcp_key_info,omitempty" tf:"force_new,conflicts:aws_key_info"`
2431
AccountID string `json:"account_id" tf:"force_new"`
2532
CreationTime int64 `json:"creation_time,omitempty" tf:"computed"`
2633
UseCases []string `json:"use_cases"`

0 commit comments

Comments
 (0)