-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathglue_catalog_database.tf
58 lines (45 loc) · 2.04 KB
/
glue_catalog_database.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
#---------------------------------------------------
# AWS Glue catalog database
#---------------------------------------------------
resource "aws_glue_catalog_database" "glue_catalog_database" {
count = var.enable_glue_catalog_database ? 1 : 0
name = var.glue_catalog_database_name != "" ? lower(var.glue_catalog_database_name) : "${lower(var.name)}-glue-catalog-db-${lower(var.environment)}"
description = var.glue_catalog_database_description
catalog_id = var.glue_catalog_database_catalog_id
location_uri = var.glue_catalog_database_location_uri
parameters = var.glue_catalog_database_parameters
dynamic "create_table_default_permission" {
iterator = create_table_default_permission
for_each = length(keys(var.glue_catalog_database_create_table_default_permission)) > 0 ? [var.glue_catalog_database_create_table_default_permission] : []
content {
permissions = lookup(create_table_default_permission.value, "permissions", null)
dynamic "principal" {
iterator = principal
for_each = length(keys(lookup(create_table_default_permission.value, "principal", {}))) > 0 ? [lookup(create_table_default_permission.value, "principal", {})] : []
content {
data_lake_principal_identifier = lookup(principal.value, "data_lake_principal_identifier", null)
}
}
}
}
dynamic "target_database" {
iterator = target_database
for_each = length(keys(var.glue_catalog_database_target_database)) > 0 ? [var.glue_catalog_database_target_database] : []
content {
catalog_id = lookup(target_database.value, "catalog_id", null)
database_name = lookup(target_database.value, "database_name", null)
region = lookup(target_database.value, "region", null)
}
}
tags = merge(
{
Name = var.glue_catalog_database_name != "" ? lower(var.glue_catalog_database_name) : "${lower(var.name)}-glue-catalog-db-${lower(var.environment)}"
},
var.tags
)
lifecycle {
create_before_destroy = true
ignore_changes = []
}
depends_on = []
}