-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
94 lines (71 loc) · 2.77 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
84
85
86
87
88
89
90
91
92
93
94
module "iam" {
source = "./modules/iam"
lambda_iam_role_name = var.lambda_iam_role_name
}
module "lambda" {
source = "./modules/image_upload/lambda"
lambda_execution_role_arn = module.iam.lambda_execution_role_arn
api_gateway_execution_arn = module.api_gateway.execution_arn
bucket_name = local.s3_bucket_name
api_url = var.api_url
create_problem_lambda_function_name = var.create_problem_lambda_function_name
create_problem_lambda_function_code_path = var.create_problem_lambda_function_code_path
get_presigned_url_lambda_function_name = var.get_presigned_url_lambda_function_name
get_presigned_url_lambda_function_code_path = var.get_presigned_url_lambda_function_code_path
image_domain_name = module.cloudfront.cloudfront_domain_name
}
module "api_gateway" {
source = "./modules/api_gateway"
lambda_function_arn = module.lambda.lambda_function_arn
create_problem_lambda_arn = module.lambda.create_problem_lambda_arn
aws_region = var.aws_region
stage_name = var.env_name
api_gateway_name = var.api_gateway_name
}
module "s3" {
source = "./modules/image_upload/s3"
s3_bucket_name = local.s3_bucket_name
origin_access_identity_arn = module.cloudfront.oai_arn
}
module "cloudfront" {
source = "./modules/cloudfront"
env_name = var.env_name
s3_bucket_domain_name = module.s3.bucket_regional_domain_name
s3_bucket_name = local.s3_bucket_name
s3_bucket_arn = module.s3.bucket_arn
video_s3_bucket_name = module.video_upload.video_output_bucket_name
video_s3_bucket_domain_name = module.video_upload.video_output_bucket_domain_name
}
resource "local_file" "index_html" {
content = local.rendered_index_html
filename = "${path.module}/src/problem_upload_website/index.html"
}
resource "aws_s3_object" "index" {
bucket = local.s3_bucket_name
key = "index.html"
source = local_file.index_html.filename
content_type = "text/html"
depends_on = [ module.s3.bucket_name, local_file.index_html ]
}
# video upload
module "video_upload" {
source = "./modules/video_upload"
aws_region = var.aws_region
env_name = var.env_name
account_id = local.account_id
lambda_execution_role_arn = module.iam.lambda_execution_role_arn
api_gateway_execution_arn = module.api_gateway.execution_arn
rest_api_id = module.api_gateway.rest_api_id
root_resource_id = module.api_gateway.root_resource_id
origin_access_identity_arn = module.cloudfront.oai_arn
api_server_url = var.api_url
cloudfront_domain = module.cloudfront.cloudfront_domain_name
}
# network
module "network" {
source = "./modules/network2"
env_suffix = var.env_name
account_id = local.account_id
region = var.aws_region
domain = var.domain_name
}