Skip to content

Commit a22b3c7

Browse files
committed
add sg
1 parent 7570066 commit a22b3c7

File tree

8 files changed

+89
-52
lines changed

8 files changed

+89
-52
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
resource "aws_security_group" "allow_sftp_egress" {
2+
name = "${local.csi}-sftp-egress"
3+
vpc_id = module.vpc.vpc_id
4+
description = "Security group for allowing outbound traffic to SFTP"
5+
6+
tags = {
7+
Name = "${local.csi}-sftp-egress"
8+
}
9+
}
10+
11+
resource "aws_security_group_rule" "allow_sftp_egress_ssh" {
12+
description = "Allow SFTP egress within VPC on port 22"
13+
type = "egress"
14+
from_port = 22
15+
to_port = 22
16+
protocol = "tcp"
17+
cidr_blocks = ["0.0.0.0/0"]
18+
security_group_id = aws_security_group.allow_sftp_egress.id
19+
}
20+
21+
resource "aws_security_group_rule" "allow_sftp_egress_https" {
22+
description = "Allow SFTP egress within VPC on port 443"
23+
type = "egress"
24+
from_port = 443
25+
to_port = 443
26+
protocol = "tcp"
27+
cidr_blocks = ["0.0.0.0/0"]
28+
security_group_id = aws_security_group.allow_sftp_egress.id
29+
}

infrastructure/terraform/components/app/data_vpc_account_vpc.tf

Lines changed: 0 additions & 25 deletions
This file was deleted.

infrastructure/terraform/components/sandbox/data_vpc_account_vpc.tf

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
data "aws_vpc" "account_vpc" {
3+
tags = {
4+
Component = "acct"
5+
}
6+
}
7+
8+
data "aws_subnets" "account_vpc_private_subnets" {
9+
filter {
10+
name = "vpc-id"
11+
values = [data.aws_vpc.account_vpc.id]
12+
}
13+
14+
tags = {
15+
Tier = "Private"
16+
}
17+
}
18+
19+
data "aws_security_group" "account_vpc_sg_allow_sftp_egress" {
20+
vpc_id = data.aws_vpc.account_vpc.id
21+
22+
tags = {
23+
Name = "${data.aws_vpc.account_vpc.tags["Project"]}-${data.aws_vpc.account_vpc.tags["Environment"]}-acct-vpc-sftp-egress"
24+
}
25+
}

infrastructure/terraform/modules/backend-api/module_lambda_send_letter_proof.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ module "lambda_send_letter_proof" {
2121
TEMPLATES_TABLE_NAME = aws_dynamodb_table.templates.name
2222
NODE_OPTIONS = "--enable-source-maps",
2323
}
24+
25+
vpc = {
26+
id = data.aws_vpc.account_vpc.id
27+
cidr_block = data.aws_vpc.account_vpc.cidr_block
28+
subnet_ids = data.aws_subnets.account_vpc_private_subnets.ids
29+
}
30+
31+
security_group_ids = [
32+
data.aws_security_group.account_vpc_sg_allow_sftp_egress.id
33+
]
2434
}
2535

2636
data "aws_iam_policy_document" "send_letter_proof" {

infrastructure/terraform/modules/lambda-function/lambda_function_main.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,13 @@ resource "aws_lambda_function" "main" {
1818
target_arn = var.dead_letter_target_arn
1919
}
2020
}
21+
22+
dynamic "vpc_config" {
23+
for_each = var.vpc != null ? [1] : []
24+
25+
content {
26+
subnet_ids = var.vpc.subnet_ids
27+
security_group_ids = var.security_group_ids
28+
}
29+
}
2130
}

infrastructure/terraform/modules/lambda-function/variables.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,17 @@ variable "dead_letter_target_arn" {
5858
type = string
5959
default = null
6060
}
61+
62+
variable "vpc" {
63+
description = "VPC details"
64+
type = optional(object({
65+
id = string
66+
cidr_block = string
67+
subnet_ids = set(string)
68+
}))
69+
}
70+
71+
variable "security_group_ids" {
72+
type = list(string)
73+
default = []
74+
}

utils/test-helper-utils/src/mock-logger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import winston from 'winston';
22
import { Writable } from 'node:stream';
33

4-
const { combine, timestamp, json } = winston.format;
4+
const { combine, timestamp, json, errors } = winston.format;
55

66
export function createMockLogger() {
77
const logMessages: { msg?: string } & Record<string, unknown>[] = [];
88

99
const logger = winston.createLogger({
1010
level: 'info',
11-
format: combine(timestamp(), json()),
11+
format: combine(timestamp(), json(), errors({ stack: true, cause: true })),
1212
transports: [
1313
new winston.transports.Stream({
1414
stream: new Writable({

0 commit comments

Comments
 (0)