Skip to content

Commit 09d07a8

Browse files
author
Michael Wunderlich
committed
read AWS region from CloudFormation via environment variable
1 parent 837bcc1 commit 09d07a8

File tree

7 files changed

+8
-6
lines changed

7 files changed

+8
-6
lines changed

.ebextensions/env.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
option_settings:
2+
aws:elasticbeanstalk:application:environment:
3+
AWS_REGION: '`{"Ref" : "AWS::Region"}`'

src/main/java/scorekeep/Constants.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ public class Constants {
77
public static final String USER_TABLE = "scorekeep-user";
88
public static final String MOVE_TABLE = "scorekeep-move";
99
public static final String STATE_TABLE = "scorekeep-state";
10-
public static final Regions REGION = Regions.US_EAST_1;
1110
}

src/main/java/scorekeep/GameModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
public class GameModel {
2828
/** AWS SDK credentials. */
2929
private AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
30-
.withRegion(Constants.REGION)
30+
.withRegion(Regions.fromName(System.getenv("AWS_REGION")))
3131
.build();
3232
private DynamoDBMapper mapper = new DynamoDBMapper(client);
3333
private SessionModel sessionModel = new SessionModel();

src/main/java/scorekeep/MoveModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
public class MoveModel {
2828
/** AWS SDK credentials. */
2929
private AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
30-
.withRegion(Constants.REGION)
30+
.withRegion(Regions.fromName(System.getenv("AWS_REGION")))
3131
.build();
3232
private DynamoDBMapper mapper = new DynamoDBMapper(client);
3333
private SessionModel sessionModel = new SessionModel();

src/main/java/scorekeep/SessionModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class SessionModel {
1717

1818
/** AWS SDK credentials. */
1919
private AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
20-
.withRegion(Constants.REGION)
20+
.withRegion(Regions.fromName(System.getenv("AWS_REGION")))
2121
.build();
2222
private DynamoDBMapper mapper = new DynamoDBMapper(client);
2323

src/main/java/scorekeep/StateModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
public class StateModel {
3232
/** AWS SDK credentials. */
3333
private AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
34-
.withRegion(Constants.REGION)
34+
.withRegion(Regions.fromName(System.getenv("AWS_REGION")))
3535
.build();
3636
private DynamoDBMapper mapper = new DynamoDBMapper(client);
3737
private SessionModel sessionModel = new SessionModel();

src/main/java/scorekeep/UserModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
public class UserModel {
1717
/** AWS SDK credentials. */
1818
private AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
19-
.withRegion(Constants.REGION)
19+
.withRegion(Regions.fromName(System.getenv("AWS_REGION")))
2020
.build();
2121
private DynamoDBMapper mapper = new DynamoDBMapper(client);
2222

0 commit comments

Comments
 (0)