Skip to content

Commit

Permalink
adds 'purpose' to kms_crypto_key (#845)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored and danawillow committed Jun 12, 2019
1 parent 9cc9183 commit 603b83f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
4 changes: 1 addition & 3 deletions google-beta/resource_dataproc_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"

"google.golang.org/api/dataproc/v1beta2"
dataproc "google.golang.org/api/dataproc/v1beta2"
)

func resourceDataprocCluster() *schema.Resource {
Expand Down Expand Up @@ -206,14 +206,12 @@ func resourceDataprocCluster() *schema.Resource {
// API does not honour this if set ...
// It always uses whatever is specified for the worker_config
// "machine_type": { ... }

"min_cpu_platform": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

"disk_config": {
Type: schema.TypeList,
Optional: true,
Expand Down
10 changes: 9 additions & 1 deletion google-beta/resource_kms_crypto_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ func resourceKmsCryptoKey() *schema.Resource {
Optional: true,
ValidateFunc: orEmpty(validateKmsCryptoKeyRotationPeriod),
},
"purpose": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Default: "ENCRYPT_DECRYPT",
ValidateFunc: validation.StringInSlice([]string{"ENCRYPT_DECRYPT", "ASYMMETRIC_SIGN", "ASYMMETRIC_DECRYPT"}, false),
},
"version_template": {
Type: schema.TypeList,
MaxItems: 1,
Expand Down Expand Up @@ -107,7 +114,7 @@ func resourceKmsCryptoKeyCreate(d *schema.ResourceData, meta interface{}) error
}

key := cloudkms.CryptoKey{
Purpose: "ENCRYPT_DECRYPT",
Purpose: d.Get("purpose").(string),
VersionTemplate: expandVersionTemplate(d.Get("version_template").([]interface{})),
}

Expand Down Expand Up @@ -193,6 +200,7 @@ func resourceKmsCryptoKeyRead(d *schema.ResourceData, meta interface{}) error {
d.Set("name", cryptoKeyId.Name)
d.Set("rotation_period", cryptoKey.RotationPeriod)
d.Set("self_link", cryptoKey.Name)
d.Set("purpose", cryptoKey.Purpose)

if err = d.Set("version_template", flattenVersionTemplate(cryptoKey.VersionTemplate)); err != nil {
return fmt.Errorf("Error setting version_template in state: %s", err.Error())
Expand Down
1 change: 1 addition & 0 deletions google-beta/resource_kms_crypto_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ resource "google_kms_crypto_key" "crypto_key" {
name = "%s"
key_ring = "${google_kms_key_ring.key_ring.self_link}"
rotation_period = "1000000s"
purpose = "ENCRYPT_DECRYPT"
version_template {
algorithm = "GOOGLE_SYMMETRIC_ENCRYPTION"
protection_level = "SOFTWARE"
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/google_kms_crypto_key.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,7 @@ exported:
the primary. The first rotation will take place after the specified period. The rotation period has the format
of a decimal number with up to 9 fractional digits, followed by the letter s (seconds).

* `purpose` - Defines the cryptographic capabilities of the key.

* `self_link` - The self link of the created CryptoKey. Its format is `projects/{projectId}/locations/{location}/keyRings/{keyRingName}/cryptoKeys/{cryptoKeyName}`.

2 changes: 2 additions & 0 deletions website/docs/r/google_kms_crypto_key.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ The following arguments are supported:
of a decimal number with up to 9 fractional digits, followed by the letter s (seconds). It must be greater than
a day (ie, 86400).

* `purpose` - (Optional) Defines the cryptographic capabilities of the key.

* `version_template` - (Optional) A template describing settings for new crypto key versions. Structure is documented below.

---
Expand Down

0 comments on commit 603b83f

Please sign in to comment.