Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions modules/aws-glue/main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module "glue_catalog_database" {
source = "terraform-aws-modules/glue/aws//modules/catalog-database"
version = "~> 1.0"
resource "aws_glue_catalog_database" "this" {
count = var.create_database ? 1 : 0

create = var.create_database
name = var.database_name
description = var.database_description
catalog_id = var.catalog_id
Expand All @@ -12,25 +10,40 @@ module "glue_catalog_database" {
tags = var.tags
}

module "glue_crawler" {
source = "terraform-aws-modules/glue/aws//modules/crawler"
version = "~> 1.0"
resource "aws_glue_crawler" "this" {
count = var.create_crawler ? 1 : 0

create = var.create_crawler
name = var.crawler_name
database_name = var.create_database ? module.glue_catalog_database.name : var.database_name
database_name = var.create_database ? aws_glue_catalog_database.this[0].name : var.database_name
role = var.crawler_role_arn
description = var.crawler_description
schedule = var.crawler_schedule
table_prefix = var.crawler_table_prefix
classifiers = var.crawler_classifiers
configuration = var.crawler_configuration

s3_targets = var.s3_targets
schema_change_policy = var.schema_change_policy
recrawl_policy = var.recrawl_policy
dynamic "s3_target" {
for_each = var.s3_targets
content {
path = s3_target.value.path
exclusions = try(s3_target.value.exclusions, [])
connection_name = s3_target.value.connection_name
event_queue_arn = s3_target.value.event_queue_arn
dlq_event_queue_arn = s3_target.value.dlq_event_queue_arn
sample_size = s3_target.value.sample_size
}
}

schema_change_policy {
update_behavior = try(var.schema_change_policy.update_behavior, "UPDATE_IN_DATABASE")
delete_behavior = try(var.schema_change_policy.delete_behavior, "LOG")
}

recrawl_policy {
recrawl_behavior = try(var.recrawl_policy.recrawl_behavior, "CRAWL_EVERYTHING")
}

tags = var.tags

depends_on = [module.glue_catalog_database]
depends_on = [aws_glue_catalog_database.this]
}
10 changes: 5 additions & 5 deletions modules/aws-glue/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
output "database_name" {
description = "Name of the Glue catalog database."
value = var.create_database ? module.glue_catalog_database.name : var.database_name
value = var.create_database ? aws_glue_catalog_database.this[0].name : var.database_name
}

output "database_id" {
description = "ID of the Glue catalog database (catalog_id:name)."
value = var.create_database ? module.glue_catalog_database.id : null
value = var.create_database ? aws_glue_catalog_database.this[0].id : null
}

output "crawler_id" {
description = "ID of the Glue crawler (same as its name)."
value = var.create_crawler ? module.glue_crawler.id : null
value = var.create_crawler ? aws_glue_crawler.this[0].id : null
}

output "crawler_arn" {
description = "ARN of the Glue crawler."
value = var.create_crawler ? module.glue_crawler.arn : null
value = var.create_crawler ? aws_glue_crawler.this[0].arn : null
}

output "crawler_name" {
description = "Name of the Glue crawler."
value = var.create_crawler ? module.glue_crawler.name : null
value = var.create_crawler ? aws_glue_crawler.this[0].id : null
}
8 changes: 4 additions & 4 deletions modules/aws-glue/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ variable "s3_targets" {
description = "List of S3 target configurations for the crawler."
type = list(object({
path = string
exclusions = optional(list(string), [])
exclusions = optional(list(string))
connection_name = optional(string)
event_queue_arn = optional(string)
dlq_event_queue_arn = optional(string)
Expand All @@ -105,16 +105,16 @@ variable "s3_targets" {
variable "schema_change_policy" {
description = "Behavior when the crawler discovers a changed schema. update_behavior: UPDATE_IN_DATABASE or LOG. delete_behavior: DELETE_FROM_DATABASE, LOG, or DEPRECATE_IN_DATABASE."
type = object({
update_behavior = optional(string, "UPDATE_IN_DATABASE")
delete_behavior = optional(string, "LOG")
update_behavior = optional(string)
delete_behavior = optional(string)
})
default = {}
}

variable "recrawl_policy" {
description = "Recrawl behavior. recrawl_behavior: CRAWL_EVERYTHING, CRAWL_NEW_FOLDERS_ONLY, or CRAWL_EVENT_MODE."
type = object({
recrawl_behavior = optional(string, "CRAWL_EVERYTHING")
recrawl_behavior = optional(string)
})
default = {}
}
Expand Down
Loading