-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement module for CloudWatch logs #1
Conversation
iam_user.tf
Outdated
@@ -0,0 +1,43 @@ | |||
resource "aws_iam_user" "default" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use this module instead: https://github.com/cloudposse/terraform-aws-iam-system-user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@osterman, in my case user will be create if username
is defined, with module terraform-aws-iam-system-user
can't get same functional. The one way is add count
to module terraform-aws-iam-system-user
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@osterman , I made PR in cloudposse/terraform-aws-iam-system-user#2 (comment)
iam_user.tf
Outdated
@@ -0,0 +1,33 @@ | |||
data "aws_iam_policy_document" "user" { | |||
count = "${var.create_user == "true" ? 1 : 0}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's rename to user_enabled
variables.tf
Outdated
} | ||
|
||
variable "stream_names" { | ||
default = ["pfsense", "ubuntu"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pfsense
is a very specific use case. It doesn't make sense as a global default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's just create a default stream with the name of default
I activated TravisCI. Please bump. |
|
||
principals { | ||
type = "Service" | ||
identifiers = ["logs.${length(var.region) > 0 ? var.region: data.aws_region.default.name}.amazonaws.com"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document var.region
in README.
"logs:DeleteLogStream", | ||
] | ||
|
||
resources = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use compact
with concat
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use compact with concat.
It can break the module work - with json
need be very careful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explain why it can break json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure which delimiter between elements which I'll get after the concat()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems, there is no need to use join
with delimiter here.
https://www.terraform.io/docs/providers/aws/d/iam_policy_document.html
iam.tf
Outdated
|
||
resources = [ | ||
"${aws_cloudwatch_log_group.default.arn}", | ||
"${join(",", aws_cloudwatch_log_stream.default.*.arn)}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is join(","
deliberate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, for prevent mistakes in json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explain what mistakes it prevents. it's not clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
element in resources
should be separated by comma, I'm not sure that comma will be without join()
main.tf
Outdated
@@ -0,0 +1,35 @@ | |||
data "aws_region" "default" { | |||
current = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"true"
@comeanother , I'm prefer the current name of repo :) |
variables.tf
Outdated
|
||
variable "namespace" { | ||
description = "Namespace (e.g. `cp` or `cloudposse`)" | ||
default = "cp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop default value.
variables.tf
Outdated
} | ||
|
||
variable "stage" { | ||
default = "dev" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop default value.
} | ||
} | ||
|
||
module "user" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this module?
It is not in use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not in use.
Why do you decided that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume, purpose of this user is to be able to connect to the corresponding streams.
But this user would has access to all streams. https://github.com/cloudposse/terraform-aws-cloudwatch-logs/pull/1/files#diff-a83a8bb953f15707ac8beb549b114ab5R22
"logs:DeleteLogStream", | ||
] | ||
|
||
resources = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems, there is no need to use join
with delimiter here.
https://www.terraform.io/docs/providers/aws/d/iam_policy_document.html
@comeanother , I see in example resources separated by comma |
outputs.tf
Outdated
value = "${aws_cloudwatch_log_group.default.name}" | ||
} | ||
|
||
output "log_stream_name" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log_stream_names
.
outputs.tf
Outdated
description = "ARN of the log group" | ||
} | ||
|
||
output "stream_arn" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stream_arns
.
main.tf
Outdated
name = "${var.name}" | ||
stage = "${var.stage}" | ||
delimiter = "${var.delimiter}" | ||
attributes = "${compact(concat(var.attributes, list("log")))}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add group
attribute?
} | ||
} | ||
|
||
module "user" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume, purpose of this user is to be able to connect to the corresponding streams.
But this user would has access to all streams. https://github.com/cloudposse/terraform-aws-cloudwatch-logs/pull/1/files#diff-a83a8bb953f15707ac8beb549b114ab5R22
What
CloudWatch
logsWhy