Skip to content

Commit fac596f

Browse files
authored
Add missing KMS fields to google_compute_instance (#13192)
1 parent 388124d commit fac596f

File tree

9 files changed

+1170
-46
lines changed

9 files changed

+1170
-46
lines changed

mmv1/products/compute/Image.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,20 @@ properties:
168168
The service account being used for the encryption request for the
169169
given KMS key. If absent, the Compute Engine default service
170170
account is used.
171+
- name: 'rawKey'
172+
type: String
173+
description: |
174+
Specifies a 256-bit customer-supplied encryption key, encoded in
175+
RFC 4648 base64 to either encrypt or decrypt this resource.
176+
ignore_read: true
177+
sensitive: true
178+
- name: 'rsaEncryptedKey'
179+
type: String
180+
description: |
181+
Specifies a 256-bit customer-supplied encryption key, encoded in
182+
RFC 4648 base64 to either encrypt or decrypt this resource.
183+
ignore_read: true
184+
sensitive: true
171185
- name: 'labels'
172186
type: KeyValueLabels
173187
description: Labels to apply to this Image.

mmv1/products/compute/Snapshot.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ parameters:
123123
ignore_read: true
124124
sensitive: true
125125
custom_flatten: 'templates/terraform/custom_flatten/compute_snapshot_snapshot_encryption_raw_key.go.tmpl'
126+
- name: 'rsaEncryptedKey'
127+
type: String
128+
description: |
129+
Specifies an encryption key stored in Google Cloud KMS, encoded in
130+
RFC 4648 base64 to either encrypt or decrypt this resource.
131+
ignore_read: true
132+
sensitive: true
126133
- name: 'sha256'
127134
type: String
128135
description: |

mmv1/third_party/terraform/services/compute/compute_instance_helpers.go.tmpl

+58
Original file line numberDiff line numberDiff line change
@@ -1089,3 +1089,61 @@ func flattenNetworkPerformanceConfig(c *compute.NetworkPerformanceConfig) []map[
10891089
},
10901090
}
10911091
}
1092+
1093+
func expandComputeInstanceEncryptionKey(d tpgresource.TerraformResourceData) *compute.CustomerEncryptionKey {
1094+
iek, ok := d.GetOk("instance_encryption_key")
1095+
if !ok {
1096+
return nil
1097+
}
1098+
1099+
iekRes := iek.([]interface{})[0].(map[string]interface{})
1100+
return &compute.CustomerEncryptionKey{
1101+
KmsKeyName: iekRes["kms_key_self_link"].(string),
1102+
Sha256: iekRes["sha256"].(string),
1103+
KmsKeyServiceAccount: iekRes["kms_key_service_account"].(string),
1104+
}
1105+
}
1106+
1107+
func flattenComputeInstanceEncryptionKey(v *compute.CustomerEncryptionKey) []map[string]interface{} {
1108+
if v == nil {
1109+
return nil
1110+
}
1111+
return []map[string]interface{}{
1112+
{
1113+
"kms_key_self_link": v.KmsKeyName,
1114+
"sha256": v.Sha256,
1115+
"kms_key_service_account": v.KmsKeyServiceAccount,
1116+
},
1117+
}
1118+
}
1119+
1120+
func expandComputeInstanceSourceEncryptionKey(d tpgresource.TerraformResourceData, field string) *compute.CustomerEncryptionKey {
1121+
cek, ok := d.GetOk(field)
1122+
if !ok {
1123+
return nil
1124+
}
1125+
1126+
cekRes := cek.([]interface{})[0].(map[string]interface{})
1127+
return &compute.CustomerEncryptionKey{
1128+
RsaEncryptedKey: cekRes["rsa_encrypted_key"].(string),
1129+
RawKey: cekRes["raw_key"].(string),
1130+
KmsKeyName: cekRes["kms_key_self_link"].(string),
1131+
Sha256: cekRes["sha256"].(string),
1132+
KmsKeyServiceAccount: cekRes["kms_key_service_account"].(string),
1133+
}
1134+
}
1135+
1136+
func flattenComputeInstanceSourceEncryptionKey(v *compute.CustomerEncryptionKey) []map[string]interface{} {
1137+
if v == nil {
1138+
return nil
1139+
}
1140+
return []map[string]interface{}{
1141+
{
1142+
"rsa_encrypted_key": v.RsaEncryptedKey,
1143+
"raw_key": v.RawKey,
1144+
"kms_key_self_link": v.KmsKeyName,
1145+
"sha256": v.Sha256,
1146+
"kms_key_service_account": v.KmsKeyServiceAccount,
1147+
},
1148+
}
1149+
}

0 commit comments

Comments
 (0)