Skip to content
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

Merged
merged 18 commits into from
Nov 27, 2017
Merged

Implement module for CloudWatch logs #1

merged 18 commits into from
Nov 27, 2017

Conversation

SweetOps
Copy link
Contributor

@SweetOps SweetOps commented Nov 1, 2017

What

  • Implement module for CloudWatch logs

Why

  • We need that for collection logs from instances

@SweetOps SweetOps self-assigned this Nov 1, 2017
@SweetOps SweetOps added the wip Work in Progress: Not ready for final review or merge label Nov 1, 2017
@SweetOps SweetOps removed the wip Work in Progress: Not ready for final review or merge label Nov 2, 2017
@SweetOps
Copy link
Contributor Author

SweetOps commented Nov 2, 2017

screenshot 2017-11-02 17 25 30

screenshot 2017-11-02 17 29 13

iam_user.tf Outdated
@@ -0,0 +1,43 @@
resource "aws_iam_user" "default" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iam_user.tf Outdated
@@ -0,0 +1,33 @@
data "aws_iam_policy_document" "user" {
count = "${var.create_user == "true" ? 1 : 0}"
Copy link
Member

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"]
Copy link
Member

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.

Copy link
Member

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

@osterman
Copy link
Member

osterman commented Nov 9, 2017

I activated TravisCI. Please bump.


principals {
type = "Service"
identifiers = ["logs.${length(var.region) > 0 ? var.region: data.aws_region.default.name}.amazonaws.com"]

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 = [

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use compact with concat.

Copy link
Contributor Author

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

Copy link
Member

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

Copy link
Contributor Author

@SweetOps SweetOps Nov 15, 2017

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()

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)}",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is join("," deliberate?

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"true"

@const-bon
Copy link

@SweetOps @osterman
Should we rename module to terraform-aws-cloudwatch-log-stream for consistence?

@SweetOps
Copy link
Contributor Author

@comeanother , I'm prefer the current name of repo :)

variables.tf Outdated

variable "namespace" {
description = "Namespace (e.g. `cp` or `cloudposse`)"
default = "cp"

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"

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" {

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.

Copy link
Contributor Author

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?

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 = [

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

@SweetOps
Copy link
Contributor Author

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" {

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" {

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")))}"

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" {

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

@const-bon const-bon merged commit 2243829 into master Nov 27, 2017
@const-bon const-bon deleted the add_code branch November 27, 2017 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants