Skip to content

Commit

Permalink
added CW logging (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
thulasirajkomminar authored Dec 19, 2023
1 parent e329f20 commit 8128d72
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ No modules.

| Name | Type |
|------|------|
| [aws_cloudwatch_log_group.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group) | resource |
| [aws_glue_job.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/glue_job) | resource |
| [aws_glue_trigger.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/glue_trigger) | resource |
| [aws_iam_role.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
Expand All @@ -89,6 +90,8 @@ No modules.
| <a name="input_connections"></a> [connections](#input\_connections) | A list with connections for this job | `list(string)` | `[]` | no |
| <a name="input_default_arguments"></a> [default\_arguments](#input\_default\_arguments) | A map with default arguments for the job | `map(string)` | `{}` | no |
| <a name="input_glue_version"></a> [glue\_version](#input\_glue\_version) | The Glue version to use | `string` | `"4.0"` | no |
| <a name="input_kms_key_id"></a> [kms\_key\_id](#input\_kms\_key\_id) | The kms key id of the AWS KMS Customer Managed Key to be used to encrypt the log data | `string` | `null` | no |
| <a name="input_log_retention_days"></a> [log\_retention\_days](#input\_log\_retention\_days) | The cloudwatch log group retention in days | `number` | `365` | no |
| <a name="input_max_capacity"></a> [max\_capacity](#input\_max\_capacity) | The maximum number of data processing units that can be allocated | `number` | `null` | no |
| <a name="input_max_retries"></a> [max\_retries](#input\_max\_retries) | The maximum number of times to retry the failing job | `number` | `0` | no |
| <a name="input_number_of_workers"></a> [number\_of\_workers](#input\_number\_of\_workers) | The number of workers that are allocated when the job runs | `string` | `null` | no |
Expand Down
5 changes: 5 additions & 0 deletions cloudwatch.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "aws_cloudwatch_log_group" "default" {
name = "/aws/glue/jobs/${var.name}"
kms_key_id = var.kms_key_id
retention_in_days = var.log_retention_days
}
6 changes: 5 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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" {
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ variable "glue_version" {
description = "The Glue version to use"
}

variable "kms_key_id" {
type = string
default = null
description = "The kms key id of the AWS KMS Customer Managed Key to be used to encrypt the log data"
}

variable "log_retention_days" {
type = number
description = "The cloudwatch log group retention in days"
default = 365
}

variable "max_capacity" {
type = number
default = null
Expand Down

0 comments on commit 8128d72

Please sign in to comment.