Skip to content

Commit 924076f

Browse files
committed
feat: integrations draft, logs, vpc link, etc
1 parent 460a275 commit 924076f

File tree

8 files changed

+112
-34
lines changed

8 files changed

+112
-34
lines changed

.terraform.lock.hcl

Lines changed: 31 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api-gateway.tf renamed to api_gateway.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ resource "aws_apigatewayv2_stage" "main" {
99
name = "$default"
1010
auto_deploy = true
1111

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+
1217
tags = {
1318
Name = "SOAT-TC API Default Stage"
1419
}

api_gateway_integrations.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,10 @@ resource "aws_apigatewayv2_integration" "debug_integration" {
55
integration_method = "ANY"
66
integration_uri = "https://example.com/"
77
}
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+
}

api_gateway_routes.tf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,28 @@ resource "aws_apigatewayv2_route" "debug_route" {
44

55
target = "integrations/${aws_apigatewayv2_integration.debug_integration.id}"
66
}
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+
}

cloudwatch.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
}

datasources.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
1+
# AWS Academy Vocareum AWS Learner Lab
2+
data "aws_iam_role" "lab_role" {
3+
name = "LabRole"
4+
}

providers.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ terraform {
1212
required_providers {
1313
aws = {
1414
source = "hashicorp/aws"
15-
version = "4.67.0"
15+
version = "5.34.0"
1616
}
1717

1818
tfe = {
1919
source = "hashicorp/tfe"
20-
version = "~> 0.49.2"
20+
version = "~> 0.51.1"
2121
}
2222
}
2323
}

vpc.tf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,32 @@ resource "aws_route_table_association" "private_rt_association" {
7474
subnet_id = element(aws_subnet.private_subnets[*].id, count.index)
7575
route_table_id = aws_route_table.private_rt.id
7676
}
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+
}

0 commit comments

Comments
 (0)