Skip to content

Commit

Permalink
Fix CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricios committed Jan 2, 2020
1 parent f6e6ef1 commit 6c2c287
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ locals {
}

resource "aws_cloudwatch_log_group" "this" {
count = local.id != ""? 1 : 0
name = local.id
retention_in_days = var.retention_in_days
tags = var.tags
Expand All @@ -11,10 +12,11 @@ resource "aws_cloudwatch_log_group" "this" {
resource "aws_cloudwatch_log_stream" "this" {
count = length(var.streams)
name = element(var.streams, count.index)
log_group_name = aws_cloudwatch_log_group.this.name
log_group_name = aws_cloudwatch_log_group.this.0.name
}

data "aws_iam_policy_document" "this" {
count = local.id != ""? 1 : 0
statement {
actions = ["logs:DescribeLogGroups","logs:DescribeLogStreams"]

Expand All @@ -27,23 +29,24 @@ data "aws_iam_policy_document" "this" {
]

resources = [
aws_cloudwatch_log_group.this.arn,
aws_cloudwatch_log_group.this.0.arn,
]
}

statement {
actions = var.additional_permissions

resources = [
aws_cloudwatch_log_group.this.arn,
aws_cloudwatch_log_group.this.0.arn,
]
}
}

resource "aws_iam_policy" "this" {
count = local.id != ""? 1 : 0
name = "${local.id}-CloudWatchLogs"
description = var.description
policy = data.aws_iam_policy_document.this.json
policy = data.aws_iam_policy_document.this.0.json
}

# --------------------------------------------------------
Expand All @@ -52,5 +55,5 @@ resource "aws_iam_policy" "this" {
resource "aws_iam_role_policy_attachment" "this" {
count = var.role != "" ? 1 : 0
role = var.role
policy_arn = aws_iam_policy.this.arn
policy_arn = aws_iam_policy.this.0.arn
}
4 changes: 2 additions & 2 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
output "name" {
description = "Name of log group"
value = "${aws_cloudwatch_log_group.this.name}"
value = aws_cloudwatch_log_group.this.*.name
}

output "policy_arn" {
value = "${aws_iam_policy.this.arn}"
value = aws_iam_policy.this.*.arn
description = "ARN of policy of CloudWatch log"
}

0 comments on commit 6c2c287

Please sign in to comment.