Skip to content

Commit

Permalink
Resolve #4, cloudwatch
Browse files Browse the repository at this point in the history
  • Loading branch information
o0th committed May 26, 2020
1 parent 7dffae3 commit ef8e6c4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions container-definitions.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
"readOnly": false
}],
"logConfiguration": {
%{ if cloudwatch >= 1 }
"logDriver": "awslogs",
"options": {
"awslogs-group": "${logs_group}",
"awslogs-stream-prefix": "${logs_stream_prefix}",
"awslogs-region": "${logs_region}"
}
%{ endif }
}
}]
5 changes: 4 additions & 1 deletion logs.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
resource "aws_cloudwatch_log_group" "this" {
name = var.name
count = var.cloudwatch >= 1 ? 1 : 0

name = var.name
retention_in_days = var.cloudwatch
}
1 change: 1 addition & 0 deletions services.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ data "template_file" "container_definitions" {
volume_name = var.name
volume_path = "/data/db"
environment = jsonencode(var.environment)
cloudwatch = var.cloudwatch
logs_group = var.name
logs_stream_prefix = var.name
logs_region = data.aws_region.this.name
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ variable "volume_size" {
default = 0
}

variable "cloudwatch" {
type = number
default = 0
}

variable "environment" {
type = list(object({ name = string, value = string }))
default = []
Expand Down

0 comments on commit ef8e6c4

Please sign in to comment.