-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor module to better support k8s requirement with fluentd (#3)
* Refactor module to better support k8s requirement with fluentd (#3)
- Loading branch information
Showing
7 changed files
with
231 additions
and
141 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
## {{ (datasource "git").name }} [![Build Status](https://travis-ci.org/cloudposse/terraform-aws-cloudwatch-logs.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-aws-cloudwatch-logs) | ||
{{ (datasource "section").warning }} | ||
|
||
Terraform module for creation of CloudWatch Log Streams and Log Groups for use with Fluentd. | ||
|
||
## Usage | ||
|
||
```terraform | ||
module "cloudwatch_log" { | ||
namespace = "${var.namespace}" | ||
stage = "${var.stage}" | ||
stream_names = ["kafka-instance-1", "kafka-instance-2"] | ||
} | ||
``` | ||
|
||
{{ (datasource "terraform").input }} | ||
|
||
{{ (datasource "terraform").output }} | ||
|
||
{{ (datasource "section").help }} | ||
|
||
{{ (datasource "section").contributing }} | ||
|
||
{{ (datasource "license").apache2 }} | ||
|
||
{{ (datasource "section").about }} | ||
|
||
### Contributors | ||
|
||
| | ||
{{- (datasource "contributor").erik }} | | ||
{{- (datasource "contributor").vladimir }} | | ||
{{- (datasource "contributor").igor }} | | ||
{{ (datasource "contributor")._3 }} | ||
|
||
{{ (datasource "contributor")._links }} |
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 |
---|---|---|
@@ -1,39 +1,66 @@ | ||
data "aws_iam_policy_document" "log_assume" { | ||
data "aws_iam_policy_document" "role_trust" { | ||
statement { | ||
actions = ["sts:AssumeRole"] | ||
|
||
principals { | ||
type = "Service" | ||
identifiers = ["logs.${length(var.region) > 0 ? var.region: data.aws_region.default.name}.amazonaws.com"] | ||
identifiers = ["ec2.amazonaws.com"] | ||
} | ||
} | ||
|
||
statement { | ||
actions = ["sts:AssumeRole"] | ||
|
||
principals { | ||
type = "AWS" | ||
|
||
identifiers = ["${var.trusted_roles}"] | ||
} | ||
} | ||
} | ||
|
||
resource "aws_iam_role" "default" { | ||
name = "${module.label.id}" | ||
assume_role_policy = "${data.aws_iam_policy_document.role_trust.json}" | ||
} | ||
|
||
data "aws_iam_policy_document" "log" { | ||
resource "aws_iam_policy" "default" { | ||
name = "${module.label.id}" | ||
policy = "${data.aws_iam_policy_document.log_agent.json}" | ||
} | ||
|
||
data "aws_iam_policy_document" "log_agent" { | ||
statement { | ||
actions = [ | ||
"logs:CreateLogGroup", | ||
"logs:CreateLogStream", | ||
"logs:PutLogEvents", | ||
"logs:DescribeLogGroups", | ||
"logs:DescribeLogStreams", | ||
"logs:CreateLogStream", | ||
"logs:DeleteLogStream", | ||
] | ||
|
||
resources = ["*"] | ||
} | ||
|
||
statement { | ||
actions = [ | ||
"logs:PutLogEvents", | ||
] | ||
|
||
resources = [ | ||
"${join(",", compact(concat(list(aws_cloudwatch_log_group.default.arn), aws_cloudwatch_log_stream.default.*.arn)))}", | ||
"${aws_cloudwatch_log_group.default.arn}", | ||
] | ||
} | ||
} | ||
|
||
resource "aws_iam_role" "log" { | ||
name = "${module.log_group_label.id}" | ||
assume_role_policy = "${data.aws_iam_policy_document.log_assume.json}" | ||
statement { | ||
actions = [ | ||
"${var.additional_permissions}", | ||
] | ||
|
||
resources = [ | ||
"${aws_cloudwatch_log_group.default.arn}", | ||
] | ||
} | ||
} | ||
|
||
resource "aws_iam_role_policy" "log" { | ||
name = "${module.log_group_label.id}" | ||
role = "${aws_iam_role.log.id}" | ||
policy = "${data.aws_iam_policy_document.log.json}" | ||
resource "aws_iam_role_policy_attachment" "default" { | ||
role = "${aws_iam_role.default.name}" | ||
policy_arn = "${aws_iam_policy.default.arn}" | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.