-
Notifications
You must be signed in to change notification settings - Fork 3
/
glue.tf
68 lines (57 loc) · 2.19 KB
/
glue.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
/* --------------------------------------------------------
FILE: glue.tf
This is probably the main file in the whole module as it is
used to specify and declare a preconfigured Glue job to be
explored by users. This file considers the usage of all
other componentes and resources already declared in other
Terrafom files, such as IAM roles.
-------------------------------------------------------- */
# Uploading the Spark application script to S3
resource "aws_s3_object" "python_scripts" {
for_each = local.glue_files
bucket = var.glue_scripts_bucket_name
key = "${local.glue_files_key}/${each.value}"
source = "${local.glue_files_root_source}/${each.value}"
}
# Defining a Glue security configuration
resource "aws_glue_security_configuration" "glue_sc" {
count = var.glue_apply_security_configuration ? 1 : 0
name = "${var.glue_job_name}-security-config"
encryption_configuration {
cloudwatch_encryption {
cloudwatch_encryption_mode = var.glue_cloudwatch_encryption_mode
kms_key_arn = local.kms_key_arn
}
job_bookmarks_encryption {
job_bookmarks_encryption_mode = var.glue_job_bookmark_encryption_mode
}
s3_encryption {
s3_encryption_mode = var.glue_s3_encryption_mode
kms_key_arn = local.kms_key_arn
}
}
}
# Defining a Glue job
resource "aws_glue_job" "job" {
# Setting job attributes
name = var.glue_job_name
role_arn = local.glue_role_arn
description = var.glue_job_description
glue_version = var.glue_job_version
max_retries = var.glue_job_max_retries
timeout = var.glue_job_timeout
worker_type = var.glue_job_worker_type
number_of_workers = var.glue_job_number_of_workers
# Setting script location and python version
command {
script_location = local.glue_script_location
python_version = var.glue_job_python_version
}
# Setting execution properties
execution_property {
max_concurrent_runs = var.glue_job_max_concurrent_runs
}
# Setting job arguments
default_arguments = local.glue_job_args
security_configuration = var.glue_apply_security_configuration ? aws_glue_security_configuration.glue_sc[0].name : ""
}