From 0c024284d186098c21cdd087739557f8aea1d0c0 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Sat, 15 Feb 2025 18:43:18 +0000 Subject: [PATCH 01/17] New pattern added --- lambda-translate-tf/README.md | 68 ++++++++++++++++++++++++ lambda-translate-tf/example-pattern.json | 59 ++++++++++++++++++++ lambda-translate-tf/iam.tf | 41 ++++++++++++++ lambda-translate-tf/main.tf | 23 ++++++++ lambda-translate-tf/outputs.tf | 9 ++++ lambda-translate-tf/src/index.py | 18 +++++++ lambda-translate-tf/variables.tf | 11 ++++ 7 files changed, 229 insertions(+) create mode 100644 lambda-translate-tf/README.md create mode 100644 lambda-translate-tf/example-pattern.json create mode 100644 lambda-translate-tf/iam.tf create mode 100644 lambda-translate-tf/main.tf create mode 100644 lambda-translate-tf/outputs.tf create mode 100644 lambda-translate-tf/src/index.py create mode 100644 lambda-translate-tf/variables.tf diff --git a/lambda-translate-tf/README.md b/lambda-translate-tf/README.md new file mode 100644 index 000000000..545129aee --- /dev/null +++ b/lambda-translate-tf/README.md @@ -0,0 +1,68 @@ +# Translate Text in real-time using Lambda function and Amazon Translate + +This pattern contains source code and supporting files for a serverless application deployable with Terraform. The pattern demonstrates how to create a Lambda function that integrates with Amazon Translate service to perform real-time text translation between languages. + +Learn more about this pattern at Serverless Land Patterns: https://serverlessland.com/patterns/lambda-translate-tf + +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 repository: + ``` + git clone https://github.com/aws-samples/serverless-patterns + ``` +2. Change directory to the pattern directory: + ``` + cd serverless-patterns/lambda-translate-tf + ``` +3. From the command line, initialize Terraform to downloads and install the providers defined in the configuration: + ``` + terraform init + ``` +4. From the command line, apply the configuration in the main.tf file: + ``` + terraform apply + ``` +5. 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 to invoke the Lambda function. + +The example provided performs Translation from English to German language. The following languages are [supported](https://docs.aws.amazon.com/translate/latest/dg/what-is-languages.html). + +## Testing + +Replace "{LambdaFunctionName}" with the function name as seen in the output of terraform template + +``` +aws lambda invoke --function-name {LambdaFunctionName} --invocation-type RequestResponse --cli-binary-format raw-in-base64-out --payload "{\"text\":\"I am very happy\", \"sl\":\"en\",\"tl\":\"de\"}" response.json +``` + +The command above returns the following output: +``` +das ist schlecht +``` + +## Cleanup + +1. Delete all created resources by Terraform + ```bash + terraform destroy + ``` +2. Confirm all created resources has been deleted + ```bash + terraform show + ``` +---- +Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. + +SPDX-License-Identifier: MIT-0 \ No newline at end of file diff --git a/lambda-translate-tf/example-pattern.json b/lambda-translate-tf/example-pattern.json new file mode 100644 index 000000000..cd95c919d --- /dev/null +++ b/lambda-translate-tf/example-pattern.json @@ -0,0 +1,59 @@ +{ + "title": "Text translation with Lambda and Translate", + "description": "Create a Lambda function that calls Translate service for text translation via the Boto3 SDK.", + "language": "python", + "level": "200", + "framework": "Terraform", + "introBox": { + "headline": "How it works", + "text": [ + "This pattern shows how to deploy a terraform template that builds a Lambda function which calls translate for text translation." + ] + }, + "gitHub": { + "template": { + "repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/lambda-translate-tf", + "templateURL": "serverless-patterns/lambda-translate-tf", + "projectFolder": "lambda-translate-tf", + "templateFile": "main.tf" + } + }, + "resources": { + "bullets": [ + { + "text": "Using AWS Lambda and Amazon Translate for text translation", + "link": "https://aws.amazon.com/blogs/machine-learning/translating-documents-with-amazon-translate-aws-lambda-and-the-new-batch-translate-api/" + }, + { + "text": "Lambda", + "link": "https://docs.aws.amazon.com/lambda/latest/dg/welcome.html" + } + ] + }, + "deploy": { + "text": [ + "terraform init", + "terraform apply" + ] + }, + "testing": { + "text": [ + "See the Github repo for detailed testing instructions." + ] + }, + "cleanup": { + "text": [ + "terraform destroy", + "terraform show" + ] + }, + "authors": [ + { + "name": "Makendran G", + "image": "https://drive.google.com/file/d/1mUObnbmn52UWL-Zn39EpgpneiBNv3LCN/view?usp=sharing", + "bio": "Cloud Support Engineer @ AWS", + "linkedin": "makendran", + "twitter": "@MakendranG" + } + ] +} \ No newline at end of file diff --git a/lambda-translate-tf/iam.tf b/lambda-translate-tf/iam.tf new file mode 100644 index 000000000..8bcca8cc3 --- /dev/null +++ b/lambda-translate-tf/iam.tf @@ -0,0 +1,41 @@ +# IAM role for Lambda +resource "aws_iam_role" "lambda_role" { + name = "translate_text_lambda_role" + + assume_role_policy = jsonencode({ + Version = "2012-10-17" + Statement = [ + { + Action = "sts:AssumeRole" + Effect = "Allow" + Principal = { + Service = "lambda.amazonaws.com" + } + } + ] + }) +} + +# IAM policy for the Lambda role +resource "aws_iam_role_policy" "lambda_policy" { + name = "translate_text_lambda_policy" + role = aws_iam_role.lambda_role.id + + policy = jsonencode({ + Version = "2012-10-17" + Statement = [ + { + Sid = "LambdatranslateText" + Effect = "Allow" + Action = ["translate:TranslateText"] + Resource = "*" + } + ] + }) +} + +# Attach basic Lambda execution role +resource "aws_iam_role_policy_attachment" "lambda_basic_execution" { + policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + role = aws_iam_role.lambda_role.name +} \ No newline at end of file diff --git a/lambda-translate-tf/main.tf b/lambda-translate-tf/main.tf new file mode 100644 index 000000000..746f24534 --- /dev/null +++ b/lambda-translate-tf/main.tf @@ -0,0 +1,23 @@ +provider "aws" { + region = var.aws_region +} + +# Archive the Python source code +data "archive_file" "lambda_zip" { + type = "zip" + source_dir = "${path.module}/src" + output_path = "${path.module}/lambda_function.zip" +} + +# Create Lambda function +resource "aws_lambda_function" "translate_text" { + filename = data.archive_file.lambda_zip.output_path + function_name = var.function_name + role = aws_iam_role.lambda_role.arn + handler = "index.lambda_handler" + runtime = "python3.13" + memory_size = 128 + timeout = 60 + + source_code_hash = data.archive_file.lambda_zip.output_base64sha256 +} \ No newline at end of file diff --git a/lambda-translate-tf/outputs.tf b/lambda-translate-tf/outputs.tf new file mode 100644 index 000000000..9d687d76c --- /dev/null +++ b/lambda-translate-tf/outputs.tf @@ -0,0 +1,9 @@ +output "lambda_function_name" { + description = "Lambda Function Name" + value = aws_lambda_function.translate_text.function_name +} + +output "lambda_function_arn" { + description = "Lambda Function ARN" + value = aws_lambda_function.translate_text.arn +} \ No newline at end of file diff --git a/lambda-translate-tf/src/index.py b/lambda-translate-tf/src/index.py new file mode 100644 index 000000000..11577aa27 --- /dev/null +++ b/lambda-translate-tf/src/index.py @@ -0,0 +1,18 @@ +import boto3 +import json + +client = boto3.client('translate') + +def lambda_handler(event, context): + text = event['text'] + source_language = event['sl'] + target_language = event['tl'] + + response = client.translate_text( + Text=text, + SourceLanguageCode=source_language, + TargetLanguageCode=target_language + ) + + # Return only the translated text + return response['TranslatedText'] \ No newline at end of file diff --git a/lambda-translate-tf/variables.tf b/lambda-translate-tf/variables.tf new file mode 100644 index 000000000..abb395ae8 --- /dev/null +++ b/lambda-translate-tf/variables.tf @@ -0,0 +1,11 @@ +variable "aws_region" { + description = "AWS region" + type = string + default = "us-east-1" +} + +variable "function_name" { + description = "Name of the Lambda function" + type = string + default = "TranslateTextFunction" +} \ No newline at end of file From f67de6019527f1e3885c1a3614f4289affdc7076 Mon Sep 17 00:00:00 2001 From: Makendran Date: Thu, 27 Feb 2025 20:56:56 +0530 Subject: [PATCH 02/17] Update lambda-translate-tf/README.md Co-authored-by: Ben <9841563+bfreiberg@users.noreply.github.com> --- lambda-translate-tf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda-translate-tf/README.md b/lambda-translate-tf/README.md index 545129aee..49aa36c07 100644 --- a/lambda-translate-tf/README.md +++ b/lambda-translate-tf/README.md @@ -1,4 +1,4 @@ -# Translate Text in real-time using Lambda function and Amazon Translate +# Translate Text in real-time using AWS Lambda function and Amazon Translate This pattern contains source code and supporting files for a serverless application deployable with Terraform. The pattern demonstrates how to create a Lambda function that integrates with Amazon Translate service to perform real-time text translation between languages. From 9263661c4c6208d6dc857cbe40a72d43bf844dac Mon Sep 17 00:00:00 2001 From: Makendran Date: Thu, 27 Feb 2025 20:57:23 +0530 Subject: [PATCH 03/17] Update lambda-translate-tf/README.md Co-authored-by: Ben <9841563+bfreiberg@users.noreply.github.com> --- lambda-translate-tf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda-translate-tf/README.md b/lambda-translate-tf/README.md index 49aa36c07..3616ee7a3 100644 --- a/lambda-translate-tf/README.md +++ b/lambda-translate-tf/README.md @@ -1,6 +1,6 @@ # Translate Text in real-time using AWS Lambda function and Amazon Translate -This pattern contains source code and supporting files for a serverless application deployable with Terraform. The pattern demonstrates how to create a Lambda function that integrates with Amazon Translate service to perform real-time text translation between languages. +This pattern contains source code and supporting files for a serverless application deployable with Terraform. The pattern demonstrates how to create an AWS Lambda function that integrates with Amazon Translate to perform real-time text translation between languages. Learn more about this pattern at Serverless Land Patterns: https://serverlessland.com/patterns/lambda-translate-tf From 0f5f1f7756fa4aadb60488f77a287fe9fd36da07 Mon Sep 17 00:00:00 2001 From: Makendran Date: Thu, 27 Feb 2025 20:58:34 +0530 Subject: [PATCH 04/17] Update lambda-translate-tf/example-pattern.json Co-authored-by: Ben <9841563+bfreiberg@users.noreply.github.com> --- lambda-translate-tf/example-pattern.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda-translate-tf/example-pattern.json b/lambda-translate-tf/example-pattern.json index cd95c919d..e850af964 100644 --- a/lambda-translate-tf/example-pattern.json +++ b/lambda-translate-tf/example-pattern.json @@ -1,5 +1,5 @@ { - "title": "Text translation with Lambda and Translate", + "title": "Text translation with AWS Lambda and Amazon Translate", "description": "Create a Lambda function that calls Translate service for text translation via the Boto3 SDK.", "language": "python", "level": "200", From 5e13d4300786d48c91a28b64cbb0829d9687a2ad Mon Sep 17 00:00:00 2001 From: Makendran Date: Thu, 27 Feb 2025 20:59:16 +0530 Subject: [PATCH 05/17] Update lambda-translate-tf/example-pattern.json Co-authored-by: Ben <9841563+bfreiberg@users.noreply.github.com> --- lambda-translate-tf/example-pattern.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda-translate-tf/example-pattern.json b/lambda-translate-tf/example-pattern.json index e850af964..f622a3fdf 100644 --- a/lambda-translate-tf/example-pattern.json +++ b/lambda-translate-tf/example-pattern.json @@ -7,7 +7,7 @@ "introBox": { "headline": "How it works", "text": [ - "This pattern shows how to deploy a terraform template that builds a Lambda function which calls translate for text translation." + "This pattern shows how to deploy a Terraform template that create a Lambda function which calls Translate for text translation." ] }, "gitHub": { From fcaaf2759917a6f77f8def021210efcf9134f704 Mon Sep 17 00:00:00 2001 From: Makendran Date: Thu, 27 Feb 2025 21:12:15 +0530 Subject: [PATCH 06/17] Update lambda-translate-tf/example-pattern.json Co-authored-by: Ben <9841563+bfreiberg@users.noreply.github.com> --- lambda-translate-tf/example-pattern.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda-translate-tf/example-pattern.json b/lambda-translate-tf/example-pattern.json index f622a3fdf..23c4e4c8c 100644 --- a/lambda-translate-tf/example-pattern.json +++ b/lambda-translate-tf/example-pattern.json @@ -1,6 +1,6 @@ { "title": "Text translation with AWS Lambda and Amazon Translate", - "description": "Create a Lambda function that calls Translate service for text translation via the Boto3 SDK.", + "description": "Create an AWS Lambda function that calls Amazon Translate for text translation via the Boto3 SDK.", "language": "python", "level": "200", "framework": "Terraform", From 1c4906379e1f4a9dc8ed3e7157159ca9e3872729 Mon Sep 17 00:00:00 2001 From: Makendran Date: Thu, 27 Feb 2025 21:29:57 +0530 Subject: [PATCH 07/17] Update README.md --- lambda-translate-tf/README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lambda-translate-tf/README.md b/lambda-translate-tf/README.md index 3616ee7a3..a40ab4c8d 100644 --- a/lambda-translate-tf/README.md +++ b/lambda-translate-tf/README.md @@ -35,9 +35,12 @@ Important: this application uses various AWS services and there are costs associ ## How it works -Use the AWS CLI to invoke the Lambda function. +The pattern uses an AWS Lambda function that integrates with Amazon Translate service to perform real-time text translation. When invoked via AWS CLI, the Lambda function takes three parameters (source text, source language, and target language) and uses Amazon Translate to convert the text from one language to another (e.g., English to German in the example provided). + +This is a simple yet powerful serverless solution for real-time text translation without having to manage any servers or infrastructure. + +"The example demonstrates translation from English to German language. For a complete list of supported languages, please refer to the [Amazon Translate documentation](https://docs.aws.amazon.com/translate/latest/dg/what-is-languages.html)." -The example provided performs Translation from English to German language. The following languages are [supported](https://docs.aws.amazon.com/translate/latest/dg/what-is-languages.html). ## Testing @@ -47,7 +50,7 @@ Replace "{LambdaFunctionName}" with the function name as seen in the output of t aws lambda invoke --function-name {LambdaFunctionName} --invocation-type RequestResponse --cli-binary-format raw-in-base64-out --payload "{\"text\":\"I am very happy\", \"sl\":\"en\",\"tl\":\"de\"}" response.json ``` -The command above returns the following output: +After running the command, open the generated response.json file to see the translated output: ``` das ist schlecht ``` @@ -65,4 +68,4 @@ das ist schlecht ---- Copyright 2025 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 3da517c17448cb3a6b355fd557d213f788c4551d Mon Sep 17 00:00:00 2001 From: Makendran Date: Thu, 27 Feb 2025 21:30:30 +0530 Subject: [PATCH 08/17] Update example-pattern.json --- lambda-translate-tf/example-pattern.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lambda-translate-tf/example-pattern.json b/lambda-translate-tf/example-pattern.json index 23c4e4c8c..daf7ff7b1 100644 --- a/lambda-translate-tf/example-pattern.json +++ b/lambda-translate-tf/example-pattern.json @@ -1,6 +1,6 @@ { "title": "Text translation with AWS Lambda and Amazon Translate", - "description": "Create an AWS Lambda function that calls Amazon Translate for text translation via the Boto3 SDK.", + "description": "Create a Lambda function that calls Translate service for text translation via the Boto3 SDK.", "language": "python", "level": "200", "framework": "Terraform", @@ -21,8 +21,8 @@ "resources": { "bullets": [ { - "text": "Using AWS Lambda and Amazon Translate for text translation", - "link": "https://aws.amazon.com/blogs/machine-learning/translating-documents-with-amazon-translate-aws-lambda-and-the-new-batch-translate-api/" + "text": "Translation processing modes", + "link": "https://docs.aws.amazon.com/translate/latest/dg/processing.html" }, { "text": "Lambda", @@ -44,7 +44,7 @@ "cleanup": { "text": [ "terraform destroy", - "terraform show" + "terraform show" ] }, "authors": [ @@ -56,4 +56,4 @@ "twitter": "@MakendranG" } ] -} \ No newline at end of file +} From 4d59a63226ffb7f4b8259d1200088cc87b3697ab Mon Sep 17 00:00:00 2001 From: Makendran Date: Thu, 27 Feb 2025 21:31:03 +0530 Subject: [PATCH 09/17] Update iam.tf --- lambda-translate-tf/iam.tf | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lambda-translate-tf/iam.tf b/lambda-translate-tf/iam.tf index 8bcca8cc3..fb5b2fd58 100644 --- a/lambda-translate-tf/iam.tf +++ b/lambda-translate-tf/iam.tf @@ -1,3 +1,6 @@ +# Get current AWS account ID +data "aws_caller_identity" "current" {} + # IAM role for Lambda resource "aws_iam_role" "lambda_role" { name = "translate_text_lambda_role" @@ -28,7 +31,7 @@ resource "aws_iam_role_policy" "lambda_policy" { Sid = "LambdatranslateText" Effect = "Allow" Action = ["translate:TranslateText"] - Resource = "*" + Resource = "arn:aws:translate:${var.aws_region}:${data.aws_caller_identity.current.account_id}:*" } ] }) @@ -38,4 +41,4 @@ resource "aws_iam_role_policy" "lambda_policy" { resource "aws_iam_role_policy_attachment" "lambda_basic_execution" { policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" role = aws_iam_role.lambda_role.name -} \ No newline at end of file +} From f5f4514d63985faad9a63757b9ccd96b4b6f42d0 Mon Sep 17 00:00:00 2001 From: Makendran Date: Thu, 27 Feb 2025 21:32:05 +0530 Subject: [PATCH 10/17] Update main.tf --- lambda-translate-tf/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lambda-translate-tf/main.tf b/lambda-translate-tf/main.tf index 746f24534..3c6cf00de 100644 --- a/lambda-translate-tf/main.tf +++ b/lambda-translate-tf/main.tf @@ -17,7 +17,7 @@ resource "aws_lambda_function" "translate_text" { handler = "index.lambda_handler" runtime = "python3.13" memory_size = 128 - timeout = 60 + timeout = 10 source_code_hash = data.archive_file.lambda_zip.output_base64sha256 -} \ No newline at end of file +} From a9a9f3022310aa7d5fb91e90728dd5c3a36a1d6f Mon Sep 17 00:00:00 2001 From: Makendran Date: Sat, 1 Mar 2025 11:50:12 +0530 Subject: [PATCH 11/17] Update lambda-translate-tf/README.md Co-authored-by: Ben <9841563+bfreiberg@users.noreply.github.com> --- lambda-translate-tf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda-translate-tf/README.md b/lambda-translate-tf/README.md index a40ab4c8d..ca4ee11f1 100644 --- a/lambda-translate-tf/README.md +++ b/lambda-translate-tf/README.md @@ -1,4 +1,4 @@ -# Translate Text in real-time using AWS Lambda function and Amazon Translate +# Translate Text in real-time using AWS Lambda and Amazon Translate This pattern contains source code and supporting files for a serverless application deployable with Terraform. The pattern demonstrates how to create an AWS Lambda function that integrates with Amazon Translate to perform real-time text translation between languages. From c7aa2cce5ea435c46b971b374b515c1d5c9eaed3 Mon Sep 17 00:00:00 2001 From: Makendran Date: Sat, 1 Mar 2025 11:51:32 +0530 Subject: [PATCH 12/17] Update lambda-translate-tf/README.md Co-authored-by: Ben <9841563+bfreiberg@users.noreply.github.com> --- lambda-translate-tf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda-translate-tf/README.md b/lambda-translate-tf/README.md index ca4ee11f1..17b875946 100644 --- a/lambda-translate-tf/README.md +++ b/lambda-translate-tf/README.md @@ -35,7 +35,7 @@ Important: this application uses various AWS services and there are costs associ ## How it works -The pattern uses an AWS Lambda function that integrates with Amazon Translate service to perform real-time text translation. When invoked via AWS CLI, the Lambda function takes three parameters (source text, source language, and target language) and uses Amazon Translate to convert the text from one language to another (e.g., English to German in the example provided). +The pattern uses an AWS Lambda function that integrates with Amazon Translate to perform real-time text translation. When invoked via the AWS CLI, the Lambda function takes three parameters (source text, source language, and target language) and uses Amazon Translate to convert the text from one language to another (for example English to German). This is a simple yet powerful serverless solution for real-time text translation without having to manage any servers or infrastructure. From f6c58684b5f4b8d8a7546cf16f279e94e7d9f790 Mon Sep 17 00:00:00 2001 From: Makendran Date: Sat, 1 Mar 2025 11:52:28 +0530 Subject: [PATCH 13/17] Update lambda-translate-tf/example-pattern.json Co-authored-by: Ben <9841563+bfreiberg@users.noreply.github.com> --- lambda-translate-tf/example-pattern.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda-translate-tf/example-pattern.json b/lambda-translate-tf/example-pattern.json index daf7ff7b1..53c299f12 100644 --- a/lambda-translate-tf/example-pattern.json +++ b/lambda-translate-tf/example-pattern.json @@ -7,7 +7,7 @@ "introBox": { "headline": "How it works", "text": [ - "This pattern shows how to deploy a Terraform template that create a Lambda function which calls Translate for text translation." + "This pattern shows how to deploy a Terraform template that creates a Lambda function which calls Amazon Translate for text translation." ] }, "gitHub": { From ebdc5478ae5876f86a4236810b03522b8ee19917 Mon Sep 17 00:00:00 2001 From: Makendran Date: Sat, 1 Mar 2025 11:53:53 +0530 Subject: [PATCH 14/17] Update README.md --- lambda-translate-tf/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/lambda-translate-tf/README.md b/lambda-translate-tf/README.md index 17b875946..7ede87cd2 100644 --- a/lambda-translate-tf/README.md +++ b/lambda-translate-tf/README.md @@ -37,8 +37,6 @@ Important: this application uses various AWS services and there are costs associ The pattern uses an AWS Lambda function that integrates with Amazon Translate to perform real-time text translation. When invoked via the AWS CLI, the Lambda function takes three parameters (source text, source language, and target language) and uses Amazon Translate to convert the text from one language to another (for example English to German). -This is a simple yet powerful serverless solution for real-time text translation without having to manage any servers or infrastructure. - "The example demonstrates translation from English to German language. For a complete list of supported languages, please refer to the [Amazon Translate documentation](https://docs.aws.amazon.com/translate/latest/dg/what-is-languages.html)." From f03ff6927018cef022e0f172adc7bb4f515e6acb Mon Sep 17 00:00:00 2001 From: Makendran Date: Sat, 1 Mar 2025 11:54:49 +0530 Subject: [PATCH 15/17] Update README.md --- lambda-translate-tf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda-translate-tf/README.md b/lambda-translate-tf/README.md index 7ede87cd2..d0f3d3b09 100644 --- a/lambda-translate-tf/README.md +++ b/lambda-translate-tf/README.md @@ -50,7 +50,7 @@ aws lambda invoke --function-name {LambdaFunctionName} --invocation-type Reques After running the command, open the generated response.json file to see the translated output: ``` -das ist schlecht +Ich freue mich sehr ``` ## Cleanup From 4c6556ef73a7da20a696a01fab3c4513a3acad75 Mon Sep 17 00:00:00 2001 From: Ben <9841563+bfreiberg@users.noreply.github.com> Date: Wed, 5 Mar 2025 08:51:33 +0100 Subject: [PATCH 16/17] Add final pattern file --- lambda-translate-tf/lambda-translate-tf.json | 78 ++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 lambda-translate-tf/lambda-translate-tf.json diff --git a/lambda-translate-tf/lambda-translate-tf.json b/lambda-translate-tf/lambda-translate-tf.json new file mode 100644 index 000000000..18c630ae4 --- /dev/null +++ b/lambda-translate-tf/lambda-translate-tf.json @@ -0,0 +1,78 @@ +{ + "title": "Text translation with AWS Lambda and Amazon Translate", + "description": "Create an AWS Lambda function that calls Amazon Translate for text translation via the Boto3 SDK.", + "language": "Python", + "level": "200", + "framework": "Terraform", + "introBox": { + "headline": "How it works", + "text": [ + "This pattern shows how to deploy a Terraform template that creates a Lambda function which calls Amazon Translate for text translation." + ] + }, + "gitHub": { + "template": { + "repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/lambda-translate-tf", + "templateURL": "serverless-patterns/lambda-translate-tf", + "projectFolder": "lambda-translate-tf", + "templateFile": "main.tf" + } + }, + "resources": { + "bullets": [ + { + "text": "Translation processing modes", + "link": "https://docs.aws.amazon.com/translate/latest/dg/processing.html" + }, + { + "text": "Lambda", + "link": "https://docs.aws.amazon.com/lambda/latest/dg/welcome.html" + } + ] + }, + "deploy": { + "text": [ + "terraform init", + "terraform apply" + ] + }, + "testing": { + "text": [ + "See the Github repo for detailed testing instructions." + ] + }, + "cleanup": { + "text": [ + "terraform destroy", + "terraform show" + ] + }, + "authors": [ + { + "name": "Makendran G", + "image": "https://drive.google.com/file/d/1mUObnbmn52UWL-Zn39EpgpneiBNv3LCN/view?usp=sharing", + "bio": "Cloud Support Engineer @ AWS", + "linkedin": "makendran", + "twitter": "@MakendranG" + } + ], + "patternArch": { + "icon1": { + "x": 20, + "y": 50, + "service": "lambda", + "label": "AWS Lambda" + }, + "icon2": { + "x": 80, + "y": 50, + "service": "translate", + "label": "Amazon Translate" + }, + "line1": { + "from": "icon1", + "to": "icon2", + "label": "" + } + } +} From 77451797758d2fea212d4493ac17beeac9987318 Mon Sep 17 00:00:00 2001 From: Makendran Date: Wed, 5 Mar 2025 23:12:00 +0530 Subject: [PATCH 17/17] Update lambda-translate-tf/example-pattern.json Co-authored-by: Ben <9841563+bfreiberg@users.noreply.github.com> --- lambda-translate-tf/example-pattern.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda-translate-tf/example-pattern.json b/lambda-translate-tf/example-pattern.json index 53c299f12..0e75cfeed 100644 --- a/lambda-translate-tf/example-pattern.json +++ b/lambda-translate-tf/example-pattern.json @@ -1,6 +1,6 @@ { "title": "Text translation with AWS Lambda and Amazon Translate", - "description": "Create a Lambda function that calls Translate service for text translation via the Boto3 SDK.", + "description": "Create an AWS Lambda function that calls Amazon Translate for text translation via the Boto3 SDK.", "language": "python", "level": "200", "framework": "Terraform",