Skip to content

Commit bb24640

Browse files
test commented code
1 parent 2a45f6a commit bb24640

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Examples/runtimes/go/misc/getEncryptedDataKeyDescription.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func GetEncryptedDataKeyDescriptionExample(kmsKeyID, ddbTableName string) {
2929
// 2. Create a Amazon DynamoDB Client and retrieve item from DynamoDB table
3030
ddb := dynamodb.NewFromConfig(cfg)
3131

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.
3333
// Here, we are sending dynamodb item but you can also input the header itself by extracting the header from
3434
// "aws_dbe_head" attribute in the dynamoDB item. The part of the code where we send input as the header is commented.
3535
getInput := &dynamodb.GetItemInput{
@@ -44,9 +44,16 @@ func GetEncryptedDataKeyDescriptionExample(kmsKeyID, ddbTableName string) {
4444
}
4545
returnedItem, err := ddb.GetItem(context.TODO(), getInput)
4646
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,
5057
}
5158
encryptedDataKeyDescriptionInput := dbesdkdynamodbencryptiontypes.GetEncryptedDataKeyDescriptionInput{
5259
Input: &inputUnion,

0 commit comments

Comments
 (0)