这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Mar 4, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public class BasicSimianArmyContext implements Monkey.Context {
/** If configured, the ARN of Role to be assumed. */
private final String assumeRoleArn;

private final String accountName;

private final String account;

private final String secret;
Expand All @@ -103,6 +105,7 @@ 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");

assumeRoleArn = config.getStr("simianarmy.client.aws.assumeRoleArn");
Expand Down Expand Up @@ -197,6 +200,14 @@ public String region() {
return region;
}

/**
* Gets the accountName
* @return the accountName
*/
public String accountName() {
return accountName;
}

@Override
public void reportEvent(Event evt) {
this.eventReport.add(evt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class BasicJanitorMonkey extends JanitorMonkey {

private final String region;

private final String accountName;

private final JanitorResourceTracker resourceTracker;

private final MonkeyRecorder recorder;
Expand All @@ -72,6 +74,7 @@ public BasicJanitorMonkey(Context ctx) {
janitors = ctx.janitors();
emailNotifier = ctx.emailNotifier();
region = ctx.region();
accountName = ctx.accountName();
resourceTracker = ctx.resourceTracker();
recorder = ctx.recorder();
calendar = ctx.calendar();
Expand Down Expand Up @@ -192,7 +195,7 @@ private String printResources(Collection<Resource> resources) {
* @return the subject of the summary email
*/
protected String getSummaryEmailSubject() {
return String.format("Janitor monkey execution summary (%s)", region);
return String.format("Janitor monkey execution summary (%s, %s)", accountName, region);
}

/**
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/netflix/simianarmy/client/aws/AWSClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ public class AWSClient implements CloudClient {
/** The region. */
private final String region;

/** The plain name for AWS account */
private final String accountName;

private final AWSCredentialsProvider awsCredentialsProvider;

private ComputeService jcloudsComputeService;
Expand Down Expand Up @@ -152,6 +155,7 @@ public class AWSClient implements CloudClient {
*/
public AWSClient(String region) {
this.region = region;
this.accountName = "Default";
this.awsCredentialsProvider = null;
}

Expand All @@ -164,6 +168,7 @@ public AWSClient(String region) {
*/
public AWSClient(String region, AWSCredentialsProvider awsCredentialsProvider) {
this.region = region;
this.accountName = "Default";
this.awsCredentialsProvider = awsCredentialsProvider;
}

Expand All @@ -176,6 +181,16 @@ public String region() {
return region;
}

/**
* The accountName.
*
* @accountName the plain name for the aws account easier to identify which account
* monkey is running in
*/
public String accountName() {
return accountName;
}

/**
* Amazon EC2 client. Abstracted to aid testing.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ public interface Context extends Monkey.Context {
*/
String region();

/**
* The accountName the monkey is running in.
* @return the accountName the monkey is running in.
*/
String accountName();

/**
* The Janitor resource tracker.
* @return the Janitor resource tracker.
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/client.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#simianarmy.client.aws.secretKey = fakeSecret
simianarmy.client.aws.region = us-west-1

### Common account name to make it easier to identify emails by subject
simianarmy.client.aws.accountName = default

### To operate under an assumed role - the role will be assumed for all activity, sts:AssumeRole
### action must be allowed for the inital IAM role being used (long lived credentials)
### http://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html
Expand All @@ -44,4 +47,4 @@ simianarmy.client.aws.region = us-west-1
### Operate in Cloud Formation mode - the random suffix appended to Auto Scaling Group names is ignored
### (specify ASG names as usual with no suffix in chaos.properties)
#
#simianarmy.client.chaos.class=com.netflix.simianarmy.basic.chaos.CloudFormationChaosMonkey
#simianarmy.client.chaos.class=com.netflix.simianarmy.basic.chaos.CloudFormationChaosMonkey
3 changes: 2 additions & 1 deletion src/test/resources/client.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
simianarmy.client.aws.accountKey = fakeAccount
simianarmy.client.aws.secretKey = fakeSecret
simianarmy.client.aws.assumeRoleArn = arn:aws:iam::fakeAccount:role/fakeRole
simianarmy.client.aws.assumeRoleArn = arn:aws:iam::fakeAccount:role/fakeRole
simianarmy.client.aws.accountName = default