|
1 | 1 | package awsdbe |
2 | 2 |
|
3 | 3 | import ( |
4 | | - // Standard imports |
5 | 4 | "context" |
6 | 5 | "fmt" |
7 | 6 |
|
8 | | - // AWS SDK imports |
9 | | - |
10 | 7 | "github.com/aws/aws-sdk-go-v2/aws" |
11 | 8 | "github.com/aws/aws-sdk-go-v2/config" |
12 | 9 | "github.com/aws/aws-sdk-go-v2/service/dynamodb" |
13 | 10 | "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" |
14 | 11 |
|
15 | 12 | dbesdkdynamodbencryptiontypes "github.com/aws/aws-database-encryption-sdk-dynamodb/releases/go/dynamodb-esdk/awscryptographydbencryptionsdkdynamodbsmithygeneratedtypes" |
16 | 13 | "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" |
17 | 15 | "github.com/aws/aws-database-encryption-sdk-dynamodb/releases/go/dynamodb-esdk/examples/utils" |
18 | 16 | ) |
19 | 17 |
|
@@ -64,12 +62,14 @@ func MigrationStep3(kmsKeyID, ddbTableName, partitionKeyValue, sortKeyWriteValue |
64 | 62 | // 3. Put an item into your table. |
65 | 63 | // This item will be encrypted. |
66 | 64 | 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" |
67 | 67 | item := map[string]types.AttributeValue{ |
68 | 68 | "partition_key": &types.AttributeValueMemberS{Value: partitionKeyValue}, |
69 | 69 | "sort_key": &types.AttributeValueMemberN{Value: sortKeyWriteValue}, |
70 | 70 | "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}, |
73 | 73 | } |
74 | 74 |
|
75 | 75 | putInput := dynamodb.PutItemInput{ |
@@ -110,13 +110,10 @@ func MigrationStep3(kmsKeyID, ddbTableName, partitionKeyValue, sortKeyWriteValue |
110 | 110 | } |
111 | 111 |
|
112 | 112 | // 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 |
118 | 116 | } |
119 | 117 | fmt.Println("MigrationStep3 completed successfully") |
120 | | - |
121 | 118 | return nil |
122 | 119 | } |
0 commit comments