This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add commands to bootstrap and enable audit logging (#117)
Add commands to bootstrap and enable audit logging
- Loading branch information
Showing
31 changed files
with
888 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ | |
|
||
group=com.nike | ||
artifactId=cerberus-lifecycle-cli | ||
version=4.0.0 | ||
version=4.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/nike/cerberus/client/aws/AthenaAwsClientFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.nike.cerberus.client.aws; | ||
|
||
import com.amazonaws.regions.Regions; | ||
import com.amazonaws.services.athena.AmazonAthenaClient; | ||
import com.nike.cerberus.service.AwsClientFactory; | ||
|
||
public class AthenaAwsClientFactory extends AwsClientFactory<AmazonAthenaClient> { | ||
|
||
@Override | ||
public AmazonAthenaClient getClient(Regions region) { | ||
if (!clients.containsKey(region)) { | ||
clients.put(region, createClient(region)); | ||
} | ||
return clients.get(region); | ||
} | ||
|
||
private AmazonAthenaClient createClient(Regions region) { | ||
return (AmazonAthenaClient) AmazonAthenaClient.builder() | ||
.withRegion(region) | ||
.withCredentials(getAWSCredentialsProviderChain()) | ||
.build(); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/nike/cerberus/command/audit/CreateAuditAthenaDbAndTableCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.nike.cerberus.command.audit; | ||
|
||
import com.beust.jcommander.Parameters; | ||
import com.nike.cerberus.command.Command; | ||
import com.nike.cerberus.operation.Operation; | ||
import com.nike.cerberus.operation.audit.CreateAuditAthenaDbAndTableOperation; | ||
|
||
import static com.nike.cerberus.command.audit.CreateAuditAthenaDbAndTableCommand.COMMAND_NAME; | ||
|
||
@Parameters( | ||
commandNames = COMMAND_NAME, | ||
commandDescription = "Creates the db and table needed in athena to enable interacting with the audit data via athena" | ||
) | ||
public class CreateAuditAthenaDbAndTableCommand implements Command { | ||
|
||
public static final String COMMAND_NAME = "create-audit-log-athena-db-and-table"; | ||
|
||
@Override | ||
public String getCommandName() { | ||
return COMMAND_NAME; | ||
} | ||
|
||
@Override | ||
public Class<? extends Operation<?>> getOperationClass() { | ||
return CreateAuditAthenaDbAndTableOperation.class; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/com/nike/cerberus/command/audit/CreateAuditLoggingStackCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.nike.cerberus.command.audit; | ||
|
||
import com.beust.jcommander.Parameter; | ||
import com.beust.jcommander.Parameters; | ||
import com.beust.jcommander.ParametersDelegate; | ||
import com.nike.cerberus.command.Command; | ||
import com.nike.cerberus.domain.cloudformation.TagParametersDelegate; | ||
import com.nike.cerberus.operation.Operation; | ||
import com.nike.cerberus.operation.audit.CreateAuditStackOperation; | ||
|
||
import static com.nike.cerberus.command.audit.CreateAuditLoggingStackCommand.COMMAND_NAME; | ||
|
||
@Parameters( | ||
commandNames = COMMAND_NAME, | ||
commandDescription = "Creates an S3 bucket and IAM roles configured to allow CMS to write audit log data and " + | ||
"IAM role that allows AWS Athena/Glue queries" | ||
) | ||
public class CreateAuditLoggingStackCommand implements Command { | ||
|
||
public static final String COMMAND_NAME = "create-audit-logging-stack"; | ||
|
||
public static final String ADMIN_ROLE_ARN_LONG_ARG = "--admin-role-arn"; | ||
|
||
@Parameter( | ||
names = ADMIN_ROLE_ARN_LONG_ARG, | ||
description = "An IAM role ARN that will be given elevated privileges for the KMS CMKs created.", | ||
required = true | ||
) | ||
private String adminRoleArn; | ||
|
||
public String getAdminRoleArn() { | ||
return adminRoleArn; | ||
} | ||
|
||
@ParametersDelegate | ||
private TagParametersDelegate tagsDelegate = new TagParametersDelegate(); | ||
|
||
public TagParametersDelegate getTagsDelegate() { | ||
return tagsDelegate; | ||
} | ||
|
||
@Override | ||
public String getCommandName() { | ||
return COMMAND_NAME; | ||
} | ||
|
||
@Override | ||
public Class<? extends Operation<?>> getOperationClass() { | ||
return CreateAuditStackOperation.class; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/nike/cerberus/command/audit/DisableAuditLoggingCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.nike.cerberus.command.audit; | ||
|
||
import com.beust.jcommander.Parameters; | ||
import com.nike.cerberus.command.Command; | ||
import com.nike.cerberus.operation.Operation; | ||
import com.nike.cerberus.operation.audit.DisableAuditLoggingOperation; | ||
|
||
import static com.nike.cerberus.command.audit.DisableAuditLoggingCommand.COMMAND_NAME; | ||
|
||
@Parameters( | ||
commandNames = COMMAND_NAME, | ||
commandDescription = "Disables the CLI to set the required CMS properties to enable audit logging, when creating or updating CMS config" | ||
) | ||
public class DisableAuditLoggingCommand implements Command { | ||
|
||
public static final String COMMAND_NAME = "disable-audit-logging"; | ||
|
||
@Override | ||
public String getCommandName() { | ||
return COMMAND_NAME; | ||
} | ||
|
||
@Override | ||
public Class<? extends Operation<?>> getOperationClass() { | ||
return DisableAuditLoggingOperation.class; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/nike/cerberus/command/audit/EnableAuditLoggingCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.nike.cerberus.command.audit; | ||
|
||
import com.beust.jcommander.Parameters; | ||
import com.nike.cerberus.command.Command; | ||
import com.nike.cerberus.operation.Operation; | ||
import com.nike.cerberus.operation.audit.EnableAuditLoggingOperation; | ||
|
||
import static com.nike.cerberus.command.audit.EnableAuditLoggingCommand.COMMAND_NAME; | ||
|
||
@Parameters( | ||
commandNames = COMMAND_NAME, | ||
commandDescription = "Enables the CLI to set the required CMS properties to enable audit logging, when creating or updating CMS config" | ||
) | ||
public class EnableAuditLoggingCommand implements Command { | ||
|
||
public static final String COMMAND_NAME = "enable-audit-logging"; | ||
|
||
@Override | ||
public String getCommandName() { | ||
return COMMAND_NAME; | ||
} | ||
|
||
@Override | ||
public Class<? extends Operation<?>> getOperationClass() { | ||
return EnableAuditLoggingOperation.class; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...java/com/nike/cerberus/command/audit/EnableAuditLoggingForExistingEnvironmentCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.nike.cerberus.command.audit; | ||
|
||
import com.beust.jcommander.Parameters; | ||
import com.nike.cerberus.command.Command; | ||
import com.nike.cerberus.operation.Operation; | ||
import com.nike.cerberus.operation.audit.EnableAuditLoggingForExistingEnvironmentOperation; | ||
|
||
import static com.nike.cerberus.command.audit.EnableAuditLoggingForExistingEnvironmentCommand.COMMAND_DESCRIPTION; | ||
import static com.nike.cerberus.command.audit.EnableAuditLoggingForExistingEnvironmentCommand.COMMAND_NAME; | ||
|
||
@Parameters( | ||
commandNames = COMMAND_NAME, | ||
commandDescription = COMMAND_DESCRIPTION | ||
) | ||
public class EnableAuditLoggingForExistingEnvironmentCommand implements Command { | ||
|
||
public static final String COMMAND_NAME = "enable-audit-logging-for-existing-environment"; | ||
public static final String COMMAND_DESCRIPTION = | ||
"A Composite command that will will execute the following commands in order: " | ||
+ "create-audit-logging-stack, " | ||
+ "create-audit-log-athena-db-and-table, " | ||
+ "enable-audit-logging, " | ||
+ "update-cms-config, " | ||
+ "reboot-cms. " | ||
+ "This will do everything required to enable audit logging for an existing environment."; | ||
|
||
@Override | ||
public String getCommandName() { | ||
return COMMAND_NAME; | ||
} | ||
|
||
@Override | ||
public Class<? extends Operation<?>> getOperationClass() { | ||
return EnableAuditLoggingForExistingEnvironmentOperation.class; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/nike/cerberus/domain/cloudformation/AuditOutputs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.nike.cerberus.domain.cloudformation; | ||
|
||
public class AuditOutputs { | ||
String auditBucketName; | ||
|
||
public String getAuditBucketName() { | ||
return auditBucketName; | ||
} | ||
|
||
public AuditOutputs setAuditBucketName(String auditBucketName) { | ||
this.auditBucketName = auditBucketName; | ||
return this; | ||
} | ||
} |
Oops, something went wrong.