forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unblock EXTERNAL/EXTERNAL_VPC Cloud KMS key creation. (GoogleCloudPla…
- Loading branch information
1 parent
d21c24d
commit 013f0af
Showing
4 changed files
with
267 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
mmv1/templates/terraform/pre_update/kms_crypto_key_version.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// The generated code does not support conditional update masks. | ||
newUpdateMask := []string{} | ||
if d.HasChange("state") { | ||
newUpdateMask = append(newUpdateMask, "state") | ||
} | ||
|
||
// Validate updated fields based on protection level (EXTERNAL vs EXTERNAL_VPC) | ||
if d.HasChange("external_protection_level_options") { | ||
if d.Get("protection_level") == "EXTERNAL" { | ||
newUpdateMask = append(newUpdateMask, "externalProtectionLevelOptions.externalKeyUri") | ||
} else if d.Get("protection_level") == "EXTERNAL_VPC" { | ||
newUpdateMask = append(newUpdateMask, "externalProtectionLevelOptions.ekmConnectionKeyPath") | ||
} | ||
} | ||
// updateMask is a URL parameter but not present in the schema, so ReplaceVars | ||
// won't set it | ||
url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(newUpdateMask, ",")}) | ||
if err != nil { | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters