Repository navigation
Expand file tree
/
Copy pathmain.tf
More file actions
101 lines (85 loc) · 2.16 KB
/
Copy pathmain.tf
File metadata and controls
101 lines (85 loc) · 2.16 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
variable "aws_region" {
default = "eu-west-1"
}
resource "aws_iam_role" "lambda_role" {
name = "demorole"
assume_role_policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
POLICY
}
resource "aws_iam_role" "firehose_role" {
name = "firehose_test_role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "firehose.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}
resource "aws_lambda_function" "demo_lambda" {
filename = "lambda.zip"
function_name = "demolambda"
role = aws_iam_role.lambda_role.arn
handler = "lambda.handler"
source_code_hash = filebase64sha256("lambda.zip")
runtime = "python3.9"
environment {
variables = {
STREAM_NAME = aws_kinesis_stream.demo_kinesis_stream.name
}
}
}
resource "aws_lambda_function_url" "demo_lambda_url" {
function_name = aws_lambda_function.demo_lambda.function_name
authorization_type = "NONE"
}
resource "aws_elasticsearch_domain" "demo_es_domain" {
domain_name = "demo-domain"
elasticsearch_version = "7.10"
}
resource "aws_kinesis_stream" "demo_kinesis_stream" {
name = "demo-kinesis-stream"
shard_count = "1"
}
resource "aws_s3_bucket" "demo_skipped_docs_bucket" {
bucket = "demo-skipped-docs-bucket"
}
resource "aws_kinesis_firehose_delivery_stream" "demo_firehose_stream" {
name = "demo-firehose-delivery-stream"
destination = "elasticsearch"
s3_configuration {
role_arn = aws_iam_role.firehose_role.arn
bucket_arn = aws_s3_bucket.demo_skipped_docs_bucket.arn
}
kinesis_source_configuration {
kinesis_stream_arn = aws_kinesis_stream.demo_kinesis_stream.arn
role_arn = aws_iam_role.firehose_role.arn
}
elasticsearch_configuration {
domain_arn = aws_elasticsearch_domain.demo_es_domain.arn
role_arn = aws_iam_role.firehose_role.arn
index_name = "test"
type_name = "test"
}
}