Skip to content

Instantly share code, notes, and snippets.

@mikebroberts
Created November 15, 2017 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikebroberts/fa279069066d9a9279e09e01d4de8f07 to your computer and use it in GitHub Desktop.
Save mikebroberts/fa279069066d9a9279e09e01d4de8f07 to your computer and use it in GitHub Desktop.
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
import com.amazonaws.services.dynamodbv2.document.*;
public class MyLambda {
private final DynamoDB dynamoDB;
private final String tableName;
public MyLambda() {
this.dynamoDB = new DynamoDB(AmazonDynamoDBClientBuilder.defaultClient());
this.tableName = System.getenv("LOCATIONS_TABLE");
}
public void handler(java.util.Map<String, String> input) {
Table table = dynamoDB.getTable(tableName);
Item item = new Item()
.withPrimaryKey("id", input.get("ID"))
.withString("value", input.get("value"));
table.putItem(item);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment