-
Notifications
You must be signed in to change notification settings - Fork 1k
Add s3-sqs-lambda-terraform pattern #2360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add s3-sqs-lambda-terraform pattern #2360
Conversation
Hi @enmata and thanks for the PR. We already have two Terraform patterns that cover this behaviour: S3 -> SQS (https://serverlessland.com/patterns/s3-sqs-cdk-terraform) and SQS -> Lambda (https://serverlessland.com/patterns/sqs-lambda-terraform-python). |
s3-sqs-lambda-terraform/README.md
Outdated
@@ -0,0 +1,81 @@ | |||
# AWS Amazon S3 Lambda with SQS queue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# AWS Amazon S3 Lambda with SQS queue | |
# Amazon S3 to Amaozn SQS queue to AWS Lambda |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a "to" missing after S3
s3-sqs-lambda-terraform/README.md
Outdated
@@ -0,0 +1,81 @@ | |||
# AWS Amazon S3 Lambda with SQS queue | |||
|
|||
The terraform manifest deploys a Lambda function, an SQS queue, one S3 buckets and the IAM resources required to run the application. Create a Lambda function that is triggered on every new jpg image file stored on s3 Bucket using SQS as a notification target. The Lambda app acts as a Boilerplate code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The terraform manifest deploys a Lambda function, an SQS queue, one S3 buckets and the IAM resources required to run the application. Create a Lambda function that is triggered on every new jpg image file stored on s3 Bucket using SQS as a notification target. The Lambda app acts as a Boilerplate code. | |
The Terraform code deploys an AWS Lambda function, an Amazon SQS queue, one AWS S3 buckets and the AWS IAM resources required to run the application. The created Lambda function is triggered on every new `.jpg` image file uploaded to the S3 bucket using an SQS queue as a notification target. The Lambda function code contains only contains minimal code for demo purposes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this changed in the latest commit, did you forget to include it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, updated.
s3-sqs-lambda-terraform/README.md
Outdated
## How it works | ||
|
||
* Use the AWS CLI or AWS console to upload an image to the source S3 Bucket | ||
* If the object is a .jpg the code, a Lambda that is triggered using SQS as a notification target. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* If the object is a .jpg the code, a Lambda that is triggered using SQS as a notification target. | |
* If the object is a .jpg file, the Lambda function is triggered using SQS as a notification target. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this changed in the latest commit, did you forget to include it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, updated.
s3-sqs-lambda-terraform/README.md
Outdated
|
||
## Testing | ||
|
||
Run the following S3 CLI command to upload an image to the S3 bucket. Note, you must edit the {SourceBucketName} placeholder with the name of the source S3 Bucket. This is provided in the stack outputs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run the following S3 CLI command to upload an image to the S3 bucket. Note, you must edit the {SourceBucketName} placeholder with the name of the source S3 Bucket. This is provided in the stack outputs. | |
Run the following AWS CLI command to upload an image to the S3 bucket. Note, you must edit the {SourceBucketName} placeholder with the name of the source S3 bucket. This is provided in the stack outputs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, updated.
s3-sqs-lambda-terraform/README.md
Outdated
|
||
## Documentations and next step | ||
|
||
To create a full Step Functions workflow with the pattern created, you can find out example workflows at Step Functions Workflow: [serverlessland.com/workflows](https://serverlessland.com/workflows) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To create a full Step Functions workflow with the pattern created, you can find out example workflows at Step Functions Workflow: [serverlessland.com/workflows](https://serverlessland.com/workflows) | |
To expand the Step Functions workflow that the pattern created, you can find out example workflows at Step Functions Workflow: [serverlessland.com/workflows](https://serverlessland.com/workflows) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, updated.
s3-sqs-lambda-terraform/main.tf
Outdated
function_name = "s3-sqs-lambda-tf-LambdaFunction" | ||
role = aws_iam_role.MyHandlerFunction-Role.arn | ||
handler = "app.handler" | ||
runtime = "nodejs16.x" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Nodejs v16 runtime is deprecated https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html
Please use the latest Nodejs runtime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upgrading it
console.log('value2 =', event.key2); | ||
console.log('value3 =', event.key3); | ||
return event.key1; // Echo back the first key value | ||
// throw new Error('Something went wrong'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unnecessary line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I Agree, removing it
Code updated with agreed changes |
Sorry, I forget to add comments changes. Now its updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just one typo left. However, you are missing the example-pattern.json
.
Use the model template located at https://github.com/aws-samples/serverless-patterns/tree/main/_pattern-model to set up a README, template and any associated code.
THIS PROCESS HAS BEEN SIMPLIFIED. All the information below must be provided in the "example-pattern.json" file cloned from the model **
The above text is taken from the new pattern template.
s3-sqs-lambda-terraform/README.md
Outdated
@@ -0,0 +1,81 @@ | |||
# Amazon S3 to Amaozn SQS queue to AWS Lambda |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Amazon S3 to Amaozn SQS queue to AWS Lambda | |
# Amazon S3 to Amazon SQS queue to AWS Lambda |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo fixed, thanks.
example-pattern.json file added as an attachment on initial post on these PR. Do you want me do add it on the commit?
Thanks for the update. To be clear, the example-pattern.json file must be added to the PR and filled out by you with corresponding values, e.g. language, level, relevant links etc. |
Added example-pattern.json |
{ | ||
"title": "S3 to Step Functions using EventBridge", | ||
"description": "How to create an EventBridge rule with S3 as the event source and Step Functions as target.", | ||
"language": "nodejs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"language": "nodejs", | |
"language": "Node.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, changed
@@ -0,0 +1,61 @@ | |||
{ | |||
"title": "S3 to Step Functions using EventBridge", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the same title as in the README
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry bout the confusion, updated.
@@ -0,0 +1,61 @@ | |||
{ | |||
"title": "S3 to Step Functions using EventBridge", | |||
"description": "How to create an EventBridge rule with S3 as the event source and Step Functions as target.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the description to match the contents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry bout the confusion, updated.
"level": "200", | ||
"framework": "Terraform", | ||
"introBox": { | ||
"headline": "How to create an EventBridge rule with S3 as the event source and Step Functions as target.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update to match the actual pattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry bout the confusion, updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still seems to be unresolved
"This sample project demonstrates how you can trigger an execution in Step Functions state machine when an object is created in an S3 bucket.", | ||
"When you uploads an object to the newly created S3 bucket, this will send an `Object Created` event to EventBridge, based on the EventBridge rule, the state machine is executed.", | ||
"This pattern deploys one Step Functions state machine, one S3 bucket, one EventBridge rule." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry bout the confusion, updated.
"text": "AWS S3 Event Notifications with EventBridge", | ||
"link": "https://aws.amazon.com/blogs/aws/new-use-amazon-s3-event-notifications-with-amazon-eventbridge" | ||
}, | ||
{ | ||
"text": "Using EventBridge with S3", | ||
"link": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/EventBridge.html" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update with relevant links
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
}, | ||
"cleanup": { | ||
"text": [ | ||
"terraform destroy" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"terraform destroy" | |
"<code>terraform destroy</code>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, all code commands updated
"name": "Oriol Matavacas", | ||
"image": "https://togithub.s3.eu-west-1.amazonaws.com/Oriol.jpg", | ||
"bio": "Oriol Matavacas is a Sr. Solutions Architect at AWS based in Barcelona. Oriol primarily supporting customers on the journey to the Cloud. He enjoys building new solutions with scalability, availability and easy to maintain by using serverless.", | ||
"linkedin": "https://www.linkedin.com/in/oriol-matavacas-rodriguez-b165868a", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"linkedin": "https://www.linkedin.com/in/oriol-matavacas-rodriguez-b165868a", | |
"linkedin": "oriol-matavacas-rodriguez-b165868a", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Thanks for the comments and sorry bout the confusion. Now its updated. |
"level": "200", | ||
"framework": "Terraform", | ||
"introBox": { | ||
"headline": "How to create an EventBridge rule with S3 as the event source and Step Functions as target.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still seems to be unresolved
"text": [ | ||
"The terraform manifest deploys a Lambda function, an SQS queue, one S3 bucket and the IAM resources required to run the application.", | ||
"An SQS queue consumes ObjectCreated events from an Amazon S3 bucket if the file has .jpg extension. The SQS triggers a Lambda function.", | ||
"The Lambda app acts as a boilerplate code.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explanation updated
"text": "S3-to-Lambda serverless applications", | ||
"link": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/EventBridge.html" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link and text don't seem to match
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note that this is still resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
"bullets": [ | ||
{ | ||
"text": "Building resilient serverless patterns by combining messaging services", | ||
"link": "https://github.com/aws-samples/s3-to-lambda-patterns" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link is outdated and doesn't really match the text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the heads up, reference updated
Thanks for the comments, now updated its updated again. |
Changes applied. Please check when you have a moment. |
@@ -0,0 +1,61 @@ | |||
{ | |||
"title": "AWS Amazon S3 Lambda with SQS queue", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"title": "AWS Amazon S3 Lambda with SQS queue", | |
"title": "Amazon S3 to AWS Lambda with Amazon SQS queue", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, changes applied
@@ -0,0 +1,61 @@ | |||
{ | |||
"title": "AWS Amazon S3 Lambda with SQS queue", | |||
"description": "Create a Lambda function triggered for every jpg image file stored to S3 via SQS.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"description": "Create a Lambda function triggered for every jpg image file stored to S3 via SQS.", | |
"description": "Create a Lambda function that is triggered for every jpg image file uploaded to S3 via an SQS queue.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, changes applied
{ | ||
"title": "AWS Amazon S3 Lambda with SQS queue", | ||
"description": "Create a Lambda function triggered for every jpg image file stored to S3 via SQS.", | ||
"language": "node.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"language": "node.js", | |
"language": "Node.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uppercase now
"level": "200", | ||
"framework": "Terraform", | ||
"introBox": { | ||
"headline": "Create a Lambda function triggered for every jpg image file stored to S3 via SQS", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The headline needs to stay below 75 characters, please reword
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compressed and resumed now. Please check
"link": "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-configure-lambda-function-trigger.html", | ||
}, | ||
{ | ||
"text": "Amazon Simple Storage Service (S3) -> User Guide -> Using EventBridge", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does EventBridge relate to the rest of the pattern? It isn't mentioned anywhere else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right and sorry for that. Reference deleted.
"<code>terraform init</code>", | ||
"<code>terraform apply</code>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tags can be removed here as they are automatically added to the
deploy
field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected
Thanks for the comments, changes applied. Please, could you review again? |
Looks good, thanks for your contribution. Your pattern will be merged to Serverlessland.com soon |
Issue #, if available:
Adding s3-sqs-lambda-terraform pattern
Description of changes:
Adding the terraform version of Add s3-sqs-lambda pattern
https://serverlessland.com/patterns/s3-sqs-lambda?ref=search
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
example-pattern.json