@@ -29,7 +29,7 @@ func GetEncryptedDataKeyDescriptionExample(kmsKeyID, ddbTableName string) {
29
29
// 2. Create a Amazon DynamoDB Client and retrieve item from DynamoDB table
30
30
ddb := dynamodb .NewFromConfig (cfg )
31
31
32
- // 3. Get the item from the dynamoDB table and prepare input for the GetEncryptedDataKeyDescription method.
32
+ // 3. Extract the item from the dynamoDB table and prepare input for the GetEncryptedDataKeyDescription method.
33
33
// Here, we are sending dynamodb item but you can also input the header itself by extracting the header from
34
34
// "aws_dbe_head" attribute in the dynamoDB item. The part of the code where we send input as the header is commented.
35
35
getInput := & dynamodb.GetItemInput {
@@ -44,9 +44,16 @@ func GetEncryptedDataKeyDescriptionExample(kmsKeyID, ddbTableName string) {
44
44
}
45
45
returnedItem , err := ddb .GetItem (context .TODO (), getInput )
46
46
utils .HandleError (err )
47
-
48
- inputUnion := dbesdkdynamodbencryptiontypes.GetEncryptedDataKeyDescriptionUnionMemberitem {
49
- Value : returnedItem .Item ,
47
+ // inputUnion := dbesdkdynamodbencryptiontypes.GetEncryptedDataKeyDescriptionUnionMemberitem{
48
+ // Value: returnedItem.Item,
49
+ // }
50
+ headerAttribute := "aws_dbe_head"
51
+ headerBytes , ok := returnedItem .Item [headerAttribute ].(* types.AttributeValueMemberB )
52
+ if ! ok {
53
+ panic ("attribute1 is not binary. It might not be encrypted." )
54
+ }
55
+ inputUnion := dbesdkdynamodbencryptiontypes.GetEncryptedDataKeyDescriptionUnionMemberheader {
56
+ Value : headerBytes .Value ,
50
57
}
51
58
encryptedDataKeyDescriptionInput := dbesdkdynamodbencryptiontypes.GetEncryptedDataKeyDescriptionInput {
52
59
Input : & inputUnion ,
0 commit comments