diff --git a/cloudwatch.tf b/cloudwatch.tf new file mode 100644 index 0000000..a2835fc --- /dev/null +++ b/cloudwatch.tf @@ -0,0 +1,4 @@ +resource "aws_cloudwatch_log_group" "default" { + name = "/aws/glue/jobs/${var.name}" + retention_in_days = var.log_retention_days +} diff --git a/main.tf b/main.tf index fde4977..d3c4dc7 100644 --- a/main.tf +++ b/main.tf @@ -1,7 +1,6 @@ resource "aws_glue_job" "default" { name = var.name connections = var.connections - default_arguments = var.default_arguments glue_version = var.glue_version max_capacity = var.max_capacity max_retries = var.max_retries @@ -16,6 +15,11 @@ resource "aws_glue_job" "default" { python_version = var.python_version script_location = var.script_location } + + default_arguments = merge({ + "--continuous-log-logGroup" : aws_cloudwatch_log_group.default.name, + "--enable-continuous-cloudwatch-log" : "true", + }, var.default_arguments) } resource "aws_glue_trigger" "default" { diff --git a/variables.tf b/variables.tf index ad4e01f..3c4ebfc 100644 --- a/variables.tf +++ b/variables.tf @@ -32,6 +32,12 @@ variable "glue_version" { description = "The Glue version to use" } +variable "log_retention_days" { + type = number + description = "The cloudwatch log group retention in days" + default = 90 +} + variable "max_capacity" { type = number default = null