22
33import java .util .HashMap ;
44import java .util .Map ;
5+ import java .util .UUID ;
56import software .amazon .awssdk .core .client .config .ClientOverrideConfiguration ;
67import software .amazon .awssdk .services .dynamodb .DynamoDbClient ;
78import software .amazon .awssdk .services .dynamodb .model .*;
3031 */
3132public class BasicPutGetExample {
3233
33- public static void PutItemGetItem (String kmsKeyId , String ddbTableName ) {
34+ public static void PutItemGetItem (String kmsKeyId , String ddbTableName , String PartitionKeyName ) {
3435 // 1. Create a Keyring. This Keyring will be responsible for protecting the data keys that protect your data.
3536 // For this example, we will create a AWS KMS Keyring with the AWS KMS Key we want to use.
3637 // We will use the `CreateMrkMultiKeyring` method to create this keyring,
@@ -142,7 +143,7 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
142143 final HashMap <String , AttributeValue > item = new HashMap <>();
143144 item .put (
144145 "partition_key" ,
145- AttributeValue .builder ().s ("BasicPutGetExample" ).build ()
146+ AttributeValue .builder ().s (PartitionKeyName ).build ()
146147 );
147148 item .put ("sort_key" , AttributeValue .builder ().n ("0" ).build ());
148149 item .put (
@@ -169,7 +170,7 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
169170 final HashMap <String , AttributeValue > keyToGet = new HashMap <>();
170171 keyToGet .put (
171172 "partition_key" ,
172- AttributeValue .builder ().s ("BasicPutGetExample" ).build ()
173+ AttributeValue .builder ().s (PartitionKeyName ).build ()
173174 );
174175 keyToGet .put ("sort_key" , AttributeValue .builder ().n ("0" ).build ());
175176
@@ -201,6 +202,6 @@ public static void main(final String[] args) {
201202 }
202203 final String kmsKeyId = args [0 ];
203204 final String ddbTableName = args [1 ];
204- PutItemGetItem (kmsKeyId , ddbTableName );
205+ PutItemGetItem (kmsKeyId , ddbTableName , "BasicPutGetExample" );
205206 }
206207}
0 commit comments