-
Notifications
You must be signed in to change notification settings - Fork 23
/
main.tf
83 lines (69 loc) · 2.16 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
provider "aws" {
region = "${var.region}"
version = "~> 1.0"
}
data "aws_kms_alias" "kms_encryption" {
name = "alias/aws/s3"
}
resource "aws_glue_catalog_database" "aws_glue_database" {
name = "${var.app_name}-glue-database"
}
resource "aws_glue_catalog_table" "aws_glue_table" {
name = "${var.app_name}-glue-table"
database_name = "${aws_glue_catalog_database.aws_glue_database.name}"
// Please refere the for more detail configuration of parameters at https://www.terraform.io/docs/providers/aws/r/glue_catalog_table.html
/*
parameters {
classification = "parquet"
}
*/
storage_descriptor {
location = "${var.s3_bucket_path}"
input_format = "${var.storage_input_format}"
output_format = "${var.storage_output_format}"
columns = [
{
name = "user_name"
type = "string"
},
{
name = "email"
type = "string"
},
]
}
}
resource "aws_kinesis_firehose_delivery_stream" "firehose_stream" {
name = "${var.app_name}_firehose_delivery_stream"
destination = "extended_s3"
kinesis_source_configuration {
kinesis_stream_arn = "${aws_kinesis_stream.kinesis_stream.arn}"
role_arn = "${aws_iam_role.firehose_role.arn}"
}
//refer the more s3 configuration at https://docs.aws.amazon.com/firehose/latest/APIReference/API_ExtendedS3DestinationConfiguration.html
extended_s3_configuration {
role_arn = "${aws_iam_role.firehose_role.arn}"
bucket_arn = "${var.s3_bucket_arn}"
buffer_size = 100
buffer_interval = "300"
kms_key_arn = "${data.aws_kms_alias.kms_encryption.arn}"
data_format_conversion_configuration {
input_format_configuration {
deserializer {
hive_json_ser_de {}
}
}
output_format_configuration {
serializer = {
parquet_ser_de {}
}
}
schema_configuration {
database_name = "${aws_glue_catalog_table.aws_glue_table.database_name}"
role_arn = "${aws_iam_role.firehose_role.arn}"
table_name = "${aws_glue_catalog_table.aws_glue_table.name}"
region = "${var.region}"
}
}
}
}