Skip to content

Commit

Permalink
feat(cli): create AWS CloudTrail integrations
Browse files Browse the repository at this point in the history
Signed-off-by: Salim Afiune Maya <[email protected]>
  • Loading branch information
afiune committed Apr 30, 2020
1 parent c3e051e commit 7e80795
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cli/cmd/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ func promptCreateIntegration(lacework *api.Client) error {
Options: []string{
"Docker Hub",
"AWS Config",
"AWS CloudTrail",
//"Docker V2 Registry",
//"Amazon Container Registry",
//"Google Container Registry",
//"AWS CloudTrail",
//"Azure Config",
//"Azure Activity Log",
//"GCP Config",
Expand All @@ -188,10 +188,11 @@ func promptCreateIntegration(lacework *api.Client) error {
return createDockerHubIntegration(lacework)
case "AWS Config":
return createAwsConfigIntegration(lacework)
case "AWS CloudTrail":
return createAwsCloudTrailIntegration(lacework)
//case "Docker V2 Registry":
//case "Amazon Container Registry":
//case "Google Container Registry":
//case "AWS CloudTrail":
//case "Azure Config":
//case "Azure Activity Log":
//case "GCP Config":
Expand Down
54 changes: 54 additions & 0 deletions cli/cmd/integration_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,57 @@ func createAwsConfigIntegration(lacework *api.Client) error {
cli.StopProgress()
return err
}

func createAwsCloudTrailIntegration(lacework *api.Client) error {
questions := []*survey.Question{
{
Name: "name",
Prompt: &survey.Input{Message: "Name:"},
Validate: survey.Required,
},
{
Name: "role_arn",
Prompt: &survey.Input{Message: "Role ARN:"},
Validate: survey.Required,
},
{
Name: "external_id",
Prompt: &survey.Input{Message: "External ID:"},
Validate: survey.Required,
},
{
Name: "queue_url",
Prompt: &survey.Input{Message: "SQS Queue URL:"},
Validate: survey.Required,
},
}

answers := struct {
Name string
RoleArn string `survey:"role_arn"`
ExternalID string `survey:"external_id"`
QueueUrl string `survey:"queue_url"`
}{}

err := survey.Ask(questions, &answers,
survey.WithIcons(promptIconsFunc),
)
if err != nil {
return err
}

aws := api.NewAwsCloudTrailIntegration(answers.Name,
api.AwsIntegrationData{
QueueUrl: answers.QueueUrl,
Credentials: api.AwsIntegrationCreds{
RoleArn: answers.RoleArn,
ExternalId: answers.ExternalID,
},
},
)

cli.StartProgress(" Creating integration...")
_, err = lacework.Integrations.CreateAws(aws)
cli.StopProgress()
return err
}

0 comments on commit 7e80795

Please sign in to comment.