@@ -31,16 +31,16 @@ This example follows a use case of a database that stores unit inspection inform
3131
3232Running this example requires access to a DDB table with the
3333following key configuration:
34- - Partition key is named "work_id" with type (S)
35- - Sort key is named "inspection_date" with type (S)
34+ - Partition key is named partitionKeyName with type (S)
35+ - Sort key is named sortKey with type (S)
3636
3737This 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
4141In this example for storing unit inspection information, this schema is utilized for the data:
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)
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)
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
@@ -58,7 +58,8 @@ func BasicSearchableEncryptionExample(
5858 branchKeyWrappingKmsKeyArn ,
5959 branchKeyDdbTableName string ) {
6060 const gsiName = "last4-unit-index"
61-
61+ partitionKeyName := "work_id"
62+ sortKey := "inspection_date"
6263 // 1. Configure Beacons.
6364 // The beacon name must be the name of a table attribute that will be encrypted.
6465 // The `length` parameter dictates how many bits are in the beacon attribute value.
@@ -236,8 +237,8 @@ func BasicSearchableEncryptionExample(
236237 // - DO_NOTHING: The attribute is not encrypted and not included in the signature
237238 // Any attributes that will be used in beacons must be configured as ENCRYPT_AND_SIGN.
238239 attributeActionsOnEncrypt := map [string ]dbesdkstructuredencryptiontypes.CryptoAction {
239- "work_id" : dbesdkstructuredencryptiontypes .CryptoActionSignOnly , // Our partition attribute must be SIGN_ONLY
240- "inspection_date" : dbesdkstructuredencryptiontypes .CryptoActionSignOnly , // Our sort attribute must be SIGN_ONLY
240+ partitionKeyName : dbesdkstructuredencryptiontypes .CryptoActionSignOnly , // Our partition attribute must be SIGN_ONLY
241+ sortKey : dbesdkstructuredencryptiontypes .CryptoActionSignOnly , // Our sort attribute must be SIGN_ONLY
241242 "inspector_id_last4" : dbesdkstructuredencryptiontypes .CryptoActionEncryptAndSign , // Beaconized attributes must be encrypted
242243 "unit" : dbesdkstructuredencryptiontypes .CryptoActionEncryptAndSign , // Beaconized attributes must be encrypted
243244 }
@@ -252,8 +253,8 @@ func BasicSearchableEncryptionExample(
252253
253254 tableConfig := dbesdkdynamodbencryptiontypes.DynamoDbTableEncryptionConfig {
254255 LogicalTableName : ddbTableName ,
255- PartitionKeyName : "work_id" ,
256- SortKeyName : aws . String ( "inspection_date" ) ,
256+ PartitionKeyName : partitionKeyName ,
257+ SortKeyName : & sortKey ,
257258 AttributeActionsOnEncrypt : attributeActionsOnEncrypt ,
258259 Keyring : kmsKeyring ,
259260 Search : & searchConfig ,
@@ -283,8 +284,8 @@ func BasicSearchableEncryptionExample(
283284 // aws_dbe_b_inspector_id_last4 = truncate(HMAC("4321"), 10)
284285 // aws_dbe_b_unit = truncate(HMAC("123456789012"), 30)
285286 item := map [string ]types.AttributeValue {
286- "work_id" : & types.AttributeValueMemberS {Value : "1313ba89-5661-41eb-ba6c-cb1b4cb67b2d" },
287- "inspection_date" : & types.AttributeValueMemberS {Value : "2023-06-13" },
287+ partitionKeyName : & types.AttributeValueMemberS {Value : "1313ba89-5661-41eb-ba6c-cb1b4cb67b2d" },
288+ sortKey : & types.AttributeValueMemberS {Value : "2023-06-13" },
288289 "inspector_id_last4" : & types.AttributeValueMemberS {Value : "4321" },
289290 "unit" : & types.AttributeValueMemberS {Value : "123456789012" },
290291 }
0 commit comments