Skip to content

Commit 4b90a21

Browse files
auto commit
1 parent 77f015d commit 4b90a21

File tree

4 files changed

+470
-22
lines changed

4 files changed

+470
-22
lines changed

Examples/runtimes/go/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/aws/aws-database-encryption-sdk-dynamodb/examples/itemencryptor"
88
"github.com/aws/aws-database-encryption-sdk-dynamodb/examples/keyring"
99
"github.com/aws/aws-database-encryption-sdk-dynamodb/examples/misc"
10+
"github.com/aws/aws-database-encryption-sdk-dynamodb/examples/searchableencryption"
1011
"github.com/aws/aws-database-encryption-sdk-dynamodb/examples/utils"
1112
)
1213

@@ -61,4 +62,11 @@ func main() {
6162
itemencryptor.ItemEncryptDecryptExample(
6263
utils.KmsKeyID(),
6364
utils.DdbTableName())
65+
66+
// searchable encryption example
67+
searchableencryption.BasicSearchableEncryptionExample(
68+
utils.UnitInspectionTestDdbTableName(),
69+
branchKey1,
70+
utils.TestKeystoreKmsKeyId(),
71+
utils.TestKeystoreName())
6472
}

Examples/runtimes/go/searchableencryption/basicsearchableencryptionexample.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ This example follows a use case of a database that stores unit inspection inform
3131
3232
Running this example requires access to a DDB table with the
3333
following key configuration:
34-
- Partition key is named partitionKeyName with type (S)
35-
- Sort key is named sortKey with type (S)
34+
- Partition key is named "work_id" with type (S)
35+
- Sort key is named "inspection_date" with type (S)
3636
3737
This table must have a Global Secondary Index (GSI) configured named "last4-unit-index":
3838
- Partition key is named "aws_dbe_b_inspector_id_last4" with type (S)
3939
- Sort key is named "aws_dbe_b_unit" with type (S)
4040
4141
In this example for storing unit inspection information, this schema is utilized for the data:
42-
- partitionKeyName stores a unique identifier for a unit inspection work order (v4 UUID)
43-
- sortKey stores an ISO 8601 date for the inspection (YYYY-MM-DD)
42+
- "work_id" stores a unique identifier for a unit inspection work order (v4 UUID)
43+
- "inspection_date" stores an ISO 8601 date for the inspection (YYYY-MM-DD)
4444
- "inspector_id_last4" stores the last 4 digits of the ID of the inspector performing the work
4545
- "unit" stores a 12-digit serial number for the unit being inspected
4646
@@ -59,7 +59,7 @@ func BasicSearchableEncryptionExample(
5959
branchKeyDdbTableName string) {
6060
const gsiName = "last4-unit-index"
6161
partitionKeyName := "work_id"
62-
sortKey := "inspection_date"
62+
sortKeyName := "inspection_date"
6363
// 1. Configure Beacons.
6464
// The beacon name must be the name of a table attribute that will be encrypted.
6565
// The `length` parameter dictates how many bits are in the beacon attribute value.
@@ -238,7 +238,7 @@ func BasicSearchableEncryptionExample(
238238
// Any attributes that will be used in beacons must be configured as ENCRYPT_AND_SIGN.
239239
attributeActionsOnEncrypt := map[string]dbesdkstructuredencryptiontypes.CryptoAction{
240240
partitionKeyName: dbesdkstructuredencryptiontypes.CryptoActionSignOnly, // Our partition attribute must be SIGN_ONLY
241-
sortKey: dbesdkstructuredencryptiontypes.CryptoActionSignOnly, // Our sort attribute must be SIGN_ONLY
241+
sortKeyName: dbesdkstructuredencryptiontypes.CryptoActionSignOnly, // Our sort attribute must be SIGN_ONLY
242242
"inspector_id_last4": dbesdkstructuredencryptiontypes.CryptoActionEncryptAndSign, // Beaconized attributes must be encrypted
243243
"unit": dbesdkstructuredencryptiontypes.CryptoActionEncryptAndSign, // Beaconized attributes must be encrypted
244244
}
@@ -254,7 +254,7 @@ func BasicSearchableEncryptionExample(
254254
tableConfig := dbesdkdynamodbencryptiontypes.DynamoDbTableEncryptionConfig{
255255
LogicalTableName: ddbTableName,
256256
PartitionKeyName: partitionKeyName,
257-
SortKeyName: &sortKey,
257+
SortKeyName: &sortKeyName,
258258
AttributeActionsOnEncrypt: attributeActionsOnEncrypt,
259259
Keyring: kmsKeyring,
260260
Search: &searchConfig,
@@ -285,7 +285,7 @@ func BasicSearchableEncryptionExample(
285285
// aws_dbe_b_unit = truncate(HMAC("123456789012"), 30)
286286
item := map[string]types.AttributeValue{
287287
partitionKeyName: &types.AttributeValueMemberS{Value: "1313ba89-5661-41eb-ba6c-cb1b4cb67b2d"},
288-
sortKey: &types.AttributeValueMemberS{Value: "2023-06-13"},
288+
sortKeyName: &types.AttributeValueMemberS{Value: "2023-06-13"},
289289
"inspector_id_last4": &types.AttributeValueMemberS{Value: "4321"},
290290
"unit": &types.AttributeValueMemberS{Value: "123456789012"},
291291
}

0 commit comments

Comments
 (0)