Commit d4b6c8a39f21ba00c683d13154c976dc16d1d0c5

Authored by Alex Mukha
1 parent d34e6bbf5f
Exists in master

Removed hardcoded region from the code.

src/main/java/org/alfresco/heartbeat/service/HeartbeatDAO.java
1 1 package org.alfresco.heartbeat.service;
2 2  
  3 +import com.amazonaws.SDKGlobalConfiguration;
3 4 import com.amazonaws.regions.Region;
4 5 import com.amazonaws.regions.Regions;
5 6 import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
... ... @@ -37,7 +38,8 @@ public class HeartbeatDAO
37 38 public HeartbeatDAO()
38 39 {
39 40 AmazonDynamoDBClient client = new AmazonDynamoDBClient();
40   - client.setRegion(Region.getRegion(Regions.EU_WEST_1));
  41 + String envRegion = System.getenv(SDKGlobalConfiguration.AWS_REGION_ENV_VAR);
  42 + client.setRegion(Region.getRegion(Regions.fromName(envRegion)));
41 43 DynamoDB dynamoDB = new DynamoDB(client);
42 44 table = dynamoDB.getTable(getTableName());
43 45 }
... ...
src/test/java/org/alfresco/heartbeat/service/HeartbeatDAOTest.java
... ... @@ -36,6 +36,7 @@ public class HeartbeatDAOTest
36 36 public static void beforeClass() throws Exception
37 37 {
38 38 AmazonDynamoDBClient client = new AmazonDynamoDBClient();
  39 + // hardcoded region for tests
39 40 client.setRegion(Region.getRegion(Regions.EU_WEST_1));
40 41 dynamoDB = new DynamoDB(client);
41 42 createTable(TABLE_NAME);
... ...