Skip to content

Commit 4130d12

Browse files
Setup ECR Terraform, update GitHub Actions for OIDC
1 parent 47ebc15 commit 4130d12

3 files changed

Lines changed: 79 additions & 0 deletions

File tree

terraform/.terraform.lock.hcl

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

terraform/lambda.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ resource "aws_lambda_function" "crud_api" {
2020
}
2121
}
2222

23+

terraform/security_groups.tf

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# terraform/security_groups.tf
2+
3+
# Lambda security group
4+
resource "aws_security_group" "lambda_sg" {
5+
name = "lambda-sg"
6+
description = "Security group for Lambda functions"
7+
vpc_id = aws_vpc.main.id # replace with your VPC resource
8+
9+
# Outbound to anywhere (for now)
10+
egress {
11+
from_port = 0
12+
to_port = 0
13+
protocol = "-1"
14+
cidr_blocks = ["0.0.0.0/0"]
15+
}
16+
17+
# Inbound rules (if Lambda needs to receive traffic from VPC resources)
18+
ingress {
19+
from_port = 5432 # RDS PostgreSQL port
20+
to_port = 5432
21+
protocol = "tcp"
22+
security_groups = [aws_security_group.rds_sg.id] # allow Lambda → RDS
23+
}
24+
25+
tags = {
26+
Project = "Serverless CRUD API"
27+
}
28+
}
29+
30+
# RDS security group
31+
resource "aws_security_group" "rds_sg" {
32+
name = "rds-sg"
33+
description = "Security group for RDS PostgreSQL"
34+
vpc_id = aws_vpc.main.id
35+
36+
ingress {
37+
from_port = 5432
38+
to_port = 5432
39+
protocol = "tcp"
40+
security_groups = [aws_security_group.lambda_sg.id] # allow Lambda → RDS
41+
}
42+
43+
egress {
44+
from_port = 0
45+
to_port = 0
46+
protocol = "-1"
47+
cidr_blocks = ["0.0.0.0/0"]
48+
}
49+
50+
tags = {
51+
Project = "Serverless CRUD API"
52+
}
53+
}

0 commit comments

Comments
 (0)