-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
65 lines (60 loc) · 3.9 KB
/
main.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
resource "snowflake_schema" "ingest" {
name = upper(var.source_name)
database = var.ingest_database_id
is_transient = try(var.ingest_schema_config.is_transient, null)
is_managed = try(var.ingest_schema_config.is_managed, null)
data_retention_days = try(var.ingest_schema_config.data_retention_days, null)
}
resource "snowflake_table" "ingest" {
database = var.ingest_database_id
schema = snowflake_schema.ingest.name
name = upper(var.table_name)
comment = "created by terraform"
column {
name = var.column_name
type = var.column_type
}
primary_key {
keys = var.keys_list
}
}
resource "snowflake_file_format" "ingest" {
for_each = var.source_files_format_dictionary
# required
name = upper(var.file_format_name)
database = var.ingest_database_id
schema = snowflake_schema.ingest.name
format_type = try(var.source_files_format_dictionary.format_type, null)
# optional
allow_duplicate = try(var.source_files_format_dictionary.allow_duplicate, null)
binary_as_text = try(var.source_files_format_dictionary.binary_as_text, null)
binary_format = try(var.source_files_format_dictionary.binary_format, null)
comment = try(var.source_files_format_dictionary.comment, null)
compression = try(var.source_files_format_dictionary.compression, null)
date_format = try(var.source_files_format_dictionary.date_format, null)
disable_auto_convert = try(var.source_files_format_dictionary.disable_auto_convert, null)
disable_snowflake_data = try(var.source_files_format_dictionary.disable_snowflake_data, null)
empty_field_as_null = try(var.source_files_format_dictionary.empty_field_as_null, null)
enable_octal = try(var.source_files_format_dictionary.enable_octal, null)
encoding = try(var.source_files_format_dictionary.encoding, null)
error_on_column_count_mismatch = try(var.source_files_format_dictionary.error_on_column_count_mismatch, null)
escape = try(var.source_files_format_dictionary.escape, null)
escape_unenclosed_field = try(var.source_files_format_dictionary.escape_unenclosed_field, null)
field_delimiter = try(var.source_files_format_dictionary.field_delimiter, null)
field_optionally_enclosed_by = try(var.source_files_format_dictionary.field_optionally_enclosed_by, null)
file_extension = try(var.source_files_format_dictionary.file_extension, null)
ignore_utf8_errors = try(var.source_files_format_dictionary.ignore_utf8_errors, null)
null_if = try(var.source_files_format_dictionary.null_if, null)
preserve_space = try(var.source_files_format_dictionary.preserve_space, null)
record_delimiter = try(var.source_files_format_dictionary.record_delimiter, null)
replace_invalid_characters = try(var.source_files_format_dictionary.replace_invalid_characters, null)
skip_blank_lines = try(var.source_files_format_dictionary.skip_blank_lines, null)
skip_byte_order_mark = try(var.source_files_format_dictionary.skip_byte_order_mark, null)
skip_header = try(var.source_files_format_dictionary.skip_header, null)
strip_null_values = try(var.source_files_format_dictionary.strip_null_values, null)
strip_outer_array = try(var.source_files_format_dictionary.strip_outer_array, null)
strip_outer_element = try(var.source_files_format_dictionary.strip_outer_element, null)
time_format = try(var.source_files_format_dictionary.time_format, null)
timestamp_format = try(var.source_files_format_dictionary.timestamp_format, null)
trim_space = try(var.source_files_format_dictionary.trim_space, null)
}