2
2
3
3
import java .util .HashMap ;
4
4
import java .util .Map ;
5
+ import java .util .UUID ;
5
6
import software .amazon .awssdk .core .client .config .ClientOverrideConfiguration ;
6
7
import software .amazon .awssdk .services .dynamodb .DynamoDbClient ;
7
8
import software .amazon .awssdk .services .dynamodb .model .*;
30
31
*/
31
32
public class BasicPutGetExample {
32
33
33
- public static void PutItemGetItem (String kmsKeyId , String ddbTableName ) {
34
+ public static void PutItemGetItem (String kmsKeyId , String ddbTableName , String PartitionKeyName ) {
34
35
// 1. Create a Keyring. This Keyring will be responsible for protecting the data keys that protect your data.
35
36
// For this example, we will create a AWS KMS Keyring with the AWS KMS Key we want to use.
36
37
// We will use the `CreateMrkMultiKeyring` method to create this keyring,
@@ -142,7 +143,7 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
142
143
final HashMap <String , AttributeValue > item = new HashMap <>();
143
144
item .put (
144
145
"partition_key" ,
145
- AttributeValue .builder ().s ("BasicPutGetExample" ).build ()
146
+ AttributeValue .builder ().s (PartitionKeyName ).build ()
146
147
);
147
148
item .put ("sort_key" , AttributeValue .builder ().n ("0" ).build ());
148
149
item .put (
@@ -169,7 +170,7 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
169
170
final HashMap <String , AttributeValue > keyToGet = new HashMap <>();
170
171
keyToGet .put (
171
172
"partition_key" ,
172
- AttributeValue .builder ().s ("BasicPutGetExample" ).build ()
173
+ AttributeValue .builder ().s (PartitionKeyName ).build ()
173
174
);
174
175
keyToGet .put ("sort_key" , AttributeValue .builder ().n ("0" ).build ());
175
176
@@ -201,6 +202,6 @@ public static void main(final String[] args) {
201
202
}
202
203
final String kmsKeyId = args [0 ];
203
204
final String ddbTableName = args [1 ];
204
- PutItemGetItem (kmsKeyId , ddbTableName );
205
+ PutItemGetItem (kmsKeyId , ddbTableName , "BasicPutGetExample" );
205
206
}
206
207
}
0 commit comments