Skip to content

Commit 61c4391

Browse files
authored
go aws csfle (#707)
* go aws csfle * pr feedback Co-authored-by: Nathan Leniz <[email protected]>
1 parent cca4b11 commit 61c4391

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,26 @@ content: |
134134
To use the AWS Key Vault, you must use
135135
`libmongocrypt <https://github.com/mongodb/libmongocrypt#installing-libmongocrypt-on-windows>`__ version 1.0 or later in your application's environment.
136136
137+
.. tab::
138+
:tabid: go
139+
140+
In ``kms/provider.go``, update the variable declarations or define the expected environmental variables in
141+
``AWSProvider()``.
142+
143+
.. code-block:: go
144+
145+
awsAccessKeyID := GetCheckedEnv("FLE_AWS_ACCESS_KEY")
146+
awsSecretAccessKey := GetCheckedEnv("FLE_AWS_SECRET_ACCESS_KEY")
147+
148+
The expected KMS provider map is created with struct tags.
149+
150+
.. code-block:: go
151+
152+
func (a *AWS) Credentials() map[string]map[string]interface{} {
153+
return map[string]map[string]interface{}{"aws": structs.Map(a.credentials)}
154+
}
155+
156+
137157
---
138158
title: Create a New Data Encryption Key
139159
ref: create-a-new-data-key
@@ -293,6 +313,32 @@ content: |
293313
To use the AWS Key Vault, you must use
294314
`libmongocrypt <https://github.com/mongodb/libmongocrypt#installing-libmongocrypt-on-windows>`__ version 1.0 or later in your application's environment.
295315
316+
.. tab::
317+
:tabid: go
318+
319+
In ``kms/provider.go``, update the variable declarations or define the expected environmental variables
320+
in ``AWSProvider()``.
321+
322+
.. code-block:: go
323+
324+
awsKeyARN := GetCheckedEnv("FLE_AWS_KEY_ARN")
325+
awsKeyRegion := GetCheckedEnv("FLE_AWS_KEY_REGION")
326+
327+
Struct tags are used to pass these values directly to the driver for use. In ``kms/provider.go``
328+
329+
.. code-block:: go
330+
331+
func (a *AWS) DataKeyOpts() interface{} {
332+
return a.dataKeyOpts
333+
}
334+
335+
In ``csfle/data_key.go``
336+
337+
.. code-block:: go
338+
339+
dataKeyOpts := options.DataKey().SetMasterKey(provider.DataKeyOpts())
340+
dataKeyID, err := clientEnc.CreateDataKey(context.TODO(), provider.Name(), dataKeyOpts)
341+
296342
---
297343
title: Update the Automatic Encryption JSON Schema
298344
ref: update-the-json-schema

0 commit comments

Comments
 (0)