Skip to content

Commit 2129bdf

Browse files
committed
setup sqs queues
1 parent 12f053b commit 2129bdf

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

cloudformation/main.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ Resources:
8383
LambdaFunctionName: !Sub ${ApplicationPrefix}-lambda
8484
LogRetentionDays: !FindInMap [General, !Ref RunEnvironment, LogRetentionDays]
8585

86+
AppSQSQueues:
87+
Type: AWS::Serverless::Application
88+
Properties:
89+
Location: ./sqs.yml
90+
Parameters:
91+
QueueName: !Sub ${ApplicationPrefix}-sqs
92+
93+
8694
IcalDomainProxy:
8795
Type: AWS::Serverless::Application
8896
Properties:
@@ -149,6 +157,31 @@ Resources:
149157
Path: /{proxy+}
150158
Method: ANY
151159

160+
AppSqsLambdaFunction:
161+
Type: AWS::Serverless::Function
162+
DependsOn:
163+
- AppLogGroups
164+
Properties:
165+
Architectures: [arm64]
166+
CodeUri: ../dist/sqsConsumer
167+
AutoPublishAlias: live
168+
Runtime: nodejs22.x
169+
Description: !Sub "${ApplicationFriendlyName} SQS Lambda"
170+
FunctionName: !Sub ${ApplicationPrefix}-sqs-lambda
171+
Handler: index.handler
172+
MemorySize: 512
173+
Role: !GetAtt AppSecurityRoles.Outputs.MainFunctionRoleArn
174+
Timeout: 900
175+
LoggingConfig:
176+
LogGroup: !Sub /aws/lambda/${LambdaFunctionName}
177+
Environment:
178+
Variables:
179+
RunEnvironment: !Ref RunEnvironment
180+
VpcConfig:
181+
Ipv6AllowedForDualStack: !If [ShouldAttachVpc, True, !Ref AWS::NoValue]
182+
SecurityGroupIds: !If [ShouldAttachVpc, !FindInMap [EnvironmentToCidr, !Ref RunEnvironment, SecurityGroupIds], !Ref AWS::NoValue]
183+
SubnetIds: !If [ShouldAttachVpc, !FindInMap [EnvironmentToCidr, !Ref RunEnvironment, SubnetIds], !Ref AWS::NoValue]
184+
152185
IamGroupRolesTable:
153186
Type: 'AWS::DynamoDB::Table'
154187
DeletionPolicy: "Retain"

cloudformation/sqs.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Description: Stack SQS Queues
3+
Transform: AWS::Serverless-2016-10-31
4+
Parameters:
5+
QueueName:
6+
Type: String
7+
AllowedPattern: ^[a-zA-Z0-9]+[a-zA-Z0-9-]+[a-zA-Z0-9]+$
8+
Resources:
9+
AppDLQ:
10+
Type: AWS::SQS::Queue
11+
Properties:
12+
QueueName: !Sub ${QueueName}-dlq
13+
AppQueue:
14+
Type: AWS::SQS::Queue
15+
Properties:
16+
QueueName: !Ref QueueName
17+
RedrivePolicy:
18+
deadLetterTargetArn:
19+
Fn::GetAtt:
20+
- "AppDLQ"
21+
- "Arn"
22+
23+
Outputs:
24+
MainQueueArn:
25+
Description: Main Queue Arn
26+
Value:
27+
Fn::GetAtt:
28+
- AppQueue
29+
- Arn
30+
DLQArn:
31+
Description: Dead-letter Queue Arn
32+
Value:
33+
Fn::GetAtt:
34+
- AppDLQ
35+
- Arn

src/api/sqs/logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
import { pino } from "pino";
2-
export const logger = pino();
2+
export const logger = pino().child({ context: "sqsHandler" });

0 commit comments

Comments
 (0)