Skip to content

Commit ef8e6c4

Browse files
committed
Resolve #4, cloudwatch
1 parent 7dffae3 commit ef8e6c4

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

container-definitions.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
"readOnly": false
2121
}],
2222
"logConfiguration": {
23+
%{ if cloudwatch >= 1 }
2324
"logDriver": "awslogs",
2425
"options": {
2526
"awslogs-group": "${logs_group}",
2627
"awslogs-stream-prefix": "${logs_stream_prefix}",
2728
"awslogs-region": "${logs_region}"
2829
}
30+
%{ endif }
2931
}
3032
}]

logs.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
resource "aws_cloudwatch_log_group" "this" {
2-
name = var.name
2+
count = var.cloudwatch >= 1 ? 1 : 0
3+
4+
name = var.name
5+
retention_in_days = var.cloudwatch
36
}

services.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ data "template_file" "container_definitions" {
1010
volume_name = var.name
1111
volume_path = "/data/db"
1212
environment = jsonencode(var.environment)
13+
cloudwatch = var.cloudwatch
1314
logs_group = var.name
1415
logs_stream_prefix = var.name
1516
logs_region = data.aws_region.this.name

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ variable "volume_size" {
3939
default = 0
4040
}
4141

42+
variable "cloudwatch" {
43+
type = number
44+
default = 0
45+
}
46+
4247
variable "environment" {
4348
type = list(object({ name = string, value = string }))
4449
default = []

0 commit comments

Comments
 (0)