-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #776 from garethmcc/v4
feat: add updated starter templates for SF V.4
- Loading branch information
Showing
24 changed files
with
54 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
'use strict'; | ||
|
||
module.exports.run = async (event, context) => { | ||
exports.run = async (event, context) => { | ||
const time = new Date(); | ||
console.log(`Your cron function "${context.functionName}" ran at ${time}`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,5 @@ | ||
const { SQS } = require("aws-sdk"); | ||
|
||
const sqs = new SQS(); | ||
|
||
const producer = async (event) => { | ||
let statusCode = 200; | ||
let message; | ||
|
||
if (!event.body) { | ||
return { | ||
statusCode: 400, | ||
body: JSON.stringify({ | ||
message: "No body was found", | ||
}), | ||
}; | ||
} | ||
|
||
try { | ||
await sqs | ||
.sendMessage({ | ||
QueueUrl: process.env.QUEUE_URL, | ||
MessageBody: event.body, | ||
MessageAttributes: { | ||
AttributeName: { | ||
StringValue: "Attribute Value", | ||
DataType: "String", | ||
}, | ||
}, | ||
}) | ||
.promise(); | ||
|
||
message = "Message accepted!"; | ||
} catch (error) { | ||
console.log(error); | ||
message = error; | ||
statusCode = 500; | ||
} | ||
|
||
return { | ||
statusCode, | ||
body: JSON.stringify({ | ||
message, | ||
}), | ||
}; | ||
}; | ||
|
||
const consumer = async (event) => { | ||
exports.consumer = async (event) => { | ||
for (const record of event.Records) { | ||
const messageAttributes = record.messageAttributes; | ||
console.log( | ||
"Message Attribute: ", | ||
messageAttributes.AttributeName.stringValue | ||
); | ||
console.log("Message Body: ", record.body); | ||
} | ||
}; | ||
|
||
module.exports = { | ||
producer, | ||
consumer, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,21 @@ | ||
service: aws-node-sqs-worker | ||
frameworkVersion: '2 || 3' | ||
frameworkVersion: '4' | ||
|
||
provider: | ||
name: aws | ||
runtime: nodejs12.x | ||
runtime: nodejs20.x | ||
lambdaHashingVersion: '20201221' | ||
|
||
constructs: | ||
jobs: | ||
type: queue | ||
worker: | ||
handler: handler.consumer | ||
|
||
functions: | ||
producer: | ||
handler: handler.producer | ||
handler: handler.consumer | ||
events: | ||
- httpApi: | ||
method: post | ||
path: /produce | ||
environment: | ||
QUEUE_URL: ${construct:jobs.queueUrl} | ||
- sqs: arn:aws:sqs:${aws:region}:${aws:accountId}:MyFirstQueue | ||
|
||
resources: | ||
Resources: | ||
JobQueue: | ||
Type: AWS::SQS::Queue | ||
Properties: | ||
QueueName: MyFirstQueue | ||
|
||
plugins: | ||
- serverless-lift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Flask==1.1.4 | ||
Werkzeug==1.0.1 | ||
|
||
markupsafe==2.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Flask==1.1.4 | ||
Werkzeug==1.0.1 | ||
|
||
markupsafe==2.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters