Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
allow cms to use athena so we can automatically add partitions
Browse files Browse the repository at this point in the history
  • Loading branch information
fieldju committed Feb 6, 2018
1 parent 2cf72f8 commit 905a40f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

group=com.nike
artifactId=cerberus-lifecycle-cli
version=4.1.0
version=4.2.0
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ 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: "
+ "update-stack --stack-name iam-roles --overwrite-template, "
+ "create-audit-logging-stack, "
+ "create-audit-log-athena-db-and-table, "
+ "enable-audit-logging, "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,6 @@ public void run(CreateAuditAthenaDbAndTableCommand command) {
throw new RuntimeException("failed to load create athena table template", e);
}
log.info(executeAthenaQuery(createAuditTable, bucketName).toString());

String msg = Chalk.on("ATTENTION: ").red().bold().toString() +
"Table creation complete, please note that before you execute queries against '" + tableName + "'\n" +
"You will have to run the following query '" + Chalk.on("MSCK REPAIR TABLE " + tableName).green().bold().toString() + "'\n" +
"CMS will uploads logs every 5 minutes and creates partition folders for every hour.\n" +
"You can automate that query to run every hour or run it before you query audit data.\n" +
"That query is free and scans the S3 folders in the audit bucket and add the new partitions (The hour folders)";

log.info(msg);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.nike.cerberus.command.audit.EnableAuditLoggingForExistingEnvironmentCommand;
import com.nike.cerberus.command.cms.UpdateCmsConfigCommand;
import com.nike.cerberus.command.core.RebootCmsCommand;
import com.nike.cerberus.command.core.UpdateStackCommand;
import com.nike.cerberus.domain.cloudformation.ConfigParameters;
import com.nike.cerberus.domain.environment.Stack;
import com.nike.cerberus.operation.composite.ChainableCommand;
Expand Down Expand Up @@ -49,10 +50,17 @@ protected List<ChainableCommand> getCompositeCommandChain(EnableAuditLoggingForE
ConfigParameters.class).getAccountAdminArn();

return ImmutableList.of(
ChainableCommand.Builder.create()
.withCommand(new UpdateStackCommand())
.withOption(UpdateStackCommand.STACK_NAME_LONG_ARG, Stack.IAM_ROLES.getName())
.withAdditionalArg(UpdateStackCommand.OVERWRITE_TEMPLATE_LONG_ARG)
.build(),

ChainableCommand.Builder.create()
.withCommand(new CreateAuditLoggingStackCommand())
.withOption(CreateAuditLoggingStackCommand.ADMIN_ROLE_ARN_LONG_ARG, adminArn)
.build(),

new ChainableCommand(new CreateAuditAthenaDbAndTableCommand()),
new ChainableCommand(new EnableAuditLoggingCommand()),
new ChainableCommand(new UpdateCmsConfigCommand()),
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/cloudformation/iam-roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Outputs:
Resources:
CmsIamRole:
Properties:
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonAthenaFullAccess
AssumeRolePolicyDocument:
Statement:
- Action:
Expand Down

0 comments on commit 905a40f

Please sign in to comment.