-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy paths3.tf
82 lines (71 loc) · 2.66 KB
/
s3.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
resource "aws_s3_bucket" "airflow" {
count = var.s3_bucket_name == "" ? 1 : 0
bucket = "${var.resource_prefix}-airflow-${var.resource_suffix}"
acl = "private"
versioning {
enabled = true
}
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "aws:kms"
}
}
}
tags = local.common_tags
}
resource "aws_s3_bucket_public_access_block" "airflow" {
count = var.s3_bucket_name == "" ? 1 : 0
bucket = aws_s3_bucket.airflow[0].id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
resource "aws_s3_bucket_object" "airflow_seed_dag" {
bucket = local.s3_bucket_name
key = "dags/airflow_seed_dag.py"
content = templatefile("${path.module}/templates/dags/airflow_seed_dag.py", {
BUCKET_NAME = local.s3_bucket_name,
KEY = local.s3_key,
AIRFLOW_HOME = var.airflow_container_home
YEAR = local.year
MONTH = local.month
DAY = local.day
})
}
resource "aws_s3_bucket_object" "airflow_example_dag" {
count = var.airflow_example_dag ? 1 : 0
bucket = local.s3_bucket_name
key = "dags/example_dag.py"
content = templatefile("${path.module}/templates/dags/example_dag.py", {})
}
resource "aws_s3_bucket_object" "airflow_scheduler_entrypoint" {
bucket = local.s3_bucket_name
key = "startup/entrypoint_scheduler.sh"
content = templatefile("${path.module}/templates/startup/entrypoint_scheduler.sh", { AIRFLOW_HOME = var.airflow_container_home })
}
resource "aws_s3_bucket_object" "airflow_webserver_entrypoint" {
bucket = local.s3_bucket_name
key = "startup/entrypoint_webserver.sh"
content = templatefile("${path.module}/templates/startup/entrypoint_webserver.sh", { AIRFLOW_HOME = var.airflow_container_home })
}
resource "aws_s3_bucket_object" "airflow_init_entrypoint" {
bucket = local.s3_bucket_name
key = "startup/entrypoint_init.sh"
content = templatefile("${path.module}/templates/startup/entrypoint_init.sh", {
RBAC_AUTH = var.airflow_authentication == "rbac" ? "true" : "false",
RBAC_USERNAME = var.rbac_admin_username,
RBAC_EMAIL = var.rbac_admin_email,
RBAC_FIRSTNAME = var.rbac_admin_firstname,
RBAC_LASTNAME = var.rbac_admin_lastname,
RBAC_PASSWORD = var.rbac_admin_password,
AIRFLOW_VERSION = var.airflow_image_tag
})
}
resource "aws_s3_bucket_object" "airflow_requirements" {
count = var.airflow_py_requirements_path == "" ? 0 : 1
bucket = local.s3_bucket_name
key = "startup/requirements.txt"
content = templatefile(local.airflow_py_requirements_path, {})
}