File tree Expand file tree Collapse file tree 8 files changed +112
-34
lines changed Expand file tree Collapse file tree 8 files changed +112
-34
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,11 @@ resource "aws_apigatewayv2_stage" "main" {
9
9
name = " $default"
10
10
auto_deploy = true
11
11
12
+ access_log_settings {
13
+ destination_arn = aws_cloudwatch_log_group. api_gateway_access_logs . arn
14
+ format = " $context.identity.sourceIp - [$context.requestTime] \" $context.routeKey $context.protocol\" $context.status $context.responseLength $context.requestId"
15
+ }
16
+
12
17
tags = {
13
18
Name = " SOAT-TC API Default Stage"
14
19
}
Original file line number Diff line number Diff line change @@ -5,3 +5,10 @@ resource "aws_apigatewayv2_integration" "debug_integration" {
5
5
integration_method = " ANY"
6
6
integration_uri = " https://example.com/"
7
7
}
8
+
9
+
10
+ resource "aws_apigatewayv2_vpc_link" "load_balancer" {
11
+ name = " SOAT-TC API Gateway Private Subnets VPC Link"
12
+ subnet_ids = aws_subnet. private_subnets [* ]. id
13
+ security_group_ids = [aws_default_security_group . default . id ]
14
+ }
Original file line number Diff line number Diff line change @@ -4,3 +4,28 @@ resource "aws_apigatewayv2_route" "debug_route" {
4
4
5
5
target = " integrations/${ aws_apigatewayv2_integration . debug_integration . id } "
6
6
}
7
+
8
+
9
+ resource "aws_apigatewayv2_route" "client_identification" {
10
+ api_id = aws_apigatewayv2_api. main . id
11
+ route_key = " POST /identification/clients/identification"
12
+ // Identification Lambda integration
13
+ }
14
+
15
+ resource "aws_apigatewayv2_route" "order_checkout" {
16
+ api_id = aws_apigatewayv2_api. main . id
17
+ route_key = " POST /order/orders"
18
+ // Client Lambda Authorizer integration
19
+ }
20
+
21
+ resource "aws_apigatewayv2_route" "order_confirmation" {
22
+ api_id = aws_apigatewayv2_api. main . id
23
+ route_key = " POST /payment/payments/initialize"
24
+ // Client Lambda Authorizer integration
25
+ }
26
+
27
+ resource "aws_apigatewayv2_route" "forward_to_alb_route" {
28
+ api_id = aws_apigatewayv2_api. main . id
29
+ route_key = " ANY /{proxy+}"
30
+ // Private Resource integration (vpc link + alb)
31
+ }
Original file line number Diff line number Diff line change
1
+ # Allow API Gateway to push logs to CloudWatch
2
+ resource "aws_api_gateway_account" "main" {
3
+ cloudwatch_role_arn = data. aws_iam_role . lab_role . arn
4
+ }
5
+
6
+ resource "aws_cloudwatch_log_group" "api_gateway_access_logs" {
7
+ name = " /aws/apigateway/SOAT-TC_API_Gateway_Access_Logs"
8
+ retention_in_days = 30
9
+ }
Original file line number Diff line number Diff line change 1
-
1
+ # AWS Academy Vocareum AWS Learner Lab
2
+ data "aws_iam_role" "lab_role" {
3
+ name = " LabRole"
4
+ }
Original file line number Diff line number Diff line change @@ -12,12 +12,12 @@ terraform {
12
12
required_providers {
13
13
aws = {
14
14
source = " hashicorp/aws"
15
- version = " 4.67 .0"
15
+ version = " 5.34 .0"
16
16
}
17
17
18
18
tfe = {
19
19
source = " hashicorp/tfe"
20
- version = " ~> 0.49.2 "
20
+ version = " ~> 0.51.1 "
21
21
}
22
22
}
23
23
}
Original file line number Diff line number Diff line change @@ -74,3 +74,32 @@ resource "aws_route_table_association" "private_rt_association" {
74
74
subnet_id = element (aws_subnet. private_subnets [* ]. id , count. index )
75
75
route_table_id = aws_route_table. private_rt . id
76
76
}
77
+
78
+ resource "aws_vpc_endpoint" "dynamodb" {
79
+ service_name = " com.amazonaws.${ var . aws_region } .dynamodb"
80
+ vpc_id = aws_vpc. main . id
81
+
82
+ route_table_ids = [aws_route_table . public_rt . id ]
83
+
84
+ tags = {
85
+ Name = " SOAT-TC DynamoDB VPC Gateway Endpoint"
86
+ }
87
+ }
88
+
89
+ resource "aws_default_security_group" "default" {
90
+ vpc_id = aws_vpc. main . id
91
+
92
+ ingress {
93
+ protocol = - 1
94
+ self = true
95
+ from_port = 0
96
+ to_port = 0
97
+ }
98
+
99
+ egress {
100
+ from_port = 0
101
+ to_port = 0
102
+ protocol = " -1"
103
+ cidr_blocks = [" 0.0.0.0/0" ]
104
+ }
105
+ }
You can’t perform that action at this time.
0 commit comments