Skip to content

Commit 147fbcd

Browse files
authored
go gcp kms (#709)
* go gcp kms * build errors * tabid error * fix small typo * pr feedback Co-authored-by: Nathan Leniz <[email protected]>
1 parent db94bb3 commit 147fbcd

File tree

1 file changed

+51
-3
lines changed

1 file changed

+51
-3
lines changed

source/includes/steps-fle-convert-to-a-remote-master-key-gcp.yaml

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,30 @@ content: |
165165
To use the GCP KMS, you must use
166166
`libmongocrypt <https://github.com/mongodb/libmongocrypt#installing-libmongocrypt-on-windows>`__ version 1.1 or later in your application's environment.
167167
168+
.. tab::
169+
:tabid: go
170+
171+
In ``kms/provider.go``, update the variable declarations or define the expected environmental variables
172+
in ``GCPProvider()``.
173+
174+
.. code-block:: go
175+
176+
gcpEmail := GetCheckedEnv("FLE_GCP_EMAIL")
177+
gcpPrivateKey := GetCheckedEnv("FLE_GCP_PRIVATE_KEY")
178+
179+
The expected KMS provider map is created with struct tags.
180+
181+
.. code-block:: go
182+
183+
func (g *GCP) Credentials() map[string]map[string]interface{} {
184+
return map[string]map[string]interface{}{"gcp": structs.Map(g.credentials)}
185+
}
186+
187+
188+
.. note::
189+
190+
To use the GCP KMS, you must use
191+
`libmongocrypt <https://github.com/mongodb/libmongocrypt>`__ version 1.1 or later in your application's environment.
168192
---
169193
title: Create a New Data Encryption Key
170194
ref: create-a-new-data-key-gcp
@@ -302,10 +326,34 @@ content: |
302326
});
303327
304328
var dataKeyId = clientEncryption.CreateDataKey("gcp", dataKeyOptions, CancellationToken.None);
305-
Console.WriteLine($"DataKeyId [UUID]: {dataKeyId}");
306-
var dataKeyIdBase64 = Convert.ToBase64String(GuidConverter.ToBytes(dataKeyId, GuidRepresentation.Standard));
307-
Console.WriteLine($"DataKeyId [base64]: {dataKeyIdBase64}");
308329
330+
.. tab::
331+
:tabid: go
332+
333+
In ``kms/provider.go``, update the variable declarations or define the expected environmental variables
334+
in ``GCPProvider()``.
335+
336+
.. code-block:: go
337+
338+
gcpProjectID := GetCheckedEnv("FLE_GCP_PROJ_ID")
339+
gcpLocation := GetCheckedEnv("FLE_GCP_LOCATION")
340+
gcpKeyRing := GetCheckedEnv("FLE_GCP_KEY_RING")
341+
gcpKeyName := GetCheckedEnv("FLE_GCP_KEY_NAME")
342+
343+
Struct tags are used to pass these values directly to the driver for use. In ``kms/provider.go``
344+
345+
.. code-block:: go
346+
347+
func (g *GCP) DataKeyOpts() interface{} {
348+
return g.dataKeyOpts
349+
}
350+
351+
In ``csfle/data_key.go``
352+
353+
.. code-block:: go
354+
355+
dataKeyOpts := options.DataKey().SetMasterKey(provider.DataKeyOpts())
356+
dataKeyID, err := clientEnc.CreateDataKey(context.TODO(), provider.Name(), dataKeyOpts)
309357
---
310358
title: Update the Automatic Encryption JSON Schema
311359
ref: update-the-json-schema-gcp

0 commit comments

Comments
 (0)