Skip to content
This repository was archived by the owner on Jan 10, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions samples/dynamodb-geo-ios/dynamodb-geo-ios/AWSConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@

NSString *const AWSElasticBeanstalkEndpoint = @"http://YOUR-ENVIRONMENT.elasticbeanstalk.com/dynamodb-geo";

/*
* Use this instead to run on a local tomcat instance
*/

//NSString *const AWSElasticBeanstalkEndpoint = @"http://localhost:9090/dynamodb-geo";

@implementation AWSConstants

@end
32 changes: 32 additions & 0 deletions samples/dynamodb-geo-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,37 @@
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<!-- http port -->
<port>9090</port>
<!-- application path always starts with /-->
<path>/</path>
<!-- optional path to a context file -->
<contextFile>${tomcatContextXml}</contextFile>
<!-- optional system propoerties you want to add -->
<systemProperties>
<!--
<AWS_ACCESS_KEY_ID>AKIAJBG2H2TJ5DSDOS6A</AWS_ACCESS_KEY_ID>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please deactivate these credentials ASAP - they're now public. :(

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow. Yeah, I got an email from was and did that. Rookie mistake. Thanks. Seems like for local use you can put any string in there anyway.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, the access key id gets used to name the database file so you can run multiple tests concurrently without them interfering, but the signature isn't actually validated so it doesn't matter if you use an actual access key. Thanks for the contribution, we'll take a look tomorrow!

<AWS_SECRET_KEY>UQi0JRd879IoZNl7dDphme7j4+ZmLE/i2e0NcO62</AWS_SECRET_KEY> -->
<AWS_ACCESS_KEY_ID>XXXXXXXXX</AWS_ACCESS_KEY_ID>
<AWS_SECRET_KEY>YYYYYYYYY</AWS_SECRET_KEY>
<PARAM1>geo-test</PARAM1>
<PARAM2>us-east-1</PARAM2>
<is_local>true</is_local>
</systemProperties>
<!-- if you want to use test dependencies rather than only runtime -->
<useTestClasspath>false</useTestClasspath>
<!-- optional if you want to add some extra directories into the classloader -->
<additionalClasspathDirs>
<additionalClasspathDir></additionalClasspathDir>
</additionalClasspathDirs>
</configuration>

</plugin>
</plugins>
</pluginManagement>

Expand All @@ -120,6 +151,7 @@
</execution>
</executions>
</plugin>

</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,21 @@ public void init() throws ServletException {
}

private void setupGeoDataManager() {
System.out.println("setup");
String accessKey = System.getProperty("AWS_ACCESS_KEY_ID");
String secretKey = System.getProperty("AWS_SECRET_KEY");
String tableName = System.getProperty("PARAM1");
String regionName = System.getProperty("PARAM2");

AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);

AmazonDynamoDBClient ddb = new AmazonDynamoDBClient(credentials);
Region region = Region.getRegion(Regions.fromName(regionName));
ddb.setRegion(region);

if(System.getProperties().containsKey("is_local")) {
ddb.setEndpoint("http://localhost:8000");
}

config = new GeoDataManagerConfiguration(ddb, tableName);
geoDataManager = new GeoDataManager(config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public boolean isRegionNameSet() {
return regionName != null && regionName.length() > 0;
}

public boolean isRunningLocal() {
return System.getProperties().containsKey("is_local");
}

public void setupTable() {
setupGeoDataManager();

Expand Down Expand Up @@ -98,6 +102,10 @@ private synchronized void setupGeoDataManager() {
AmazonDynamoDBClient ddb = new AmazonDynamoDBClient(credentials, clientConfiguration);
ddb.setRegion(region);

if(isRunningLocal()) {
ddb.setEndpoint("http://localhost:8000");
}

GeoDataManagerConfiguration config = new GeoDataManagerConfiguration(ddb, tableName);
geoDataManager = new GeoDataManager(config);
}
Expand Down