Skip to content

Commit e5250e7

Browse files
auto commit
1 parent f882e00 commit e5250e7

File tree

1 file changed

+8
-11
lines changed
  • Examples/runtimes/go/migration/PlaintextToAWSDBE/awsdbe

1 file changed

+8
-11
lines changed

Examples/runtimes/go/migration/PlaintextToAWSDBE/awsdbe/step3.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
package awsdbe
22

33
import (
4-
// Standard imports
54
"context"
65
"fmt"
76

8-
// AWS SDK imports
9-
107
"github.com/aws/aws-sdk-go-v2/aws"
118
"github.com/aws/aws-sdk-go-v2/config"
129
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
1310
"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
1411

1512
dbesdkdynamodbencryptiontypes "github.com/aws/aws-database-encryption-sdk-dynamodb/releases/go/dynamodb-esdk/awscryptographydbencryptionsdkdynamodbsmithygeneratedtypes"
1613
"github.com/aws/aws-database-encryption-sdk-dynamodb/releases/go/dynamodb-esdk/dbesdkmiddleware"
14+
plaintexttoawsdbe "github.com/aws/aws-database-encryption-sdk-dynamodb/releases/go/dynamodb-esdk/examples/migration/PlaintextToAWSDBE"
1715
"github.com/aws/aws-database-encryption-sdk-dynamodb/releases/go/dynamodb-esdk/examples/utils"
1816
)
1917

@@ -64,12 +62,14 @@ func MigrationStep3(kmsKeyID, ddbTableName, partitionKeyValue, sortKeyWriteValue
6462
// 3. Put an item into your table.
6563
// This item will be encrypted.
6664
encryptedAndSignedValue := "this will be encrypted and signed"
65+
signOnlyValue := "this will never be encrypted, but it will be signed"
66+
doNothingValue := "this will never be encrypted nor signed"
6767
item := map[string]types.AttributeValue{
6868
"partition_key": &types.AttributeValueMemberS{Value: partitionKeyValue},
6969
"sort_key": &types.AttributeValueMemberN{Value: sortKeyWriteValue},
7070
"attribute1": &types.AttributeValueMemberS{Value: encryptedAndSignedValue},
71-
"attribute2": &types.AttributeValueMemberS{Value: "this will never be encrypted, but it will be signed"},
72-
"attribute3": &types.AttributeValueMemberS{Value: "this will never be encrypted nor signed"},
71+
"attribute2": &types.AttributeValueMemberS{Value: signOnlyValue},
72+
"attribute3": &types.AttributeValueMemberS{Value: doNothingValue},
7373
}
7474

7575
putInput := dynamodb.PutItemInput{
@@ -110,13 +110,10 @@ func MigrationStep3(kmsKeyID, ddbTableName, partitionKeyValue, sortKeyWriteValue
110110
}
111111

112112
// Verify we got the expected item back
113-
if partitionKeyValue != result.Item["partition_key"].(*types.AttributeValueMemberS).Value {
114-
panic("Decrypted item does not match original item")
115-
}
116-
if encryptedAndSignedValue != result.Item["attribute1"].(*types.AttributeValueMemberS).Value {
117-
panic("Decrypted item does not match original item")
113+
err = plaintexttoawsdbe.VerifyReturnedItem(result, partitionKeyValue, sortKeyReadValue, encryptedAndSignedValue, signOnlyValue, doNothingValue)
114+
if err != nil {
115+
return err
118116
}
119117
fmt.Println("MigrationStep3 completed successfully")
120-
121118
return nil
122119
}

0 commit comments

Comments
 (0)