Skip to content

Commit 2e87ccc

Browse files
committed
create the appropriate roles
1 parent cbe7abc commit 2e87ccc

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ build: src/ cloudformation/ docs/
5454
yarn -D
5555
VITE_BUILD_HASH=$(GIT_HASH) yarn build
5656
cp -r src/api/resources/ dist/api/resources
57+
rm -rf dist/lambda/sqs
5758
sam build --template-file cloudformation/main.yml
5859

5960
local:

cloudformation/iam.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Resources:
1616
ApiLambdaIAMRole:
1717
Type: AWS::IAM::Role
1818
Properties:
19+
ManagedPolicyArns:
20+
- arn:aws:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole
1921
AssumeRolePolicyDocument:
2022
Version: '2012-10-17'
2123
Statement:

cloudformation/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ Resources:
182182
SecurityGroupIds: !If [ShouldAttachVpc, !FindInMap [EnvironmentToCidr, !Ref RunEnvironment, SecurityGroupIds], !Ref AWS::NoValue]
183183
SubnetIds: !If [ShouldAttachVpc, !FindInMap [EnvironmentToCidr, !Ref RunEnvironment, SubnetIds], !Ref AWS::NoValue]
184184

185+
SQSLambdaEventMapping:
186+
Type: AWS::Lambda::EventSourceMapping
187+
Properties:
188+
BatchSize: 5
189+
EventSourceArn: !GetAtt AppSecurityRoles.Outputs.MainQueueArn
190+
FunctionName: !Sub ${ApplicationPrefix}-sqs-lambda
191+
185192
IamGroupRolesTable:
186193
Type: 'AWS::DynamoDB::Table'
187194
DeletionPolicy: "Retain"

src/api/build.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ const commonParams = {
3333
esbuild
3434
.build({
3535
...commonParams,
36-
entryPoints: ["api/lambda.js", "api/index.js"],
36+
entryPoints: ["api/lambda.js"],
3737
outdir: "../../dist/lambda/",
38+
external: [...commonParams.external, "sqs/*"],
3839
})
3940
.then(() => console.log("API server build completed successfully!"))
4041
.catch((error) => {

0 commit comments

Comments
 (0)