From 877825432ed50754067f7db313a0cf0080e95fd2 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 8 Jul 2024 07:22:19 +0000 Subject: [PATCH 01/11] Add s3-sqs-lambda-terraform pattern --- s3-sqs-lambda-terraform/README.md | 81 +++++++++++++ s3-sqs-lambda-terraform/main.tf | 173 ++++++++++++++++++++++++++++ s3-sqs-lambda-terraform/src/app.mjs | 10 ++ 3 files changed, 264 insertions(+) create mode 100644 s3-sqs-lambda-terraform/README.md create mode 100644 s3-sqs-lambda-terraform/main.tf create mode 100644 s3-sqs-lambda-terraform/src/app.mjs diff --git a/s3-sqs-lambda-terraform/README.md b/s3-sqs-lambda-terraform/README.md new file mode 100644 index 000000000..04a799269 --- /dev/null +++ b/s3-sqs-lambda-terraform/README.md @@ -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. + +Learn more about this pattern at Serverless Land Patterns: [serverlessland.com/patterns/s3-sqs-lambda-terraform](https://serverlessland.com/patterns/s3-sqs-lambda-terraform) + +Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the [AWS Pricing page](https://aws.amazon.com/pricing/) for details. You are responsible for any AWS costs incurred. No warranty is implied in this example. + + +## Requirements + +* [Create an AWS account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources. +* [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) installed and configured +* [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) +* [Terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started) installed + + +## Deployment Instructions + +1. Create a new directory, navigate to that directory in a terminal and clone the GitHub repository: + ``` + git clone https://github.com/aws-samples/serverless-patterns + ``` +1. Change directory to the pattern directory: + ``` + cd s3-sqs-lambda-terraform + ``` +1. From the command line, initialize terraform to to downloads and installs the providers defined in the configuration: + ``` + terraform init + ``` +1. From the command line, apply the configuration in the main.tf file: + ``` + terraform apply + ``` +1. During the prompts: + * Enter yes +1. Note the outputs from the deployment process. These contain the resource names and/or ARNs which are used for testing. + + +## 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. + +## 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. + +```bash +aws s3 cp './events/exampleImage.png' s3://{SourceBucketName} +``` + +## 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) + + +## Cleanup + +1. Change directory to the pattern directory: + ``` + cd s3-sqs-lambda-terraform + ``` +1. Delete all files from the S3 bucket +1. Delete all created resources by terraform + ```bash + terraform destroy + ``` +1. During the prompts: + * Enter yes +1. Confirm all created resources has been deleted + ```bash + terraform show + ``` + + +---- +Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. + +SPDX-License-Identifier: MIT-0 \ No newline at end of file diff --git a/s3-sqs-lambda-terraform/main.tf b/s3-sqs-lambda-terraform/main.tf new file mode 100644 index 000000000..96c5cd602 --- /dev/null +++ b/s3-sqs-lambda-terraform/main.tf @@ -0,0 +1,173 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 3.27" + } + } + + required_version = ">= 0.14.9" +} + +data "aws_caller_identity" "current" {} +data "aws_region" "current" {} + + +################################################################# +# S3 Buckets +################################################################# +# Create a new Source S3 bucket +resource "aws_s3_bucket" "MySourceS3Bucket" { + bucket_prefix = "s3-sqs-lambda-tf-sources3bucket-" +} + +# Send notifications to SQS for all events in the bucket +resource "aws_s3_bucket_notification" "MySourceS3BucketNotification" { + bucket = aws_s3_bucket.MySourceS3Bucket.id + + queue { + queue_arn = aws_sqs_queue.MyHandlerQueue.arn + events = [ + "s3:ObjectCreated:*" + ] + filter_suffix = ".jpg" + } + +} + +################################################################# +# SQS - Queue +################################################################# +# Create SQS - Queue +resource "aws_sqs_queue" "MyHandlerQueue" { + name = "s3-sqs-lambda-tf-SQSResizerQueue" +} + +# Create SQS - Policy +resource "aws_sqs_queue_policy" "MyHandlerQueuePolicy" { + queue_url = aws_sqs_queue.MyHandlerQueue.id + + policy = < { + //console.log('Received event:', JSON.stringify(event, null, 2)); + console.log('value1 =', event.key1); + 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'); +}; From 8550a91b271ece43cb12cfb1d1c5b36509e8055f Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 10 Jul 2024 09:04:10 +0000 Subject: [PATCH 02/11] Adding changes after PR comments --- s3-sqs-lambda-terraform/main.tf | 6 +++--- s3-sqs-lambda-terraform/src/app.mjs | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/s3-sqs-lambda-terraform/main.tf b/s3-sqs-lambda-terraform/main.tf index 96c5cd602..cbfeebedb 100644 --- a/s3-sqs-lambda-terraform/main.tf +++ b/s3-sqs-lambda-terraform/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "~> 3.27" + version = "~> 5.57.0" } } @@ -84,7 +84,7 @@ resource "aws_lambda_function" "MyHandlerFunction-Function" { function_name = "s3-sqs-lambda-tf-LambdaFunction" role = aws_iam_role.MyHandlerFunction-Role.arn handler = "app.handler" - runtime = "nodejs16.x" + runtime = "nodejs20.x" } # Create a zip file from the Lambda source code @@ -169,5 +169,5 @@ output "SourceS3BucketName" { } output "LambdaFunctionArn" { value = aws_lambda_function.MyHandlerFunction-Function.arn - description = "ResizerFunction function Arn" + description = "HandlerFunction function Arn" } diff --git a/s3-sqs-lambda-terraform/src/app.mjs b/s3-sqs-lambda-terraform/src/app.mjs index 4776ac0e7..dd2854408 100644 --- a/s3-sqs-lambda-terraform/src/app.mjs +++ b/s3-sqs-lambda-terraform/src/app.mjs @@ -3,8 +3,6 @@ console.log('Loading function'); export const handler = async (event, context) => { //console.log('Received event:', JSON.stringify(event, null, 2)); console.log('value1 =', event.key1); - 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'); }; From ae5feec508a67c975eafc504a6cbd114702b4fa2 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 12 Jul 2024 12:54:54 +0000 Subject: [PATCH 03/11] Adding comments changes after PR discussion --- s3-sqs-lambda-terraform/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/s3-sqs-lambda-terraform/README.md b/s3-sqs-lambda-terraform/README.md index 04a799269..c4dd4ac20 100644 --- a/s3-sqs-lambda-terraform/README.md +++ b/s3-sqs-lambda-terraform/README.md @@ -1,6 +1,6 @@ -# AWS Amazon S3 Lambda with SQS queue +# Amazon S3 to Amaozn SQS queue to AWS Lambda -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. Learn more about this pattern at Serverless Land Patterns: [serverlessland.com/patterns/s3-sqs-lambda-terraform](https://serverlessland.com/patterns/s3-sqs-lambda-terraform) @@ -41,11 +41,11 @@ Important: this application uses various AWS services and there are costs associ ## 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. +* If the object is a .jpg file, the Lambda function is triggered using SQS as a notification target. ## 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. +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. ```bash aws s3 cp './events/exampleImage.png' s3://{SourceBucketName} @@ -53,7 +53,7 @@ aws s3 cp './events/exampleImage.png' s3://{SourceBucketName} ## 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) +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) ## Cleanup @@ -78,4 +78,4 @@ To create a full Step Functions workflow with the pattern created, you can find ---- Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -SPDX-License-Identifier: MIT-0 \ No newline at end of file +SPDX-License-Identifier: MIT-0 From cefa38e51ee18149d618f2eab34882b3d46498e8 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 26 Jul 2024 12:56:26 +0000 Subject: [PATCH 04/11] Fixing typos on README --- s3-sqs-lambda-terraform/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s3-sqs-lambda-terraform/README.md b/s3-sqs-lambda-terraform/README.md index c4dd4ac20..9e2c9d9aa 100644 --- a/s3-sqs-lambda-terraform/README.md +++ b/s3-sqs-lambda-terraform/README.md @@ -1,4 +1,4 @@ -# Amazon S3 to Amaozn SQS queue to AWS Lambda +# Amazon S3 to Amazon SQS queue to AWS Lambda 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. From 4307b2a0b1a77251239992645d2dd8b06d218796 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 29 Jul 2024 07:14:05 +0000 Subject: [PATCH 05/11] Adding example-pattern.json --- s3-sqs-lambda-terraform/example-pattern.json | 61 ++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 s3-sqs-lambda-terraform/example-pattern.json diff --git a/s3-sqs-lambda-terraform/example-pattern.json b/s3-sqs-lambda-terraform/example-pattern.json new file mode 100644 index 000000000..c0c369238 --- /dev/null +++ b/s3-sqs-lambda-terraform/example-pattern.json @@ -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.", + "language": "nodejs", + "level": "200", + "framework": "Terraform", + "introBox": { + "headline": "How to create an EventBridge rule with S3 as the event source and Step Functions as target.", + "text": [ + "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." + ] + }, + "gitHub": { + "template": { + "repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/s3-sqs-lambda-terraform", + "templateURL": "serverless-patterns/s3-sqs-lambda-terraform", + "projectFolder": "s3-sqs-lambda-terraform", + "templateFile": "main.tf" + } + }, + "resources": { + "bullets": [ + { + "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" + } + ] + }, + "deploy": { + "text": [ + "terraform init", + "terraform apply" + ] + }, + "testing": { + "text": [ + "See the GitHub repo for detailed testing instructions." + ] + }, + "cleanup": { + "text": [ + "terraform destroy" + ] + }, + "authors": [ + { + "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", + "twitter": "" + } + ] +} + From 8d6cff02bc82e03abfd7bd13d858e4e534153fbf Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 16 Aug 2024 07:52:29 +0000 Subject: [PATCH 06/11] Fixing example-pattern.json description and bullets with PR comments --- s3-sqs-lambda-terraform/example-pattern.json | 28 ++++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/s3-sqs-lambda-terraform/example-pattern.json b/s3-sqs-lambda-terraform/example-pattern.json index c0c369238..27ec35248 100644 --- a/s3-sqs-lambda-terraform/example-pattern.json +++ b/s3-sqs-lambda-terraform/example-pattern.json @@ -1,15 +1,15 @@ { - "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", + "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", "level": "200", "framework": "Terraform", "introBox": { "headline": "How to create an EventBridge rule with S3 as the event source and Step Functions as target.", "text": [ - "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." + "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.", ] }, "gitHub": { @@ -23,19 +23,19 @@ "resources": { "bullets": [ { - "text": "AWS S3 Event Notifications with EventBridge", - "link": "https://aws.amazon.com/blogs/aws/new-use-amazon-s3-event-notifications-with-amazon-eventbridge" + "text": "Building resilient serverless patterns by combining messaging services", + "link": "https://github.com/aws-samples/s3-to-lambda-patterns" }, { - "text": "Using EventBridge with S3", + "text": "S3-to-Lambda serverless applications", "link": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/EventBridge.html" } ] }, "deploy": { "text": [ - "terraform init", - "terraform apply" + "terraform init", + "terraform apply" ] }, "testing": { @@ -45,15 +45,15 @@ }, "cleanup": { "text": [ - "terraform destroy" + "terraform destroy" ] }, "authors": [ { "name": "Oriol Matavacas", - "image": "https://togithub.s3.eu-west-1.amazonaws.com/Oriol.jpg", + "image": "link-to-your-photo.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", + "linkedin": "oriol-matavacas-rodriguez-b165868a", "twitter": "" } ] From 3d4a499877f30d09de9a77d350898d5371b245a0 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 21 Aug 2024 12:16:38 +0000 Subject: [PATCH 07/11] Updating example-pattern.json as per PR comments --- s3-sqs-lambda-terraform/example-pattern.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/s3-sqs-lambda-terraform/example-pattern.json b/s3-sqs-lambda-terraform/example-pattern.json index 27ec35248..1f2721b3d 100644 --- a/s3-sqs-lambda-terraform/example-pattern.json +++ b/s3-sqs-lambda-terraform/example-pattern.json @@ -5,11 +5,11 @@ "level": "200", "framework": "Terraform", "introBox": { - "headline": "How to create an EventBridge rule with S3 as the event source and Step Functions as target.", + "headline": "Create a Lambda function triggered for every jpg image file stored to S3 via SQS", "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.", + "The Lambda function serve as a pre-configured template, providing a starting point for developing your application." ] }, "gitHub": { @@ -23,8 +23,8 @@ "resources": { "bullets": [ { - "text": "Building resilient serverless patterns by combining messaging services", - "link": "https://github.com/aws-samples/s3-to-lambda-patterns" + "text": "Configuring an Amazon SQS queue to trigger an AWS Lambda function", + "link": "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-configure-lambda-function-trigger.html", }, { "text": "S3-to-Lambda serverless applications", From 3ab54f610c1e435a6529cada7802cf68ba2d4afa Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 26 Aug 2024 16:45:42 +0000 Subject: [PATCH 08/11] Updating example-pattern.json as per PR comments --- s3-sqs-lambda-terraform/example-pattern.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s3-sqs-lambda-terraform/example-pattern.json b/s3-sqs-lambda-terraform/example-pattern.json index 1f2721b3d..ee0f9e754 100644 --- a/s3-sqs-lambda-terraform/example-pattern.json +++ b/s3-sqs-lambda-terraform/example-pattern.json @@ -27,7 +27,7 @@ "link": "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-configure-lambda-function-trigger.html", }, { - "text": "S3-to-Lambda serverless applications", + "text": "Amazon Simple Storage Service (S3) -> User Guide -> Using EventBridge", "link": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/EventBridge.html" } ] From 4e5ed7c473dad7f1bc594466ceb76f6d61aa8623 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 18 Sep 2024 14:23:15 +0000 Subject: [PATCH 09/11] Updating example-pattern.json as per PR comments --- s3-sqs-lambda-terraform/example-pattern.json | 22 ++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/s3-sqs-lambda-terraform/example-pattern.json b/s3-sqs-lambda-terraform/example-pattern.json index ee0f9e754..1a3a16428 100644 --- a/s3-sqs-lambda-terraform/example-pattern.json +++ b/s3-sqs-lambda-terraform/example-pattern.json @@ -1,15 +1,15 @@ { - "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", + "title": "Amazon S3 to AWS Lambda with Amazon SQS queue", + "description": "Create a Lambda function that is triggered for every jpg image file uploaded to S3 via an SQS queue.", + "language": "Node.js", "level": "200", "framework": "Terraform", "introBox": { "headline": "Create a Lambda function triggered for every jpg image file stored to S3 via SQS", "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 function serve as a pre-configured template, providing a starting point for developing your application." + "Terraform deploys Lambda, SQS, S3, and IAM resources.", + "SQS consumes S3 .jpg events, triggering Lambda.", + "Lambda serves as a template for app development." ] }, "gitHub": { @@ -24,18 +24,14 @@ "bullets": [ { "text": "Configuring an Amazon SQS queue to trigger an AWS Lambda function", - "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", - "link": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/EventBridge.html" + "link": "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-configure-lambda-function-trigger.html" } ] }, "deploy": { "text": [ - "terraform init", - "terraform apply" + "terraform init", + "terraform apply" ] }, "testing": { From cc4df543b12e5599a82701d97b4a6c0a863621e8 Mon Sep 17 00:00:00 2001 From: Ben <9841563+bfreiberg@users.noreply.github.com> Date: Wed, 20 Nov 2024 10:37:30 +0100 Subject: [PATCH 10/11] Add final pattern file --- .../s3-sqs-lambda-terraform.json | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 s3-sqs-lambda-terraform/s3-sqs-lambda-terraform.json diff --git a/s3-sqs-lambda-terraform/s3-sqs-lambda-terraform.json b/s3-sqs-lambda-terraform/s3-sqs-lambda-terraform.json new file mode 100644 index 000000000..ccdffd2ac --- /dev/null +++ b/s3-sqs-lambda-terraform/s3-sqs-lambda-terraform.json @@ -0,0 +1,86 @@ +{ + "title": "Amazon S3 to AWS Lambda with Amazon SQS queue", + "description": "Create a Lambda function triggered for every image file stored to S3 via SQS.", + "language": "Node.js", + "level": "200", + "framework": "Terraform", + "introBox": { + "headline": "Lambda function triggered for every image file stored to S3 via SQS", + "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 function serve as a pre-configured template, providing a starting point for developing your application." + ] + }, + "gitHub": { + "template": { + "repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/s3-sqs-lambda-terraform", + "templateURL": "serverless-patterns/s3-sqs-lambda-terraform", + "projectFolder": "s3-sqs-lambda-terraform", + "templateFile": "main.tf" + } + }, + "resources": { + "bullets": [ + { + "text": "Configuring an Amazon SQS queue to trigger an AWS Lambda function", + "link": "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-configure-lambda-function-trigger.html" + } + ] + }, + "deploy": { + "text": [ + "terraform init", + "terraform apply" + ] + }, + "testing": { + "text": [ + "See the GitHub repo for detailed testing instructions." + ] + }, + "cleanup": { + "text": [ + "terraform destroy" + ] + }, + "authors": [ + { + "name": "Oriol Matavacas", + "image": "", + "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": "oriol-matavacas-rodriguez-b165868a", + "twitter": "" + } + ], + "patternArch": { + "icon1": { + "x": 20, + "y": 50, + "service": "s3", + "label": "Amazon S3 bucket" + }, + "icon2": { + "x": 50, + "y": 50, + "service": "sqs", + "label": "Amazon SQS queue" + }, + "icon3": { + "x": 80, + "y": 50, + "service": "lambda", + "label": "AWS Lambda" + }, + "line1": { + "from": "icon1", + "to": "icon2", + "label": "Image uploaded" + }, + "line2": { + "from": "icon2", + "to": "icon3", + "label": "" + } + } +} From 8a32f8a7b558799bd8376f9df92d4092d29599ec Mon Sep 17 00:00:00 2001 From: Ben <9841563+bfreiberg@users.noreply.github.com> Date: Wed, 20 Nov 2024 10:40:48 +0100 Subject: [PATCH 11/11] Update example-pattern.json --- s3-sqs-lambda-terraform/example-pattern.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/s3-sqs-lambda-terraform/example-pattern.json b/s3-sqs-lambda-terraform/example-pattern.json index 1a3a16428..d6d1edb5c 100644 --- a/s3-sqs-lambda-terraform/example-pattern.json +++ b/s3-sqs-lambda-terraform/example-pattern.json @@ -5,11 +5,11 @@ "level": "200", "framework": "Terraform", "introBox": { - "headline": "Create a Lambda function triggered for every jpg image file stored to S3 via SQS", + "headline": "Lambda function triggered for every image file stored to S3 via SQS", "text": [ - "Terraform deploys Lambda, SQS, S3, and IAM resources.", - "SQS consumes S3 .jpg events, triggering Lambda.", - "Lambda serves as a template for app development." + "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 function serve as a pre-configured template, providing a starting point for developing your application." ] }, "gitHub": { @@ -47,7 +47,7 @@ "authors": [ { "name": "Oriol Matavacas", - "image": "link-to-your-photo.jpg", + "image": "", "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": "oriol-matavacas-rodriguez-b165868a", "twitter": ""