-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathglue_trigger.tf
98 lines (81 loc) · 3.54 KB
/
glue_trigger.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#---------------------------------------------------
# AWS Glue trigger
#---------------------------------------------------
resource "aws_glue_trigger" "glue_trigger" {
count = var.enable_glue_trigger ? 1 : 0
name = var.glue_trigger_name != "" ? lower(var.glue_trigger_name) : "${lower(var.name)}-glue-trigger-${lower(var.environment)}"
type = upper(var.glue_trigger_type)
description = var.glue_trigger_description
enabled = var.glue_trigger_enabled
schedule = var.glue_trigger_schedule
workflow_name = var.glue_trigger_workflow_name != "" && !var.enable_glue_workflow ? var.glue_trigger_workflow_name : element(concat(aws_glue_workflow.glue_workflow.*.id, [""]), 0)
start_on_creation = var.glue_trigger_start_on_creation
dynamic "actions" {
iterator = actions
for_each = var.glue_trigger_actions
content {
arguments = lookup(actions.value, "arguments", null)
# Both JobName or CrawlerName cannot be set together in an action
crawler_name = lookup(actions.value, "crawler_name", (var.enable_glue_crawler && !var.enable_glue_job ? element(concat(aws_glue_crawler.glue_crawler.*.id, [""]), 0) : null))
job_name = lookup(actions.value, "job_name", (var.enable_glue_job && !var.enable_glue_crawler ? element(concat(aws_glue_job.glue_job.*.id, [""]), 0) : null))
timeout = lookup(actions.value, "timeout", null)
security_configuration = lookup(actions.value, "security_configuration", null)
dynamic "notification_property" {
iterator = notification_property
for_each = length(keys(lookup(actions.value, "notification_property", {}))) > 0 ? [lookup(actions.value, "notification_property", {})] : []
content {
notify_delay_after = lookup(notification_property.value, "notify_delay_after", [])
}
}
}
}
dynamic "predicate" {
iterator = predicate
for_each = length(keys(var.glue_trigger_predicate)) > 0 ? [var.glue_trigger_predicate] : []
content {
logical = lookup(predicate.value, "logical", null)
dynamic "conditions" {
iterator = conditions
for_each = lookup(predicate.value, "conditions", [])
content {
job_name = lookup(conditions.value, "job_name", null)
state = lookup(conditions.value, "state", null)
crawler_name = lookup(conditions.value, "crawler_name", null)
crawl_state = lookup(conditions.value, "crawl_state", null)
logical_operator = lookup(conditions.value, "logical_operator", null)
}
}
}
}
dynamic "event_batching_condition" {
iterator = event_batching_condition
for_each = var.glue_trigger_event_batching_condition
content {
batch_size = lookup(event_batching_condition.value, "create", null)
batch_window = lookup(event_batching_condition.value, "delete", null)
}
}
dynamic "timeouts" {
iterator = timeouts
for_each = length(keys(var.glue_trigger_timeouts)) > 0 ? [var.glue_trigger_timeouts] : []
content {
create = lookup(timeouts.value, "create", null)
delete = lookup(timeouts.value, "delete", null)
}
}
tags = merge(
{
Name = var.glue_trigger_name != "" ? lower(var.glue_trigger_name) : "${lower(var.name)}-glue-trigger-${lower(var.environment)}"
},
var.tags
)
lifecycle {
create_before_destroy = true
ignore_changes = []
}
depends_on = [
aws_glue_workflow.glue_workflow,
aws_glue_crawler.glue_crawler,
aws_glue_job.glue_job
]
}