-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
62 lines (54 loc) · 1.7 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
# DynamoDB Table
module "posts_ddb" {
source = "./modules/dynamodb"
table_name = var.posts_ddb_name
billing_mode = var.billing_mode
read_capacity = var.read_capacity
write_capacity = var.write_capacity
hash_key = "id"
hash_key_type = "S"
additional_tags = var.posts_ddb_additional_tags
}
# Create NewPost Function
module "new_post_lambda" {
source = "./modules/lambda"
function_name = "NewPost"
lambda_handler = "index.handler"
environment_variables = {
"POSTS_TABLE" = module.posts_ddb.name
"SNS_TOPIC" = aws_sns_topic.new_posts.arn
}
}
# Create GetPost Function
module "get_post_lambda" {
source = "./modules/lambda"
function_name = "GetPost"
lambda_handler = "index.handler"
environment_variables = {
"POSTS_TABLE" = module.posts_ddb.name
}
}
# Create ConvertToAudio Function
module "convert_post_to_audio_lambda" {
source = "./modules/lambda"
function_name = "ConvertToAudio"
lambda_handler = "index.handler"
environment_variables = {
"POSTS_TABLE" = module.posts_ddb.name
"BUCKET_NAME" = "${aws_s3_bucket.audio_posts.id}"
}
}
module "api_gateway" {
source = "./modules/api-gw"
api_gateway_region = var.region
rest_api_name = "posts"
api_gateway_account_id = data.aws_caller_identity.current.account_id
get_post_lambda_function_name = module.get_post_lambda.function_name
get_post_lambda_function_arn = module.get_post_lambda.function_invoke_arn
new_post_lambda_function_name = module.new_post_lambda.function_name
new_post_lambda_function_arn = module.new_post_lambda.function_invoke_arn
depends_on = [
module.get_post_lambda,
module.new_post_lambda
]
}