Skip to content
This repository has been archived by the owner on Jun 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #59 from securityclippy/firehose_lambda_function_p…
Browse files Browse the repository at this point in the history
…ermissions

fixing invoke lambda permissions
  • Loading branch information
mattjane-okta authored Aug 10, 2018
2 parents 436146a + 0f58a24 commit 4f44180
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions terraform/modules/elasticsearch_firehose/firehose.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,45 @@ resource "aws_iam_role" "sgt-firehose-assume-role" {
assume_role_policy = "${data.aws_iam_policy_document.sgt_firehose_assume_role_policy_doc.json}"
}

data "aws_iam_policy_document" "firehose_invoke_lambda_policy_doc" {
statement {
effect = "Allow"
actions = [
"lambda:InvokeFunction",
"lambda:GetFunctionConfiguration",
"logs:PutLogEvents"
]
resources = [
"${aws_lambda_function.sgt_osquery_results_date_transform.arn}:$LATEST"
]
}
statement {
effect = "Allow"
actions = [
"logs:PutLogEvents"
]
resources = [
"*"
]
}
statement {
effect = "Allow"
actions = [
"kinesis:DescribeStream",
"kinesis:GetShardIterator",
"kinesis:GetRecords"
]
resources = [
"${aws_kinesis_firehose_delivery_stream.sgt-firehose-osquery_results.arn}"
]
}
}

resource "aws_iam_policy" "firehose_invoke_lambda_policy" {
name = "sgt-firehose-lambda-policy"
policy = "${data.aws_iam_policy_document.firehose_invoke_lambda_policy_doc.json}"
}

resource "aws_iam_role_policy_attachment" "attach_s3_policy" {
policy_arn = "${aws_iam_policy.sgt-firehose-s3-policy.arn}"
role = "${aws_iam_role.sgt-firehose-assume-role.id}"
Expand Down Expand Up @@ -208,6 +247,7 @@ data "aws_iam_policy_document" "elasticsearch_policy" {
}

resource "aws_iam_policy" "elasticsearch_policy" {
name = "sgt-elasticsearch-policy"
policy = "${data.aws_iam_policy_document.elasticsearch_policy.json}"
}

Expand All @@ -216,7 +256,13 @@ resource "aws_iam_role_policy_attachment" "elasticsearch_policy_attachment" {
role = "${aws_iam_role.sgt-firehose-assume-role.name}"
}

resource "aws_iam_role_policy_attachment" "firehose_invoke_lambda_policy_attachment" {
policy_arn = "${aws_iam_policy.firehose_invoke_lambda_policy.arn}"
role = "${aws_iam_role.sgt-firehose-assume-role.name}"
}

resource "aws_iam_policy" "sgt-node-user-policy" {
name = "sgt-node-user-policy"
policy = "${data.aws_iam_policy_document.sgt-node-user.json}"
}

Expand Down

0 comments on commit 4f44180

Please sign in to comment.