Fix #36 Avoid failure on start due to CreateTable

Current implementation uses a ResourceInUse side-effect to detect that the table already exists.
This requires that the user/role running the KCL have the CreateTable permission.  Update the
LeaseManager to check if the table exists to allow limited privilege users to run KCL code.
This commit is contained in:
Brian M. Carr 2016-05-09 11:40:50 -05:00
parent 74c259ca11
commit 620d36559d

View file

@ -115,6 +115,9 @@ public class LeaseManager<T extends Lease> implements ILeaseManager<T> {
request.setProvisionedThroughput(throughput); request.setProvisionedThroughput(throughput);
try { try {
if (leaseTableExists()) {
return false;
}
dynamoDBClient.createTable(request); dynamoDBClient.createTable(request);
} catch (ResourceInUseException e) { } catch (ResourceInUseException e) {
tableDidNotExist = false; tableDidNotExist = false;