Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

Commit

Permalink
Merge pull request #233 from Ten48BASE/master
Browse files Browse the repository at this point in the history
Adding AWS region detection.
  • Loading branch information
ebukoski committed Jan 28, 2016
2 parents 6c6adff + 450fc0a commit 6347c9c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import com.amazonaws.ClientConfiguration;
import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;

import com.netflix.simianarmy.CloudClient;
import com.netflix.simianarmy.Monkey;
Expand Down Expand Up @@ -126,7 +128,15 @@ protected BasicSimianArmyContext(String... configFiles) {
account = config.getStr("simianarmy.client.aws.accountKey");
secret = config.getStr("simianarmy.client.aws.secretKey");
accountName = config.getStrOrElse("simianarmy.client.aws.accountName", "Default");
region = config.getStrOrElse("simianarmy.client.aws.region", "us-east-1");

String defaultRegion = "us-east-1";
Region currentRegion = Regions.getCurrentRegion();

if (currentRegion != null) {
defaultRegion = currentRegion.getName();
}

region = config.getStrOrElse("simianarmy.client.aws.region", defaultRegion);
GLOBAL_OWNER_TAGKEY = config.getStrOrElse("simianarmy.tags.owner", "owner");

// Check for and configure optional proxy configuration
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/client.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
### see: http://docs.aws.amazon.com/AWSSdkDocsJava/latest/DeveloperGuide/java-dg-roles.html
#simianarmy.client.aws.accountKey = fakeAccount
#simianarmy.client.aws.secretKey = fakeSecret
### Comment out the following line to detect the AWS region where the instance is running
simianarmy.client.aws.region = us-west-1

### Common account name to make it easier to identify emails by subject
Expand Down

0 comments on commit 6347c9c

Please sign in to comment.