Skip to content

Commit

Permalink
updating role paths used by scheduled queries (#1216)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryandeivert committed Mar 31, 2020
1 parent 5b63c95 commit 07812ef
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ resource "aws_cloudwatch_event_rule" "event" {
name = "${var.prefix}_streamalert_scheduled_queries_event_${count.index}"
description = var.query_packs[count.index].description
schedule_expression = var.query_packs[count.index].schedule_expression

tags = {
Name = "StreamAlert"
}
}

resource "aws_cloudwatch_event_target" "run_step_function" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# Attach additional permissions to the auto-generated Lambda IAM Role
resource "aws_iam_role_policy" "lambda_permissions" {
name = "${var.prefix}_streamalert_scheduled_queries_lambda_permissions"
name = "LambdaRequiredPermissions"
role = module.scheduled_queries_lambda.role_id
policy = data.aws_iam_policy_document.lambda_permissions.json
}
Expand Down Expand Up @@ -97,7 +97,12 @@ data "aws_iam_policy_document" "lambda_permissions" {
# Setup the IAM Role for the Step Functions
resource "aws_iam_role" "iam_for_step_functions" {
name = "${var.prefix}_streamalert_scheduled_queries_state_machines"
path = "/streamalert/"
assume_role_policy = data.aws_iam_policy_document.iam_step_function_assume_role.json

tags = {
Name = "StreamAlert"
}
}

# Only allow Step Functions to assume this role
Expand All @@ -116,7 +121,7 @@ data "aws_iam_policy_document" "iam_step_function_assume_role" {

# Attach an additional policy to the IAM Role
resource "aws_iam_role_policy" "stepfunction_permissions" {
name = "${var.prefix}_streamalert_scheduled_queries_state_machine_permissions"
name = "StepFunctionsInvokeLambda"
role = aws_iam_role.iam_for_step_functions.id
policy = data.aws_iam_policy_document.stepfunction_permissions.json
}
Expand All @@ -143,7 +148,12 @@ data "aws_iam_policy_document" "stepfunction_permissions" {
# Setup the IAM Role
resource "aws_iam_role" "iam_for_cloudwatch_schedule" {
name = "${var.prefix}_streamalert_scheduled_queries_cloudwatch_schedule"
path = "/streamalert/"
assume_role_policy = data.aws_iam_policy_document.iam_cloudwatch_assume_role.json

tags = {
Name = "StreamAlert"
}
}

# Only allow cloudwatch to assume this role
Expand All @@ -162,7 +172,7 @@ data "aws_iam_policy_document" "iam_cloudwatch_assume_role" {

# Attach additional permissions to the IAM Role
resource "aws_iam_role_policy" "cloudwatch_schedule_permissions" {
name = "${var.prefix}_streamalert_scheduled_queries_cloudwatch_schedule_permissions"
name = "StepFunctionsStartViaCWE"
role = aws_iam_role.iam_for_cloudwatch_schedule.id
policy = data.aws_iam_policy_document.cloudwatch_schedule_permission.json
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ resource "aws_sfn_state_machine" "state_machine" {
}
EOF

tags = {
Name = "StreamAlert"
}

}

This file was deleted.

0 comments on commit 07812ef

Please sign in to comment.