From 462732e9d2ce74d02f3863f7d71485eb47505a66 Mon Sep 17 00:00:00 2001 From: Chodavarapu Naga Viswanadha Avinash Date: Tue, 22 Oct 2024 12:49:28 +0530 Subject: [PATCH 1/7] feat (NR-305269) : Added example for java language. --- .../HelloWorldFunction/Dockerfile | 22 +++ .../HelloWorldFunction/pom.xml | 52 +++++++ .../src/main/java/helloworld/App.java | 48 +++++++ .../src/test/java/helloworld/AppTest.java | 22 +++ .../java-17-maven-sam-example/README.md | 134 ++++++++++++++++++ .../events/event.json | 63 ++++++++ .../java-17-maven-sam-example/samconfig.toml | 30 ++++ .../java-17-maven-sam-example/template.yaml | 41 ++++++ 8 files changed, 412 insertions(+) create mode 100644 examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/Dockerfile create mode 100644 examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/pom.xml create mode 100644 examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/src/main/java/helloworld/App.java create mode 100644 examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/src/test/java/helloworld/AppTest.java create mode 100644 examples/sam/containerizedlambda/java-17-maven-sam-example/README.md create mode 100644 examples/sam/containerizedlambda/java-17-maven-sam-example/events/event.json create mode 100644 examples/sam/containerizedlambda/java-17-maven-sam-example/samconfig.toml create mode 100644 examples/sam/containerizedlambda/java-17-maven-sam-example/template.yaml diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/Dockerfile b/examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/Dockerfile new file mode 100644 index 0000000..5ca688c --- /dev/null +++ b/examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/Dockerfile @@ -0,0 +1,22 @@ +# Define the New Relic pre-built image +FROM public.ecr.aws/newrelic-lambda-layers-for-docker/newrelic-lambda-layers-java:17 AS layer + +FROM public.ecr.aws/sam/build-java17:latest as build-image + + +WORKDIR "/task" +COPY src/ src/ +COPY pom.xml ./ + +RUN mvn -q clean install +RUN mvn dependency:copy-dependencies -DincludeScope=compile + + +FROM public.ecr.aws/lambda/java:17 + +COPY --from=layer /opt/ /opt/ +COPY --from=build-image /task/target/classes /var/task/ +COPY --from=build-image /task/target/dependency /var/task/lib + +# Command can be overwritten by providing a different command in the template directly. +CMD [ "com.newrelic.java.HandlerWrapper::handleRequest" ] diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/pom.xml b/examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/pom.xml new file mode 100644 index 0000000..9ebabad --- /dev/null +++ b/examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/pom.xml @@ -0,0 +1,52 @@ + + 4.0.0 + helloworld + HelloWorld + 1.0 + jar + A sample Hello World created for SAM CLI. + + 17 + 17 + + + + + com.amazonaws + aws-lambda-java-core + 1.2.2 + + + com.amazonaws + aws-lambda-java-events + 3.11.0 + + + junit + junit + 4.13.2 + test + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + + + package + + shade + + + + + + + diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/src/main/java/helloworld/App.java b/examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/src/main/java/helloworld/App.java new file mode 100644 index 0000000..0cbd0f8 --- /dev/null +++ b/examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/src/main/java/helloworld/App.java @@ -0,0 +1,48 @@ +package helloworld; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Collectors; + +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; +import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; +import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent; + +/** + * Handler for requests to Lambda function. + */ +public class App implements RequestHandler { + + public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) { + Map headers = new HashMap<>(); + headers.put("Content-Type", "application/json"); + headers.put("X-Custom-Header", "application/json"); + + APIGatewayProxyResponseEvent response = new APIGatewayProxyResponseEvent() + .withHeaders(headers); + try { + final String pageContents = this.getPageContents("https://checkip.amazonaws.com"); + String output = String.format("{ \"message\": \"hello world\", \"location\": \"%s\" }", pageContents); + + return response + .withStatusCode(200) + .withBody(output); + } catch (IOException e) { + return response + .withBody("{}") + .withStatusCode(500); + } + } + + private String getPageContents(String address) throws IOException{ + URL url = new URL(address); + try(BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()))) { + return br.lines().collect(Collectors.joining(System.lineSeparator())); + } + } +} diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/src/test/java/helloworld/AppTest.java b/examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/src/test/java/helloworld/AppTest.java new file mode 100644 index 0000000..240323b --- /dev/null +++ b/examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/src/test/java/helloworld/AppTest.java @@ -0,0 +1,22 @@ +package helloworld; + +import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import org.junit.Test; + +public class AppTest { + @Test + public void successfulResponse() { + App app = new App(); + APIGatewayProxyResponseEvent result = app.handleRequest(null, null); + assertEquals(200, result.getStatusCode().intValue()); + assertEquals("application/json", result.getHeaders().get("Content-Type")); + String content = result.getBody(); + assertNotNull(content); + assertTrue(content.contains("\"message\"")); + assertTrue(content.contains("\"hello world\"")); + assertTrue(content.contains("\"location\"")); + } +} diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/README.md b/examples/sam/containerizedlambda/java-17-maven-sam-example/README.md new file mode 100644 index 0000000..4e21393 --- /dev/null +++ b/examples/sam/containerizedlambda/java-17-maven-sam-example/README.md @@ -0,0 +1,134 @@ +# java-17-maven-sam-example + +This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders. + +- HelloWorldFunction/src/main - Code for the application's Lambda function and Project Dockerfile. +- events - Invocation events that you can use to invoke the function. +- HelloWorldFunction/src/test - Unit tests for the application code. +- template.yaml - A template that defines the application's AWS resources. + +The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code. + +## Getting started + +There are two ways to start using this serverless application example: + +### Option 1: Create a new SAM project + +You can create your own SAM project using the `sam init` command: + +1. **Set up your environment**: Before you start, make sure that you have the SAM CLI and Docker installed on your machine. + - Install the SAM CLI following these [installation instructions](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html). + - Install Docker using the [Docker Community Edition installation guide](https://hub.docker.com/search/?type=edition&offering=community). + +2. **Initiate a new project**: + Run the following command to create a new serverless application with a Docker image package type: + + ```bash + sam init --package-type Image + ``` + +3. **Select the desired template**: Choose `AWS Quick Start Templates` and then select the `Hello World Example`. + +4. **Configure your project**: Follow the prompts to set up your project, adding any additional features if necessary. + +### Option 2: Clone an existing repository + +Alternatively, you can clone this existing repository and deploy the application directly. + +After cloning the repository or creating a new SAM project, you can then build and deploy your application as described in the following sections. + + +The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code. + +## Deploy the sample application + +The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API. + +To use the SAM CLI, you need the following tools. + +* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) +* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) + +You may need the following for local testing. +* java17 - [Install the Java 17](https://docs.aws.amazon.com/corretto/latest/corretto-17-ug/downloads-list.html) +* Maven - [Install Maven](https://maven.apache.org/install.html) + +To build and deploy your application for the first time, run the following in your shell: + +```bash +sam build +sam deploy --guided +``` + +The first command will build a docker image from a Dockerfile and then copy the source of your application inside the Docker image. The second command will package and deploy your application to AWS, with a series of prompts: + +* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name. +* **AWS Region**: The AWS region you want to deploy your app to. +* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes. +* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modifies IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command. +* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application. + +You can find your API Gateway Endpoint URL in the output values displayed after deployment. + +## Use the SAM CLI to build and test locally + +Build your application with the `sam build` command. + +```bash +java-17-maven-sam-example$ sam build +``` + +The SAM CLI builds a docker image from a Dockerfile and then installs dependencies defined in `HelloWorldFunction/pom.xml` inside the docker image. The processed template file is saved in the `.aws-sam/build` folder. + + + +Run functions locally and invoke them with the `sam local invoke` command. + +```bash +java-17-maven-sam-example$ sam local invoke HelloWorldFunction +``` + +The SAM CLI can also emulate your application's API. Use the `sam local start-api` to run the API locally on port 3000. + +```bash +java-17-maven-sam-example$ sam local start-api +java-17-maven-sam-example$ curl http://localhost:3000/ + +## Add a resource to your application +The application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in [the SAM specification](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md), you can use standard [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html) resource types. + +## Fetch, tail, and filter Lambda function logs + +To simplify troubleshooting, SAM CLI has a command called `sam logs`. `sam logs` lets you fetch logs generated by your deployed Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug. + +`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM. + +```bash +java-17-maven-sam-example$ sam logs -n HelloWorldFunction --stack-name java-17-maven-sam-example --tail +``` + +You can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html). + +## Unit tests + +Tests are defined in the `HelloWorldFunction/src/test` folder in this project. + +```bash +java-17-maven-sam-example$ cd HelloWorldFunction +HelloWorldFunction$ mvn test +``` + +## Cleanup + +To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following: + +```bash +sam delete --stack-name java-17-maven-sam-example +``` + +## Resources + +See the [AWS SAM developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) for an introduction to SAM specification, the SAM CLI, and serverless application concepts. + +Next, you can use AWS Serverless Application Repository to deploy ready to use Apps that go beyond hello world samples and learn how authors developed their applications: [AWS Serverless Application Repository main page](https://aws.amazon.com/serverless/serverlessrepo/) diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/events/event.json b/examples/sam/containerizedlambda/java-17-maven-sam-example/events/event.json new file mode 100644 index 0000000..3822fad --- /dev/null +++ b/examples/sam/containerizedlambda/java-17-maven-sam-example/events/event.json @@ -0,0 +1,63 @@ +{ + "body": "{\"message\": \"hello world\"}", + "resource": "/{proxy+}", + "path": "/path/to/resource", + "httpMethod": "POST", + "isBase64Encoded": false, + "queryStringParameters": { + "foo": "bar" + }, + "pathParameters": { + "proxy": "/path/to/resource" + }, + "stageVariables": { + "baz": "qux" + }, + "headers": { + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", + "Accept-Encoding": "gzip, deflate, sdch", + "Accept-Language": "en-US,en;q=0.8", + "Cache-Control": "max-age=0", + "CloudFront-Forwarded-Proto": "https", + "CloudFront-Is-Desktop-Viewer": "true", + "CloudFront-Is-Mobile-Viewer": "false", + "CloudFront-Is-SmartTV-Viewer": "false", + "CloudFront-Is-Tablet-Viewer": "false", + "CloudFront-Viewer-Country": "US", + "Host": "1234567890.execute-api.us-east-1.amazonaws.com", + "Upgrade-Insecure-Requests": "1", + "User-Agent": "Custom User Agent String", + "Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)", + "X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==", + "X-Forwarded-For": "127.0.0.1, 127.0.0.2", + "X-Forwarded-Port": "443", + "X-Forwarded-Proto": "https" + }, + "requestContext": { + "accountId": "123456789012", + "resourceId": "123456", + "stage": "prod", + "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", + "requestTime": "09/Apr/2015:12:34:56 +0000", + "requestTimeEpoch": 1428582896000, + "identity": { + "cognitoIdentityPoolId": null, + "accountId": null, + "cognitoIdentityId": null, + "caller": null, + "accessKey": null, + "sourceIp": "127.0.0.1", + "cognitoAuthenticationType": null, + "cognitoAuthenticationProvider": null, + "userArn": null, + "userAgent": "Custom User Agent String", + "user": null + }, + "path": "/prod/path/to/resource", + "resourcePath": "/{proxy+}", + "httpMethod": "POST", + "apiId": "1234567890", + "protocol": "HTTP/1.1" + } + } + \ No newline at end of file diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/samconfig.toml b/examples/sam/containerizedlambda/java-17-maven-sam-example/samconfig.toml new file mode 100644 index 0000000..f0bf234 --- /dev/null +++ b/examples/sam/containerizedlambda/java-17-maven-sam-example/samconfig.toml @@ -0,0 +1,30 @@ +# More information about the configuration file can be found here: +# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html +version = 0.1 + +[default.global.parameters] +stack_name = "java-17-maven-sam-example" + +[default.build.parameters] +parallel = true + +[default.validate.parameters] +lint = true + +[default.deploy.parameters] +capabilities = "CAPABILITY_IAM" +confirm_changeset = true +resolve_s3 = true +resolve_image_repos = true + +[default.package.parameters] +resolve_s3 = true + +[default.sync.parameters] +watch = true + +[default.local_start_api.parameters] +warm_containers = "EAGER" + +[default.local_start_lambda.parameters] +warm_containers = "EAGER" diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/template.yaml b/examples/sam/containerizedlambda/java-17-maven-sam-example/template.yaml new file mode 100644 index 0000000..337277f --- /dev/null +++ b/examples/sam/containerizedlambda/java-17-maven-sam-example/template.yaml @@ -0,0 +1,41 @@ +AWSTemplateFormatVersion: '2010-09-09' +Transform: AWS::Serverless-2016-10-31 +Description: > + java-17-maven-sam-example + + Sample SAM Template for java-17-maven-sam-example + +# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst +Globals: + Function: + Timeout: 20 + MemorySize: 512 + +Resources: + HelloWorldFunction: + Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction + Properties: + PackageType: Image + Architectures: + - x86_64 + Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object + Variables: + NEW_RELIC_LAMBDA_HANDLER: helloworld.App::handleRequest + NEW_RELIC_LICENSE_KEY: "YOUR_NEWRELIC_LICENSE_KEY" + NEW_RELIC_LOG_ENDPOINT: "YOUR_NEWRELIC_LOG_ENDPOINT" + NEW_RELIC_TELEMETRY_ENDPOINT: "YOUR_NEWRELIC_TELEMETRY_ENDPOINT" + Metadata: + DockerTag: java17-maven-v1 + DockerContext: ./HelloWorldFunction + Dockerfile: Dockerfile + +Outputs: + # ServerlessRestApi is an implicit API created out of Events key under Serverless::Function + # Find out more about other implicit resources you can reference within SAM + # https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api + HelloWorldFunction: + Description: "Hello World Lambda Function ARN" + Value: !GetAtt HelloWorldFunction.Arn + HelloWorldFunctionIamRole: + Description: "Implicit IAM Role created for Hello World function" + Value: !GetAtt HelloWorldFunctionRole.Arn From 6252cf55b73d631c83375f164a09a43fc04d5cec Mon Sep 17 00:00:00 2001 From: Chodavarapu Naga Viswanadha Avinash Date: Tue, 22 Oct 2024 12:51:54 +0530 Subject: [PATCH 2/7] feat (NR-305269) : Added example for nodejs. --- .../nodejs-sam-example/.gitignore | 207 ++++++++++++++++++ .../nodejs-sam-example/README.md | 137 ++++++++++++ .../nodejs-sam-example/events/event.json | 62 ++++++ .../nodejs-sam-example/hello-world/.npmignore | 1 + .../nodejs-sam-example/hello-world/Dockerfile | 14 ++ .../nodejs-sam-example/hello-world/app.mjs | 23 ++ .../hello-world/tests/unit/test-handler.mjs | 20 ++ .../nodejs-sam-example/samconfig.toml | 30 +++ .../nodejs-sam-example/template.yaml | 40 ++++ 9 files changed, 534 insertions(+) create mode 100644 examples/sam/containerizedlambda/nodejs-sam-example/.gitignore create mode 100644 examples/sam/containerizedlambda/nodejs-sam-example/README.md create mode 100644 examples/sam/containerizedlambda/nodejs-sam-example/events/event.json create mode 100644 examples/sam/containerizedlambda/nodejs-sam-example/hello-world/.npmignore create mode 100644 examples/sam/containerizedlambda/nodejs-sam-example/hello-world/Dockerfile create mode 100644 examples/sam/containerizedlambda/nodejs-sam-example/hello-world/app.mjs create mode 100644 examples/sam/containerizedlambda/nodejs-sam-example/hello-world/tests/unit/test-handler.mjs create mode 100644 examples/sam/containerizedlambda/nodejs-sam-example/samconfig.toml create mode 100644 examples/sam/containerizedlambda/nodejs-sam-example/template.yaml diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/.gitignore b/examples/sam/containerizedlambda/nodejs-sam-example/.gitignore new file mode 100644 index 0000000..5854f05 --- /dev/null +++ b/examples/sam/containerizedlambda/nodejs-sam-example/.gitignore @@ -0,0 +1,207 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/osx,node,linux,windows,sam +# Edit at https://www.toptal.com/developers/gitignore?templates=osx,node,linux,windows,sam + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test +.env*.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist + +# Storybook build outputs +.out +.storybook-out +storybook-static + +# rollup.js default build output +dist/ + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# Temporary folders +tmp/ +temp/ + +### OSX ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### SAM ### +# Ignore build directories for the AWS Serverless Application Model (SAM) +# Info: https://aws.amazon.com/serverless/sam/ +# Docs: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-reference.html + +**/.aws-sam + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/osx,node,linux,windows,sam diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/README.md b/examples/sam/containerizedlambda/nodejs-sam-example/README.md new file mode 100644 index 0000000..77e025a --- /dev/null +++ b/examples/sam/containerizedlambda/nodejs-sam-example/README.md @@ -0,0 +1,137 @@ +# nodejs-sam-example + +This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders. + +- hello-world - Code for the application's Lambda function and Project Dockerfile. +- events - Invocation events that you can use to invoke the function. +- hello-world/tests - Unit tests for the application code. +- template.yaml - A template that defines the application's AWS resources. + + +Certainly! You can instruct users to either set up a new project using AWS SAM or clone an existing repository to deploy the application. Here's how you can include both options in the README introduction: + +## Getting started + +There are two ways to start using this serverless application example: + +### Option 1: Create a new SAM project + +You can create your own SAM project using the `sam init` command: + +1. **Set up your environment**: Before you start, make sure that you have the SAM CLI and Docker installed on your machine. + - Install the SAM CLI following these [installation instructions](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html). + - Install Docker using the [Docker Community Edition installation guide](https://hub.docker.com/search/?type=edition&offering=community). + +2. **Initiate a new project**: + Run the following command to create a new serverless application with a Docker image package type: + + ```bash + sam init --package-type Image + ``` + +3. **Select the desired template**: Choose `AWS Quick Start Templates` and then select the `Hello World Example`. + +4. **Configure your project**: Follow the prompts to set up your project, adding any additional features if necessary. + +### Option 2: Clone an existing repository + +Alternatively, you can clone this existing repository and deploy the application directly. + +After cloning the repository or creating a new SAM project, you can then build and deploy your application as described in the following sections. + + +The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code. + +## Deploy the sample application + +The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API. + +To use the SAM CLI, you need the following tools. + +* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) +* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) + +You may need the following for local testing. + +* Node.js - [Install Node.js 20](https://nodejs.org/en/), including the NPM package management tool. + +To build and deploy your application for the first time, run the following in your shell: + +```bash +sam build +sam deploy --guided +``` + +The first command will build a docker image from a Dockerfile and then the source of your application inside the Docker image. The second command will package and deploy your application to AWS, with a series of prompts: + +* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name. +* **AWS Region**: The AWS region you want to deploy your app to. +* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes. +* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modifies IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command. +* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application. + +You can find your API Gateway Endpoint URL in the output values displayed after deployment. + +## Use the SAM CLI to build and test locally + +Build your application with the `sam build` command. + +```bash +nodejs-sam-example$ sam build +``` + +The SAM CLI builds a docker image from a Dockerfile and then installs dependencies defined in `hello-world/package.json` inside the docker image. The processed template file is saved in the `.aws-sam/build` folder. +* **Note**: The Dockerfile included in this sample application uses `npm install` by default. If you are building your code for production, you can modify it to use `npm ci` instead. + + +Run functions locally and invoke them with the `sam local invoke` command. + +```bash +nodejs-sam-example$ sam local invoke HelloWorldFunction +``` + +The SAM CLI can also emulate your application's API. Use the `sam local start-api` to run the API locally on port 3000. + +```bash +nodejs-sam-example$ sam local start-api +nodejs-sam-example$ curl http://localhost:3000/ +``` + +## Add a resource to your application +The application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in [the SAM specification](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md), you can use standard [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html) resource types. + +## Fetch, tail, and filter Lambda function logs + +To simplify troubleshooting, SAM CLI has a command called `sam logs`. `sam logs` lets you fetch logs generated by your deployed Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug. + +`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM. + +```bash +nodejs-sam-example$ sam logs -n HelloWorldFunction --stack-name nodejs-sam-example --tail +``` + +You can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html). + +## Unit tests + +Tests are defined in the `hello-world/tests` folder in this project. Use NPM to install the [Mocha test framework](https://mochajs.org/) and run unit tests from your local machine. + +```bash +nodejs-sam-example$ cd hello-world +hello-world$ npm install +hello-world$ npm run test +``` + +## Cleanup + +To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following: + +```bash +sam delete --stack-name nodejs-sam-example +``` + +## Resources + +See the [AWS SAM developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) for an introduction to SAM specification, the SAM CLI, and serverless application concepts. + +Next, you can use AWS Serverless Application Repository to deploy ready to use Apps that go beyond hello world samples and learn how authors developed their applications: [AWS Serverless Application Repository main page](https://aws.amazon.com/serverless/serverlessrepo/) diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/events/event.json b/examples/sam/containerizedlambda/nodejs-sam-example/events/event.json new file mode 100644 index 0000000..070ad8e --- /dev/null +++ b/examples/sam/containerizedlambda/nodejs-sam-example/events/event.json @@ -0,0 +1,62 @@ +{ + "body": "{\"message\": \"hello world\"}", + "resource": "/{proxy+}", + "path": "/path/to/resource", + "httpMethod": "POST", + "isBase64Encoded": false, + "queryStringParameters": { + "foo": "bar" + }, + "pathParameters": { + "proxy": "/path/to/resource" + }, + "stageVariables": { + "baz": "qux" + }, + "headers": { + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", + "Accept-Encoding": "gzip, deflate, sdch", + "Accept-Language": "en-US,en;q=0.8", + "Cache-Control": "max-age=0", + "CloudFront-Forwarded-Proto": "https", + "CloudFront-Is-Desktop-Viewer": "true", + "CloudFront-Is-Mobile-Viewer": "false", + "CloudFront-Is-SmartTV-Viewer": "false", + "CloudFront-Is-Tablet-Viewer": "false", + "CloudFront-Viewer-Country": "US", + "Host": "1234567890.execute-api.us-east-1.amazonaws.com", + "Upgrade-Insecure-Requests": "1", + "User-Agent": "Custom User Agent String", + "Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)", + "X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==", + "X-Forwarded-For": "127.0.0.1, 127.0.0.2", + "X-Forwarded-Port": "443", + "X-Forwarded-Proto": "https" + }, + "requestContext": { + "accountId": "123456789012", + "resourceId": "123456", + "stage": "prod", + "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", + "requestTime": "09/Apr/2015:12:34:56 +0000", + "requestTimeEpoch": 1428582896000, + "identity": { + "cognitoIdentityPoolId": null, + "accountId": null, + "cognitoIdentityId": null, + "caller": null, + "accessKey": null, + "sourceIp": "127.0.0.1", + "cognitoAuthenticationType": null, + "cognitoAuthenticationProvider": null, + "userArn": null, + "userAgent": "Custom User Agent String", + "user": null + }, + "path": "/prod/path/to/resource", + "resourcePath": "/{proxy+}", + "httpMethod": "POST", + "apiId": "1234567890", + "protocol": "HTTP/1.1" + } +} diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/.npmignore b/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/.npmignore new file mode 100644 index 0000000..e7e1fb0 --- /dev/null +++ b/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/.npmignore @@ -0,0 +1 @@ +tests/* diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/Dockerfile b/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/Dockerfile new file mode 100644 index 0000000..21cd9af --- /dev/null +++ b/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/Dockerfile @@ -0,0 +1,14 @@ +# Define the New Relic pre-built image +FROM public.ecr.aws/newrelic-lambda-layers-for-docker/newrelic-lambda-layers-nodejs:20 AS layer + +FROM public.ecr.aws/lambda/nodejs:20 + +# Copy New Relic Layer code +COPY --from=layer /opt/ /opt/ + +COPY app.mjs package*.json ./ + +RUN npm install + +# CMD override to New Relic's handler wrapper +CMD [ "newrelic-lambda-wrapper.handler" ] \ No newline at end of file diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/app.mjs b/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/app.mjs new file mode 100644 index 0000000..9cef2ac --- /dev/null +++ b/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/app.mjs @@ -0,0 +1,23 @@ +/** + * + * Event doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format + * @param {Object} event - API Gateway Lambda Proxy Input Format + * + * Context doc: https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html + * @param {Object} context + * + * Return doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html + * @returns {Object} object - API Gateway Lambda Proxy Output Format + * + */ + +export const lambdaHandler = async (event, context) => { + const response = { + statusCode: 200, + body: JSON.stringify({ + message: 'hello world', + }) + }; + + return response; + }; diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/tests/unit/test-handler.mjs b/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/tests/unit/test-handler.mjs new file mode 100644 index 0000000..02a66db --- /dev/null +++ b/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/tests/unit/test-handler.mjs @@ -0,0 +1,20 @@ +'use strict'; + +import { lambdaHandler } from '../../app.mjs'; +import { expect } from 'chai'; +var event, context; + +describe('Tests index', function () { + it('verifies successful response', async () => { + const result = await lambdaHandler(event, context) + + expect(result).to.be.an('object'); + expect(result.statusCode).to.equal(200); + expect(result.body).to.be.an('string'); + + let response = JSON.parse(result.body); + + expect(response).to.be.an('object'); + expect(response.message).to.be.equal("hello world"); + }); +}); diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/samconfig.toml b/examples/sam/containerizedlambda/nodejs-sam-example/samconfig.toml new file mode 100644 index 0000000..eaf48fd --- /dev/null +++ b/examples/sam/containerizedlambda/nodejs-sam-example/samconfig.toml @@ -0,0 +1,30 @@ +# More information about the configuration file can be found here: +# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html +version = 0.1 + +[default.global.parameters] +stack_name = "nodejs-sam-example" + +[default.build.parameters] +parallel = true + +[default.validate.parameters] +lint = true + +[default.deploy.parameters] +capabilities = "CAPABILITY_IAM" +confirm_changeset = true +resolve_s3 = true +resolve_image_repos = true + +[default.package.parameters] +resolve_s3 = true + +[default.sync.parameters] +watch = true + +[default.local_start_api.parameters] +warm_containers = "EAGER" + +[default.local_start_lambda.parameters] +warm_containers = "EAGER" diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/template.yaml b/examples/sam/containerizedlambda/nodejs-sam-example/template.yaml new file mode 100644 index 0000000..95da295 --- /dev/null +++ b/examples/sam/containerizedlambda/nodejs-sam-example/template.yaml @@ -0,0 +1,40 @@ +AWSTemplateFormatVersion: '2010-09-09' +Transform: AWS::Serverless-2016-10-31 +Description: > + nodejs-sam-example + + Sample SAM Template for nodejs-sam-example + +# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst +Globals: + Function: + Timeout: 3 + +Resources: + HelloWorldFunction: + Type: AWS::Serverless::Function + Properties: + PackageType: Image + Architectures: + - x86_64 + Environment: + Variables: + NEW_RELIC_LAMBDA_HANDLER: "app.lambdaHandler" + NEW_RELIC_LICENSE_KEY: "YOUR_NEWRELIC_LICENSE_KEY" + NEW_RELIC_LOG_ENDPOINT: "YOUR_NEWRELIC_LOG_ENDPOINT" + NEW_RELIC_TELEMETRY_ENDPOINT: "YOUR_NEWRELIC_TELEMETRY_ENDPOINT" + Metadata: + DockerTag: nodejs20.x-v1 + DockerContext: ./hello-world + Dockerfile: Dockerfile + +Outputs: + # ServerlessRestApi is an implicit API created out of Events key under Serverless::Function + # Find out more about other implicit resources you can reference within SAM + # https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api + HelloWorldFunction: + Description: "Hello World Lambda Function ARN" + Value: !GetAtt HelloWorldFunction.Arn + HelloWorldFunctionIamRole: + Description: "Implicit IAM Role created for Hello World function" + Value: !GetAtt HelloWorldFunctionRole.Arn From 7d9b852e7930a411e52f05b2b79d5912648d5273 Mon Sep 17 00:00:00 2001 From: Chodavarapu Naga Viswanadha Avinash Date: Tue, 22 Oct 2024 12:52:22 +0530 Subject: [PATCH 3/7] feat(NR-305269) : Added example for nodejs. --- .../hello-world/package-lock.json | 1038 +++++++++++++++++ .../hello-world/package.json | 19 + 2 files changed, 1057 insertions(+) create mode 100644 examples/sam/containerizedlambda/nodejs-sam-example/hello-world/package-lock.json create mode 100644 examples/sam/containerizedlambda/nodejs-sam-example/hello-world/package.json diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/package-lock.json b/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/package-lock.json new file mode 100644 index 0000000..b8e97d4 --- /dev/null +++ b/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/package-lock.json @@ -0,0 +1,1038 @@ +{ + "name": "hello_world", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "hello_world", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "axios": ">=1.6.0" + }, + "devDependencies": { + "chai": "^4.3.6", + "mocha": "^10.2.0" + } + }, + "node_modules/ansi-colors": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "node_modules/assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/axios": { + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", + "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/chai": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.5.0.tgz", + "integrity": "sha512-RITGBfijLkBddZvnn8jdqoTypxvqbOLYQkGGxXzeFjVHvudaPw0HNFD9x928/eUwYWd2dPCugVqspGALTZZQKw==", + "dev": true, + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.3", + "deep-eql": "^4.1.3", + "get-func-name": "^2.0.2", + "loupe": "^2.3.6", + "pathval": "^1.1.1", + "type-detect": "^4.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/check-error": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", + "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==", + "dev": true, + "dependencies": { + "get-func-name": "^2.0.2" + }, + "engines": { + "node": "*" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/debug": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/deep-eql": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.4.tgz", + "integrity": "sha512-SUwdGfqdKOwxCPeVYjwSyRpJ7Z+fhpwIAtmCUdZIWZ/YP5R9WAsyuSgpLVDi9bjWoN2LXHNss/dk3urXtdQxGg==", + "dev": true, + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/diff": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "dev": true, + "bin": { + "flat": "cli.js" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", + "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-func-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", + "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true, + "bin": { + "he": "bin/he" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/loupe": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz", + "integrity": "sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==", + "dev": true, + "dependencies": { + "get-func-name": "^2.0.1" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mocha": { + "version": "10.7.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.7.3.tgz", + "integrity": "sha512-uQWxAu44wwiACGqjbPYmjo7Lg8sFrS3dQe7PP2FQI+woptP4vZXSMcfMyFL/e1yFEeEpV4RtyTpZROOKmxis+A==", + "dev": true, + "dependencies": { + "ansi-colors": "^4.1.3", + "browser-stdout": "^1.3.1", + "chokidar": "^3.5.3", + "debug": "^4.3.5", + "diff": "^5.2.0", + "escape-string-regexp": "^4.0.0", + "find-up": "^5.0.0", + "glob": "^8.1.0", + "he": "^1.2.0", + "js-yaml": "^4.1.0", + "log-symbols": "^4.1.0", + "minimatch": "^5.1.6", + "ms": "^2.1.3", + "serialize-javascript": "^6.0.2", + "strip-json-comments": "^3.1.1", + "supports-color": "^8.1.1", + "workerpool": "^6.5.1", + "yargs": "^16.2.0", + "yargs-parser": "^20.2.9", + "yargs-unparser": "^2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": ">= 14.0.0" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/serialize-javascript": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/type-detect": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.1.0.tgz", + "integrity": "sha512-Acylog8/luQ8L7il+geoSxhEkazvkslg7PSNKOX59mbB9cOveP5aq9h74Y7YU8yDpJwetzQQrfIwtf4Wp4LKcw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/workerpool": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", + "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", + "dev": true + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dev": true, + "dependencies": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/package.json b/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/package.json new file mode 100644 index 0000000..0164adc --- /dev/null +++ b/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/package.json @@ -0,0 +1,19 @@ +{ + "name": "hello_world", + "version": "1.0.0", + "description": "hello world sample for NodeJS", + "main": "app.js", + "repository": "https://github.com/awslabs/aws-sam-cli/tree/develop/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs", + "author": "SAM CLI", + "license": "MIT", + "dependencies": { + "axios": ">=1.6.0" + }, + "scripts": { + "test": "mocha tests/unit/" + }, + "devDependencies": { + "chai": "^4.3.6", + "mocha": "^10.2.0" + } +} From dd8d5441ce60acd0f48f8ff10af5d3f6b4dcf5f0 Mon Sep 17 00:00:00 2001 From: Chodavarapu Naga Viswanadha Avinash Date: Tue, 22 Oct 2024 12:55:30 +0530 Subject: [PATCH 4/7] feat NR-305269: Added Python sam example. --- .../python-sam-example/.gitignore | 244 ++++++++++++++++++ .../python-sam-example/README.md | 137 ++++++++++ .../python-sam-example/__init__.py | 0 .../python-sam-example/events/event.json | 63 +++++ .../python-sam-example/hello_world/Dockerfile | 11 + .../hello_world/__init__.py | 0 .../python-sam-example/hello_world/app.py | 33 +++ .../hello_world/requirements.txt | 1 + .../python-sam-example/samconfig.toml | 30 +++ .../python-sam-example/template.yaml | 41 +++ .../python-sam-example/tests/__init__.py | 0 .../python-sam-example/tests/unit/__init__.py | 0 .../tests/unit/test_handler.py | 72 ++++++ 13 files changed, 632 insertions(+) create mode 100644 examples/sam/containerizedlambda/python-sam-example/.gitignore create mode 100644 examples/sam/containerizedlambda/python-sam-example/README.md create mode 100644 examples/sam/containerizedlambda/python-sam-example/__init__.py create mode 100644 examples/sam/containerizedlambda/python-sam-example/events/event.json create mode 100644 examples/sam/containerizedlambda/python-sam-example/hello_world/Dockerfile create mode 100644 examples/sam/containerizedlambda/python-sam-example/hello_world/__init__.py create mode 100644 examples/sam/containerizedlambda/python-sam-example/hello_world/app.py create mode 100644 examples/sam/containerizedlambda/python-sam-example/hello_world/requirements.txt create mode 100644 examples/sam/containerizedlambda/python-sam-example/samconfig.toml create mode 100644 examples/sam/containerizedlambda/python-sam-example/template.yaml create mode 100644 examples/sam/containerizedlambda/python-sam-example/tests/__init__.py create mode 100644 examples/sam/containerizedlambda/python-sam-example/tests/unit/__init__.py create mode 100644 examples/sam/containerizedlambda/python-sam-example/tests/unit/test_handler.py diff --git a/examples/sam/containerizedlambda/python-sam-example/.gitignore b/examples/sam/containerizedlambda/python-sam-example/.gitignore new file mode 100644 index 0000000..4808264 --- /dev/null +++ b/examples/sam/containerizedlambda/python-sam-example/.gitignore @@ -0,0 +1,244 @@ + +# Created by https://www.gitignore.io/api/osx,linux,python,windows,pycharm,visualstudiocode + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### OSX ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### PyCharm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# CMake +cmake-build-debug/ + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Ruby plugin and RubyMine +/.rakeTasks + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### PyCharm Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/sonarlint + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +.pytest_cache/ +nosetests.xml +coverage.xml +*.cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule.* + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +.history + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Build folder + +*/build/* + +# End of https://www.gitignore.io/api/osx,linux,python,windows,pycharm,visualstudiocode \ No newline at end of file diff --git a/examples/sam/containerizedlambda/python-sam-example/README.md b/examples/sam/containerizedlambda/python-sam-example/README.md new file mode 100644 index 0000000..0a97bf0 --- /dev/null +++ b/examples/sam/containerizedlambda/python-sam-example/README.md @@ -0,0 +1,137 @@ +# python-sam-example + +This project contains source code for a "Hello World" serverless application that you can deploy with the SAM CLI. It includes the following files and folders: + +- hello_world - Code for the application's Lambda function and Project Dockerfile. +- tests - Unit tests for the application code. +- template.yaml - A template that defines the application's AWS resources. + +The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. + + +## Getting started + +There are two ways to start using this serverless application example: + +### Option 1: Create a new SAM project + +You can create your own SAM project using the `sam init` command: + +1. **Set up your environment**: Before you start, make sure that you have the SAM CLI and Docker installed on your machine. + - Install the SAM CLI following these [installation instructions](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html). + - Install Docker using the [Docker Community Edition installation guide](https://hub.docker.com/search/?type=edition&offering=community). + +2. **Initiate a new project**: + Run the following command to create a new serverless application with a Docker image package type: + + ```bash + sam init --package-type Image + ``` + +3. **Select the desired template**: Choose `AWS Quick Start Templates` and then select the `Hello World Example`. + +4. **Configure your project**: Follow the prompts to set up your project, adding any additional features if necessary. + +### Option 2: Clone an existing repository + +Alternatively, you can clone this existing repository and deploy the application directly. + +After cloning the repository or creating a new SAM project, you can then build and deploy your application as described in the following sections. + + +The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code. + + +## Deploy the sample application + + +The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API. + +To use the SAM CLI, you need the following tools. + +* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) +* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) + +You may need the following for local testing. +* [Python 3 installed](https://www.python.org/downloads/) + +To build and deploy your application for the first time, run the following in your shell: + +```bash +sam build +sam deploy --guided +``` + +The `sam build` command builds the application, and the `sam deploy --guided` command prompts you to configure the deployment settings. The guided deployment will also save your settings to `samconfig.toml` for future deployments. + +The first command will build a docker image from a Dockerfile and then copy the source of your application inside the Docker image. The second command will package and deploy your application to AWS, with a series of prompts: + +* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name. +* **AWS Region**: The AWS region you want to deploy your app to. +* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes. +* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modifies IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command. +* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application. + +You can find your API Gateway Endpoint URL in the output values displayed after deployment. + +## Use the SAM CLI to build and test locally + +Build your application with the `sam build` command. + +```bash +python-sam-example$ sam build +``` + +The SAM CLI builds a docker image from a Dockerfile and then installs dependencies defined in `hello_world/requirements.txt` inside the docker image. The processed template file is saved in the `.aws-sam/build` folder. + +You can invoke the function locally with the `sam local invoke` command: + +```bash +python-sam-example$ sam local invoke HelloWorldFunction +``` + +The SAM CLI can also emulate your application's API. Run the API locally with the following command: + +```bash +python-sam-example$ sam local start-api +python-sam-example$ curl http://localhost:3000/hello +``` + +## Add a resource to your application +The application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in [the SAM specification](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md), you can use standard [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html) resource types. + +## Fetch, tail, and filter Lambda function logs + +To simplify troubleshooting, SAM CLI has a command called `sam logs`. `sam logs` lets you fetch logs generated by your deployed Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug. + +`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM. + +```bash +python-sam-example$ sam logs -n HelloWorldFunction --stack-name "python-sam-example" --tail +``` + +You can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html). + + +## Unit tests + +Run unit tests using pytest: + +```bash +python-sam-example$ pip install pytest pytest-mock --user +python-sam-example$ python -m pytest tests/ -v +``` + +## Cleanup + +To delete the deployed "Hello World" application, run: + +```bash +sam delete --stack-name "python-sam-example" +``` + +## Resources + +For more information about developing with SAM, visit the [AWS SAM developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html). + +Check out the [AWS Serverless Application Repository](https://aws.amazon.com/serverless/serverlessrepo/) to find ready-to-use serverless applications beyond simple samples. \ No newline at end of file diff --git a/examples/sam/containerizedlambda/python-sam-example/__init__.py b/examples/sam/containerizedlambda/python-sam-example/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/sam/containerizedlambda/python-sam-example/events/event.json b/examples/sam/containerizedlambda/python-sam-example/events/event.json new file mode 100644 index 0000000..a429ac5 --- /dev/null +++ b/examples/sam/containerizedlambda/python-sam-example/events/event.json @@ -0,0 +1,63 @@ +{ + "body": "{\"message\": \"hello world\"}", + "resource": "/hello", + "path": "/hello", + "httpMethod": "GET", + "isBase64Encoded": false, + "queryStringParameters": { + "foo": "bar" + }, + "pathParameters": { + "proxy": "/path/to/resource" + }, + "stageVariables": { + "baz": "qux" + }, + "headers": { + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", + "Accept-Encoding": "gzip, deflate, sdch", + "Accept-Language": "en-US,en;q=0.8", + "Cache-Control": "max-age=0", + "CloudFront-Forwarded-Proto": "https", + "CloudFront-Is-Desktop-Viewer": "true", + "CloudFront-Is-Mobile-Viewer": "false", + "CloudFront-Is-SmartTV-Viewer": "false", + "CloudFront-Is-Tablet-Viewer": "false", + "CloudFront-Viewer-Country": "US", + "Host": "1234567890.execute-api.us-east-1.amazonaws.com", + "Upgrade-Insecure-Requests": "1", + "User-Agent": "Custom User Agent String", + "Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)", + "X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==", + "X-Forwarded-For": "127.0.0.1, 127.0.0.2", + "X-Forwarded-Port": "443", + "X-Forwarded-Proto": "https" + }, + "requestContext": { + "accountId": "123456789012", + "resourceId": "123456", + "stage": "prod", + "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", + "requestTime": "09/Apr/2015:12:34:56 +0000", + "requestTimeEpoch": 1428582896000, + "identity": { + "cognitoIdentityPoolId": null, + "accountId": null, + "cognitoIdentityId": null, + "caller": null, + "accessKey": null, + "sourceIp": "127.0.0.1", + "cognitoAuthenticationType": null, + "cognitoAuthenticationProvider": null, + "userArn": null, + "userAgent": "Custom User Agent String", + "user": null + }, + "path": "/prod/hello", + "resourcePath": "/hello", + "httpMethod": "POST", + "apiId": "1234567890", + "protocol": "HTTP/1.1" + } + } + \ No newline at end of file diff --git a/examples/sam/containerizedlambda/python-sam-example/hello_world/Dockerfile b/examples/sam/containerizedlambda/python-sam-example/hello_world/Dockerfile new file mode 100644 index 0000000..34be6de --- /dev/null +++ b/examples/sam/containerizedlambda/python-sam-example/hello_world/Dockerfile @@ -0,0 +1,11 @@ +FROM public.ecr.aws/newrelic-lambda-layers-for-docker/newrelic-lambda-layers-python:312 AS layer + +FROM public.ecr.aws/lambda/python:3.12 + +COPY --from=layer /opt/ /opt/ + +COPY app.py requirements.txt ./ + +RUN python3.12 -m pip install -r requirements.txt -t . + +CMD [ "newrelic_lambda_wrapper.handler" ] diff --git a/examples/sam/containerizedlambda/python-sam-example/hello_world/__init__.py b/examples/sam/containerizedlambda/python-sam-example/hello_world/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/sam/containerizedlambda/python-sam-example/hello_world/app.py b/examples/sam/containerizedlambda/python-sam-example/hello_world/app.py new file mode 100644 index 0000000..a04e259 --- /dev/null +++ b/examples/sam/containerizedlambda/python-sam-example/hello_world/app.py @@ -0,0 +1,33 @@ +import json + + +def lambda_handler(event, context): + """Sample pure Lambda function + + Parameters + ---------- + event: dict, required + API Gateway Lambda Proxy Input Format + + Event doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format + + context: object, required + Lambda Context runtime methods and attributes + + Context doc: https://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html + + Returns + ------ + API Gateway Lambda Proxy Output Format: dict + + Return doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html + """ + + return { + "statusCode": 200, + "body": json.dumps( + { + "message": "hello world", + } + ), + } diff --git a/examples/sam/containerizedlambda/python-sam-example/hello_world/requirements.txt b/examples/sam/containerizedlambda/python-sam-example/hello_world/requirements.txt new file mode 100644 index 0000000..663bd1f --- /dev/null +++ b/examples/sam/containerizedlambda/python-sam-example/hello_world/requirements.txt @@ -0,0 +1 @@ +requests \ No newline at end of file diff --git a/examples/sam/containerizedlambda/python-sam-example/samconfig.toml b/examples/sam/containerizedlambda/python-sam-example/samconfig.toml new file mode 100644 index 0000000..ea5b01a --- /dev/null +++ b/examples/sam/containerizedlambda/python-sam-example/samconfig.toml @@ -0,0 +1,30 @@ +# More information about the configuration file can be found here: +# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html +version = 0.1 + +[default.global.parameters] +stack_name = "python-sam-example" + +[default.build.parameters] +parallel = true + +[default.validate.parameters] +lint = true + +[default.deploy.parameters] +capabilities = "CAPABILITY_IAM" +confirm_changeset = true +resolve_s3 = true +resolve_image_repos = true + +[default.package.parameters] +resolve_s3 = true + +[default.sync.parameters] +watch = true + +[default.local_start_api.parameters] +warm_containers = "EAGER" + +[default.local_start_lambda.parameters] +warm_containers = "EAGER" diff --git a/examples/sam/containerizedlambda/python-sam-example/template.yaml b/examples/sam/containerizedlambda/python-sam-example/template.yaml new file mode 100644 index 0000000..3f41bc9 --- /dev/null +++ b/examples/sam/containerizedlambda/python-sam-example/template.yaml @@ -0,0 +1,41 @@ +AWSTemplateFormatVersion: '2010-09-09' +Transform: AWS::Serverless-2016-10-31 +Description: > + python3.12 + + Sample SAM Template for python-sam-example + +# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst +Globals: + Function: + Timeout: 3 + +Resources: + HelloWorldFunction: + Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction + Properties: + PackageType: Image + Architectures: + - x86_64 + Environment: + Variables: + NEW_RELIC_LAMBDA_HANDLER: "app.lambda_handler" + NEW_RELIC_LICENSE_KEY: "YOUR_NEWRELIC_LICENSE_KEY" + NEW_RELIC_LOG_ENDPOINT: "YOUR_NEWRELIC_LOG_ENDPOINT" + NEW_RELIC_TELEMETRY_ENDPOINT: "YOUR_NEWRELIC_TELEMETRY_ENDPOINT" + + Metadata: + Dockerfile: Dockerfile + DockerContext: ./hello_world + DockerTag: python3.12-v1 + +Outputs: + # ServerlessRestApi is an implicit API created out of Events key under Serverless::Function + # Find out more about other implicit resources you can reference within SAM + # https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api + HelloWorldFunction: + Description: "Hello World Lambda Function ARN" + Value: !GetAtt HelloWorldFunction.Arn + HelloWorldFunctionIamRole: + Description: "Implicit IAM Role created for Hello World function" + Value: !GetAtt HelloWorldFunctionRole.Arn diff --git a/examples/sam/containerizedlambda/python-sam-example/tests/__init__.py b/examples/sam/containerizedlambda/python-sam-example/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/sam/containerizedlambda/python-sam-example/tests/unit/__init__.py b/examples/sam/containerizedlambda/python-sam-example/tests/unit/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/sam/containerizedlambda/python-sam-example/tests/unit/test_handler.py b/examples/sam/containerizedlambda/python-sam-example/tests/unit/test_handler.py new file mode 100644 index 0000000..ab6d6a0 --- /dev/null +++ b/examples/sam/containerizedlambda/python-sam-example/tests/unit/test_handler.py @@ -0,0 +1,72 @@ +import json + +import pytest + +from hello_world import app + + +@pytest.fixture() +def apigw_event(): + """ Generates API GW Event""" + + return { + "body": '{ "test": "body"}', + "resource": "/{proxy+}", + "requestContext": { + "resourceId": "123456", + "apiId": "1234567890", + "resourcePath": "/{proxy+}", + "httpMethod": "POST", + "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", + "accountId": "123456789012", + "identity": { + "apiKey": "", + "userArn": "", + "cognitoAuthenticationType": "", + "caller": "", + "userAgent": "Custom User Agent String", + "user": "", + "cognitoIdentityPoolId": "", + "cognitoIdentityId": "", + "cognitoAuthenticationProvider": "", + "sourceIp": "127.0.0.1", + "accountId": "", + }, + "stage": "prod", + }, + "queryStringParameters": {"foo": "bar"}, + "headers": { + "Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)", + "Accept-Language": "en-US,en;q=0.8", + "CloudFront-Is-Desktop-Viewer": "true", + "CloudFront-Is-SmartTV-Viewer": "false", + "CloudFront-Is-Mobile-Viewer": "false", + "X-Forwarded-For": "127.0.0.1, 127.0.0.2", + "CloudFront-Viewer-Country": "US", + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", + "Upgrade-Insecure-Requests": "1", + "X-Forwarded-Port": "443", + "Host": "1234567890.execute-api.us-east-1.amazonaws.com", + "X-Forwarded-Proto": "https", + "X-Amz-Cf-Id": "aaaaaaaaaae3VYQb9jd-nvCd-de396Uhbp027Y2JvkCPNLmGJHqlaA==", + "CloudFront-Is-Tablet-Viewer": "false", + "Cache-Control": "max-age=0", + "User-Agent": "Custom User Agent String", + "CloudFront-Forwarded-Proto": "https", + "Accept-Encoding": "gzip, deflate, sdch", + }, + "pathParameters": {"proxy": "/examplepath"}, + "httpMethod": "POST", + "stageVariables": {"baz": "qux"}, + "path": "/examplepath", + } + + +def test_lambda_handler(apigw_event, mocker): + + ret = app.lambda_handler(apigw_event, "") + data = json.loads(ret["body"]) + + assert ret["statusCode"] == 200 + assert "message" in ret["body"] + assert data["message"] == "hello world" From 67fc6742919d4e8e37f0106ed1386c09811279f8 Mon Sep 17 00:00:00 2001 From: Chodavarapu Naga Viswanadha Avinash Date: Tue, 22 Oct 2024 16:47:02 +0530 Subject: [PATCH 5/7] feat NR-305269 : Updated events and git ignore files. --- .../java-17-maven-sam-example/.gitignore | 209 ++++++++++++++++++ .../events/event.json | 63 ------ .../java-17-maven-sam-example/samconfig.toml | 30 --- .../java-17-maven-sam-example/template.yaml | 3 +- .../nodejs-sam-example/.gitignore | 4 +- .../nodejs-sam-example/events/event.json | 62 ------ .../nodejs-sam-example/samconfig.toml | 30 --- .../nodejs-sam-example/template.yaml | 2 - .../python-sam-example/.gitignore | 3 +- .../python-sam-example/events/event.json | 63 ------ .../python-sam-example/samconfig.toml | 30 --- .../python-sam-example/template.yaml | 2 - 12 files changed, 215 insertions(+), 286 deletions(-) create mode 100644 examples/sam/containerizedlambda/java-17-maven-sam-example/.gitignore delete mode 100644 examples/sam/containerizedlambda/java-17-maven-sam-example/events/event.json delete mode 100644 examples/sam/containerizedlambda/java-17-maven-sam-example/samconfig.toml delete mode 100644 examples/sam/containerizedlambda/nodejs-sam-example/events/event.json delete mode 100644 examples/sam/containerizedlambda/nodejs-sam-example/samconfig.toml delete mode 100644 examples/sam/containerizedlambda/python-sam-example/events/event.json delete mode 100644 examples/sam/containerizedlambda/python-sam-example/samconfig.toml diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/.gitignore b/examples/sam/containerizedlambda/java-17-maven-sam-example/.gitignore new file mode 100644 index 0000000..7885523 --- /dev/null +++ b/examples/sam/containerizedlambda/java-17-maven-sam-example/.gitignore @@ -0,0 +1,209 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/osx,node,linux,windows,sam +# Edit at https://www.toptal.com/developers/gitignore?templates=osx,node,linux,windows,sam + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test +.env*.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist + +# Storybook build outputs +.out +.storybook-out +storybook-static + +# rollup.js default build output +dist/ + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# Temporary folders +tmp/ +temp/ + +### OSX ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### SAM ### +# Ignore build directories for the AWS Serverless Application Model (SAM) +# Info: https://aws.amazon.com/serverless/sam/ +# Docs: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-reference.html + +**/.aws-sam + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/osx,node,linux,windows,sam +*.toml \ No newline at end of file diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/events/event.json b/examples/sam/containerizedlambda/java-17-maven-sam-example/events/event.json deleted file mode 100644 index 3822fad..0000000 --- a/examples/sam/containerizedlambda/java-17-maven-sam-example/events/event.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "body": "{\"message\": \"hello world\"}", - "resource": "/{proxy+}", - "path": "/path/to/resource", - "httpMethod": "POST", - "isBase64Encoded": false, - "queryStringParameters": { - "foo": "bar" - }, - "pathParameters": { - "proxy": "/path/to/resource" - }, - "stageVariables": { - "baz": "qux" - }, - "headers": { - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", - "Accept-Encoding": "gzip, deflate, sdch", - "Accept-Language": "en-US,en;q=0.8", - "Cache-Control": "max-age=0", - "CloudFront-Forwarded-Proto": "https", - "CloudFront-Is-Desktop-Viewer": "true", - "CloudFront-Is-Mobile-Viewer": "false", - "CloudFront-Is-SmartTV-Viewer": "false", - "CloudFront-Is-Tablet-Viewer": "false", - "CloudFront-Viewer-Country": "US", - "Host": "1234567890.execute-api.us-east-1.amazonaws.com", - "Upgrade-Insecure-Requests": "1", - "User-Agent": "Custom User Agent String", - "Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)", - "X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==", - "X-Forwarded-For": "127.0.0.1, 127.0.0.2", - "X-Forwarded-Port": "443", - "X-Forwarded-Proto": "https" - }, - "requestContext": { - "accountId": "123456789012", - "resourceId": "123456", - "stage": "prod", - "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", - "requestTime": "09/Apr/2015:12:34:56 +0000", - "requestTimeEpoch": 1428582896000, - "identity": { - "cognitoIdentityPoolId": null, - "accountId": null, - "cognitoIdentityId": null, - "caller": null, - "accessKey": null, - "sourceIp": "127.0.0.1", - "cognitoAuthenticationType": null, - "cognitoAuthenticationProvider": null, - "userArn": null, - "userAgent": "Custom User Agent String", - "user": null - }, - "path": "/prod/path/to/resource", - "resourcePath": "/{proxy+}", - "httpMethod": "POST", - "apiId": "1234567890", - "protocol": "HTTP/1.1" - } - } - \ No newline at end of file diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/samconfig.toml b/examples/sam/containerizedlambda/java-17-maven-sam-example/samconfig.toml deleted file mode 100644 index f0bf234..0000000 --- a/examples/sam/containerizedlambda/java-17-maven-sam-example/samconfig.toml +++ /dev/null @@ -1,30 +0,0 @@ -# More information about the configuration file can be found here: -# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html -version = 0.1 - -[default.global.parameters] -stack_name = "java-17-maven-sam-example" - -[default.build.parameters] -parallel = true - -[default.validate.parameters] -lint = true - -[default.deploy.parameters] -capabilities = "CAPABILITY_IAM" -confirm_changeset = true -resolve_s3 = true -resolve_image_repos = true - -[default.package.parameters] -resolve_s3 = true - -[default.sync.parameters] -watch = true - -[default.local_start_api.parameters] -warm_containers = "EAGER" - -[default.local_start_lambda.parameters] -warm_containers = "EAGER" diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/template.yaml b/examples/sam/containerizedlambda/java-17-maven-sam-example/template.yaml index 337277f..73f7be5 100644 --- a/examples/sam/containerizedlambda/java-17-maven-sam-example/template.yaml +++ b/examples/sam/containerizedlambda/java-17-maven-sam-example/template.yaml @@ -22,8 +22,7 @@ Resources: Variables: NEW_RELIC_LAMBDA_HANDLER: helloworld.App::handleRequest NEW_RELIC_LICENSE_KEY: "YOUR_NEWRELIC_LICENSE_KEY" - NEW_RELIC_LOG_ENDPOINT: "YOUR_NEWRELIC_LOG_ENDPOINT" - NEW_RELIC_TELEMETRY_ENDPOINT: "YOUR_NEWRELIC_TELEMETRY_ENDPOINT" + Metadata: DockerTag: java17-maven-v1 DockerContext: ./HelloWorldFunction diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/.gitignore b/examples/sam/containerizedlambda/nodejs-sam-example/.gitignore index 5854f05..7885523 100644 --- a/examples/sam/containerizedlambda/nodejs-sam-example/.gitignore +++ b/examples/sam/containerizedlambda/nodejs-sam-example/.gitignore @@ -150,7 +150,8 @@ temp/ .LSOverride # Icon must end with two \r -Icon +Icon + # Thumbnails ._* @@ -205,3 +206,4 @@ $RECYCLE.BIN/ *.lnk # End of https://www.toptal.com/developers/gitignore/api/osx,node,linux,windows,sam +*.toml \ No newline at end of file diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/events/event.json b/examples/sam/containerizedlambda/nodejs-sam-example/events/event.json deleted file mode 100644 index 070ad8e..0000000 --- a/examples/sam/containerizedlambda/nodejs-sam-example/events/event.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "body": "{\"message\": \"hello world\"}", - "resource": "/{proxy+}", - "path": "/path/to/resource", - "httpMethod": "POST", - "isBase64Encoded": false, - "queryStringParameters": { - "foo": "bar" - }, - "pathParameters": { - "proxy": "/path/to/resource" - }, - "stageVariables": { - "baz": "qux" - }, - "headers": { - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", - "Accept-Encoding": "gzip, deflate, sdch", - "Accept-Language": "en-US,en;q=0.8", - "Cache-Control": "max-age=0", - "CloudFront-Forwarded-Proto": "https", - "CloudFront-Is-Desktop-Viewer": "true", - "CloudFront-Is-Mobile-Viewer": "false", - "CloudFront-Is-SmartTV-Viewer": "false", - "CloudFront-Is-Tablet-Viewer": "false", - "CloudFront-Viewer-Country": "US", - "Host": "1234567890.execute-api.us-east-1.amazonaws.com", - "Upgrade-Insecure-Requests": "1", - "User-Agent": "Custom User Agent String", - "Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)", - "X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==", - "X-Forwarded-For": "127.0.0.1, 127.0.0.2", - "X-Forwarded-Port": "443", - "X-Forwarded-Proto": "https" - }, - "requestContext": { - "accountId": "123456789012", - "resourceId": "123456", - "stage": "prod", - "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", - "requestTime": "09/Apr/2015:12:34:56 +0000", - "requestTimeEpoch": 1428582896000, - "identity": { - "cognitoIdentityPoolId": null, - "accountId": null, - "cognitoIdentityId": null, - "caller": null, - "accessKey": null, - "sourceIp": "127.0.0.1", - "cognitoAuthenticationType": null, - "cognitoAuthenticationProvider": null, - "userArn": null, - "userAgent": "Custom User Agent String", - "user": null - }, - "path": "/prod/path/to/resource", - "resourcePath": "/{proxy+}", - "httpMethod": "POST", - "apiId": "1234567890", - "protocol": "HTTP/1.1" - } -} diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/samconfig.toml b/examples/sam/containerizedlambda/nodejs-sam-example/samconfig.toml deleted file mode 100644 index eaf48fd..0000000 --- a/examples/sam/containerizedlambda/nodejs-sam-example/samconfig.toml +++ /dev/null @@ -1,30 +0,0 @@ -# More information about the configuration file can be found here: -# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html -version = 0.1 - -[default.global.parameters] -stack_name = "nodejs-sam-example" - -[default.build.parameters] -parallel = true - -[default.validate.parameters] -lint = true - -[default.deploy.parameters] -capabilities = "CAPABILITY_IAM" -confirm_changeset = true -resolve_s3 = true -resolve_image_repos = true - -[default.package.parameters] -resolve_s3 = true - -[default.sync.parameters] -watch = true - -[default.local_start_api.parameters] -warm_containers = "EAGER" - -[default.local_start_lambda.parameters] -warm_containers = "EAGER" diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/template.yaml b/examples/sam/containerizedlambda/nodejs-sam-example/template.yaml index 95da295..7fffcb6 100644 --- a/examples/sam/containerizedlambda/nodejs-sam-example/template.yaml +++ b/examples/sam/containerizedlambda/nodejs-sam-example/template.yaml @@ -21,8 +21,6 @@ Resources: Variables: NEW_RELIC_LAMBDA_HANDLER: "app.lambdaHandler" NEW_RELIC_LICENSE_KEY: "YOUR_NEWRELIC_LICENSE_KEY" - NEW_RELIC_LOG_ENDPOINT: "YOUR_NEWRELIC_LOG_ENDPOINT" - NEW_RELIC_TELEMETRY_ENDPOINT: "YOUR_NEWRELIC_TELEMETRY_ENDPOINT" Metadata: DockerTag: nodejs20.x-v1 DockerContext: ./hello-world diff --git a/examples/sam/containerizedlambda/python-sam-example/.gitignore b/examples/sam/containerizedlambda/python-sam-example/.gitignore index 4808264..a78cee6 100644 --- a/examples/sam/containerizedlambda/python-sam-example/.gitignore +++ b/examples/sam/containerizedlambda/python-sam-example/.gitignore @@ -241,4 +241,5 @@ $RECYCLE.BIN/ */build/* -# End of https://www.gitignore.io/api/osx,linux,python,windows,pycharm,visualstudiocode \ No newline at end of file +# End of https://www.gitignore.io/api/osx,linux,python,windows,pycharm,visualstudiocode +*.toml \ No newline at end of file diff --git a/examples/sam/containerizedlambda/python-sam-example/events/event.json b/examples/sam/containerizedlambda/python-sam-example/events/event.json deleted file mode 100644 index a429ac5..0000000 --- a/examples/sam/containerizedlambda/python-sam-example/events/event.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "body": "{\"message\": \"hello world\"}", - "resource": "/hello", - "path": "/hello", - "httpMethod": "GET", - "isBase64Encoded": false, - "queryStringParameters": { - "foo": "bar" - }, - "pathParameters": { - "proxy": "/path/to/resource" - }, - "stageVariables": { - "baz": "qux" - }, - "headers": { - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", - "Accept-Encoding": "gzip, deflate, sdch", - "Accept-Language": "en-US,en;q=0.8", - "Cache-Control": "max-age=0", - "CloudFront-Forwarded-Proto": "https", - "CloudFront-Is-Desktop-Viewer": "true", - "CloudFront-Is-Mobile-Viewer": "false", - "CloudFront-Is-SmartTV-Viewer": "false", - "CloudFront-Is-Tablet-Viewer": "false", - "CloudFront-Viewer-Country": "US", - "Host": "1234567890.execute-api.us-east-1.amazonaws.com", - "Upgrade-Insecure-Requests": "1", - "User-Agent": "Custom User Agent String", - "Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)", - "X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==", - "X-Forwarded-For": "127.0.0.1, 127.0.0.2", - "X-Forwarded-Port": "443", - "X-Forwarded-Proto": "https" - }, - "requestContext": { - "accountId": "123456789012", - "resourceId": "123456", - "stage": "prod", - "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", - "requestTime": "09/Apr/2015:12:34:56 +0000", - "requestTimeEpoch": 1428582896000, - "identity": { - "cognitoIdentityPoolId": null, - "accountId": null, - "cognitoIdentityId": null, - "caller": null, - "accessKey": null, - "sourceIp": "127.0.0.1", - "cognitoAuthenticationType": null, - "cognitoAuthenticationProvider": null, - "userArn": null, - "userAgent": "Custom User Agent String", - "user": null - }, - "path": "/prod/hello", - "resourcePath": "/hello", - "httpMethod": "POST", - "apiId": "1234567890", - "protocol": "HTTP/1.1" - } - } - \ No newline at end of file diff --git a/examples/sam/containerizedlambda/python-sam-example/samconfig.toml b/examples/sam/containerizedlambda/python-sam-example/samconfig.toml deleted file mode 100644 index ea5b01a..0000000 --- a/examples/sam/containerizedlambda/python-sam-example/samconfig.toml +++ /dev/null @@ -1,30 +0,0 @@ -# More information about the configuration file can be found here: -# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html -version = 0.1 - -[default.global.parameters] -stack_name = "python-sam-example" - -[default.build.parameters] -parallel = true - -[default.validate.parameters] -lint = true - -[default.deploy.parameters] -capabilities = "CAPABILITY_IAM" -confirm_changeset = true -resolve_s3 = true -resolve_image_repos = true - -[default.package.parameters] -resolve_s3 = true - -[default.sync.parameters] -watch = true - -[default.local_start_api.parameters] -warm_containers = "EAGER" - -[default.local_start_lambda.parameters] -warm_containers = "EAGER" diff --git a/examples/sam/containerizedlambda/python-sam-example/template.yaml b/examples/sam/containerizedlambda/python-sam-example/template.yaml index 3f41bc9..e346547 100644 --- a/examples/sam/containerizedlambda/python-sam-example/template.yaml +++ b/examples/sam/containerizedlambda/python-sam-example/template.yaml @@ -21,8 +21,6 @@ Resources: Variables: NEW_RELIC_LAMBDA_HANDLER: "app.lambda_handler" NEW_RELIC_LICENSE_KEY: "YOUR_NEWRELIC_LICENSE_KEY" - NEW_RELIC_LOG_ENDPOINT: "YOUR_NEWRELIC_LOG_ENDPOINT" - NEW_RELIC_TELEMETRY_ENDPOINT: "YOUR_NEWRELIC_TELEMETRY_ENDPOINT" Metadata: Dockerfile: Dockerfile From c70ab9a490bfbe82c9c73a840158606301ca6b4a Mon Sep 17 00:00:00 2001 From: Chodavarapu Naga Viswanadha Avinash Date: Tue, 22 Oct 2024 17:04:45 +0530 Subject: [PATCH 6/7] feat NR-305269 : Updated Readme file to simple explanation. --- .../java-17-maven-sam-example/README.md | 167 ++++++----------- .../nodejs-sam-example/README.md | 170 ++++++----------- .../python-sam-example/README.md | 171 +++++++----------- 3 files changed, 181 insertions(+), 327 deletions(-) diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/README.md b/examples/sam/containerizedlambda/java-17-maven-sam-example/README.md index 4e21393..e54e7b1 100644 --- a/examples/sam/containerizedlambda/java-17-maven-sam-example/README.md +++ b/examples/sam/containerizedlambda/java-17-maven-sam-example/README.md @@ -1,134 +1,87 @@ # java-17-maven-sam-example -This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders. +This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes: -- HelloWorldFunction/src/main - Code for the application's Lambda function and Project Dockerfile. -- events - Invocation events that you can use to invoke the function. -- HelloWorldFunction/src/test - Unit tests for the application code. -- template.yaml - A template that defines the application's AWS resources. +- `HelloWorldFunction/src/main`: Code for the application's Lambda function and Project Dockerfile. +- `events`: Invocation events that you can use to invoke the function. +- `HelloWorldFunction/src/test`: Unit tests for the application code. +- `template.yaml`: A template that defines the application's AWS resources. -The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code. +## Getting Started -## Getting started +### Prerequisites -There are two ways to start using this serverless application example: +1. **Install SAM CLI**: [Installation instructions](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) +2. **Install Docker**: [Docker Community Edition installation guide](https://hub.docker.com/search/?type=edition&offering=community) +3. **Install Java 17**: [Java 17 installation](https://docs.aws.amazon.com/corretto/latest/corretto-17-ug/downloads-list.html) +4. **Install Maven**: [Maven installation](https://maven.apache.org/install.html) -### Option 1: Create a new SAM project - -You can create your own SAM project using the `sam init` command: - -1. **Set up your environment**: Before you start, make sure that you have the SAM CLI and Docker installed on your machine. - - Install the SAM CLI following these [installation instructions](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html). - - Install Docker using the [Docker Community Edition installation guide](https://hub.docker.com/search/?type=edition&offering=community). - -2. **Initiate a new project**: - Run the following command to create a new serverless application with a Docker image package type: +### Option 1: Create a New SAM Project +1. **Initialize Project**: ```bash sam init --package-type Image ``` +2. **Select Template**: Choose `AWS Quick Start Templates` and `Hello World Example`. +3. **Configure Project**: Follow the prompts. -3. **Select the desired template**: Choose `AWS Quick Start Templates` and then select the `Hello World Example`. - -4. **Configure your project**: Follow the prompts to set up your project, adding any additional features if necessary. - -### Option 2: Clone an existing repository - -Alternatively, you can clone this existing repository and deploy the application directly. - -After cloning the repository or creating a new SAM project, you can then build and deploy your application as described in the following sections. - - -The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code. - -## Deploy the sample application - -The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API. - -To use the SAM CLI, you need the following tools. - -* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) -* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) - -You may need the following for local testing. -* java17 - [Install the Java 17](https://docs.aws.amazon.com/corretto/latest/corretto-17-ug/downloads-list.html) -* Maven - [Install Maven](https://maven.apache.org/install.html) - -To build and deploy your application for the first time, run the following in your shell: - -```bash -sam build -sam deploy --guided -``` - -The first command will build a docker image from a Dockerfile and then copy the source of your application inside the Docker image. The second command will package and deploy your application to AWS, with a series of prompts: - -* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name. -* **AWS Region**: The AWS region you want to deploy your app to. -* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes. -* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modifies IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command. -* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application. - -You can find your API Gateway Endpoint URL in the output values displayed after deployment. - -## Use the SAM CLI to build and test locally - -Build your application with the `sam build` command. - -```bash -java-17-maven-sam-example$ sam build -``` - -The SAM CLI builds a docker image from a Dockerfile and then installs dependencies defined in `HelloWorldFunction/pom.xml` inside the docker image. The processed template file is saved in the `.aws-sam/build` folder. - - +### Option 2: Clone Existing Repository -Run functions locally and invoke them with the `sam local invoke` command. - -```bash -java-17-maven-sam-example$ sam local invoke HelloWorldFunction -``` - -The SAM CLI can also emulate your application's API. Use the `sam local start-api` to run the API locally on port 3000. - -```bash -java-17-maven-sam-example$ sam local start-api -java-17-maven-sam-example$ curl http://localhost:3000/ - -## Add a resource to your application -The application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in [the SAM specification](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md), you can use standard [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html) resource types. +1. **Clone Repository**: + ```bash + git clone https://github.com/newrelic/newrelic-lambda-extension.git + ``` -## Fetch, tail, and filter Lambda function logs +## Deploy the Application -To simplify troubleshooting, SAM CLI has a command called `sam logs`. `sam logs` lets you fetch logs generated by your deployed Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug. +1. **Build Application**: + ```bash + sam build + ``` +2. **Deploy Application**: + ```bash + sam deploy --guided + ``` -`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM. +## Local Development -```bash -java-17-maven-sam-example$ sam logs -n HelloWorldFunction --stack-name java-17-maven-sam-example --tail -``` +1. **Build Locally**: + ```bash + sam build + ``` +2. **Invoke Function Locally**: + ```bash + sam local invoke HelloWorldFunction + ``` +3. **Start Local API**: + ```bash + sam local start-api + curl http://localhost:3000/ + ``` -You can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html). +## Fetch Logs -## Unit tests +1. **Fetch Lambda Logs**: + ```bash + sam logs -n HelloWorldFunction --stack-name java-17-maven-sam-example --tail + ``` -Tests are defined in the `HelloWorldFunction/src/test` folder in this project. +## Run Unit Tests -```bash -java-17-maven-sam-example$ cd HelloWorldFunction -HelloWorldFunction$ mvn test -``` +1. **Run Tests**: + ```bash + cd HelloWorldFunction + mvn test + ``` ## Cleanup -To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following: - -```bash -sam delete --stack-name java-17-maven-sam-example -``` +1. **Delete Deployed Application**: + ```bash + sam delete --stack-name java-17-maven-sam-example + ``` ## Resources -See the [AWS SAM developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) for an introduction to SAM specification, the SAM CLI, and serverless application concepts. - -Next, you can use AWS Serverless Application Repository to deploy ready to use Apps that go beyond hello world samples and learn how authors developed their applications: [AWS Serverless Application Repository main page](https://aws.amazon.com/serverless/serverlessrepo/) +- [AWS SAM Developer Guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) +- [AWS Serverless Application Repository](https://aws.amazon.com/serverless/serverlessrepo/) \ No newline at end of file diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/README.md b/examples/sam/containerizedlambda/nodejs-sam-example/README.md index 77e025a..85b4fd7 100644 --- a/examples/sam/containerizedlambda/nodejs-sam-example/README.md +++ b/examples/sam/containerizedlambda/nodejs-sam-example/README.md @@ -1,137 +1,87 @@ # nodejs-sam-example -This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders. +This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes: -- hello-world - Code for the application's Lambda function and Project Dockerfile. -- events - Invocation events that you can use to invoke the function. -- hello-world/tests - Unit tests for the application code. -- template.yaml - A template that defines the application's AWS resources. +- `hello-world`: Code for the application's Lambda function and Project Dockerfile. +- `events`: Invocation events that you can use to invoke the function. +- `hello-world/tests`: Unit tests for the application code. +- `template.yaml`: A template that defines the application's AWS resources. +## Getting Started -Certainly! You can instruct users to either set up a new project using AWS SAM or clone an existing repository to deploy the application. Here's how you can include both options in the README introduction: +### Prerequisites -## Getting started +1. **Install SAM CLI**: [Installation instructions](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) +2. **Install Docker**: [Docker Community Edition installation guide](https://hub.docker.com/search/?type=edition&offering=community) +3. **Install Node.js**: [Node.js 20 installation](https://nodejs.org/en/) -There are two ways to start using this serverless application example: - -### Option 1: Create a new SAM project - -You can create your own SAM project using the `sam init` command: - -1. **Set up your environment**: Before you start, make sure that you have the SAM CLI and Docker installed on your machine. - - Install the SAM CLI following these [installation instructions](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html). - - Install Docker using the [Docker Community Edition installation guide](https://hub.docker.com/search/?type=edition&offering=community). - -2. **Initiate a new project**: - Run the following command to create a new serverless application with a Docker image package type: +### Option 1: Create a New SAM Project +1. **Initialize Project**: ```bash sam init --package-type Image ``` +2. **Select Template**: Choose `AWS Quick Start Templates` and `Hello World Example`. +3. **Configure Project**: Follow the prompts. -3. **Select the desired template**: Choose `AWS Quick Start Templates` and then select the `Hello World Example`. - -4. **Configure your project**: Follow the prompts to set up your project, adding any additional features if necessary. - -### Option 2: Clone an existing repository - -Alternatively, you can clone this existing repository and deploy the application directly. - -After cloning the repository or creating a new SAM project, you can then build and deploy your application as described in the following sections. - - -The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code. - -## Deploy the sample application - -The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API. - -To use the SAM CLI, you need the following tools. - -* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) -* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) - -You may need the following for local testing. - -* Node.js - [Install Node.js 20](https://nodejs.org/en/), including the NPM package management tool. - -To build and deploy your application for the first time, run the following in your shell: - -```bash -sam build -sam deploy --guided -``` - -The first command will build a docker image from a Dockerfile and then the source of your application inside the Docker image. The second command will package and deploy your application to AWS, with a series of prompts: - -* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name. -* **AWS Region**: The AWS region you want to deploy your app to. -* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes. -* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modifies IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command. -* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application. - -You can find your API Gateway Endpoint URL in the output values displayed after deployment. - -## Use the SAM CLI to build and test locally - -Build your application with the `sam build` command. - -```bash -nodejs-sam-example$ sam build -``` - -The SAM CLI builds a docker image from a Dockerfile and then installs dependencies defined in `hello-world/package.json` inside the docker image. The processed template file is saved in the `.aws-sam/build` folder. -* **Note**: The Dockerfile included in this sample application uses `npm install` by default. If you are building your code for production, you can modify it to use `npm ci` instead. +### Option 2: Clone Existing Repository +1. **Clone Repository**: + ```bash + git clone https://github.com/newrelic/newrelic-lambda-extension.git + ``` -Run functions locally and invoke them with the `sam local invoke` command. - -```bash -nodejs-sam-example$ sam local invoke HelloWorldFunction -``` - -The SAM CLI can also emulate your application's API. Use the `sam local start-api` to run the API locally on port 3000. - -```bash -nodejs-sam-example$ sam local start-api -nodejs-sam-example$ curl http://localhost:3000/ -``` - -## Add a resource to your application -The application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in [the SAM specification](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md), you can use standard [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html) resource types. - -## Fetch, tail, and filter Lambda function logs +## Deploy the Application -To simplify troubleshooting, SAM CLI has a command called `sam logs`. `sam logs` lets you fetch logs generated by your deployed Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug. +1. **Build Application**: + ```bash + sam build + ``` +2. **Deploy Application**: + ```bash + sam deploy --guided + ``` -`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM. +## Local Development -```bash -nodejs-sam-example$ sam logs -n HelloWorldFunction --stack-name nodejs-sam-example --tail -``` +1. **Build Locally**: + ```bash + sam build + ``` +2. **Invoke Function Locally**: + ```bash + sam local invoke HelloWorldFunction + ``` +3. **Start Local API**: + ```bash + sam local start-api + curl http://localhost:3000/ + ``` -You can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html). +## Fetch Logs -## Unit tests +1. **Fetch Lambda Logs**: + ```bash + sam logs -n HelloWorldFunction --stack-name nodejs-sam-example --tail + ``` -Tests are defined in the `hello-world/tests` folder in this project. Use NPM to install the [Mocha test framework](https://mochajs.org/) and run unit tests from your local machine. +## Run Unit Tests -```bash -nodejs-sam-example$ cd hello-world -hello-world$ npm install -hello-world$ npm run test -``` +1. **Install Test Dependencies**: + ```bash + cd hello-world + npm install + npm run test + ``` ## Cleanup -To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following: - -```bash -sam delete --stack-name nodejs-sam-example -``` +1. **Delete Deployed Application**: + ```bash + sam delete --stack-name nodejs-sam-example + ``` ## Resources -See the [AWS SAM developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) for an introduction to SAM specification, the SAM CLI, and serverless application concepts. - -Next, you can use AWS Serverless Application Repository to deploy ready to use Apps that go beyond hello world samples and learn how authors developed their applications: [AWS Serverless Application Repository main page](https://aws.amazon.com/serverless/serverlessrepo/) +- [AWS SAM Developer Guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) +- [AWS Serverless Application Repository](https://aws.amazon.com/serverless/serverlessrepo/) \ No newline at end of file diff --git a/examples/sam/containerizedlambda/python-sam-example/README.md b/examples/sam/containerizedlambda/python-sam-example/README.md index 0a97bf0..9283b42 100644 --- a/examples/sam/containerizedlambda/python-sam-example/README.md +++ b/examples/sam/containerizedlambda/python-sam-example/README.md @@ -1,137 +1,88 @@ # python-sam-example -This project contains source code for a "Hello World" serverless application that you can deploy with the SAM CLI. It includes the following files and folders: +This project contains source code for a "Hello World" serverless application that you can deploy with the SAM CLI. It includes: -- hello_world - Code for the application's Lambda function and Project Dockerfile. -- tests - Unit tests for the application code. -- template.yaml - A template that defines the application's AWS resources. +- `hello_world`: Code for the application's Lambda function and Dockerfile. +- `tests`: Unit tests for the application code. +- `template.yaml`: Defines the application's AWS resources. -The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. +## Getting Started +### Prerequisites -## Getting started +1. **Install SAM CLI**: [Installation instructions](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) +2. **Install Docker**: [Docker Community Edition installation guide](https://hub.docker.com/search/?type=edition&offering=community) +3. **Install Python 3**: [Python 3 installation](https://www.python.org/downloads/) -There are two ways to start using this serverless application example: - -### Option 1: Create a new SAM project - -You can create your own SAM project using the `sam init` command: - -1. **Set up your environment**: Before you start, make sure that you have the SAM CLI and Docker installed on your machine. - - Install the SAM CLI following these [installation instructions](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html). - - Install Docker using the [Docker Community Edition installation guide](https://hub.docker.com/search/?type=edition&offering=community). - -2. **Initiate a new project**: - Run the following command to create a new serverless application with a Docker image package type: +### Option 1: Create a New SAM Project +1. **Initialize Project**: ```bash sam init --package-type Image ``` +2. **Select Template**: Choose `AWS Quick Start Templates` and `Hello World Example`. +3. **Configure Project**: Follow the prompts. -3. **Select the desired template**: Choose `AWS Quick Start Templates` and then select the `Hello World Example`. - -4. **Configure your project**: Follow the prompts to set up your project, adding any additional features if necessary. - -### Option 2: Clone an existing repository - -Alternatively, you can clone this existing repository and deploy the application directly. - -After cloning the repository or creating a new SAM project, you can then build and deploy your application as described in the following sections. - - -The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code. - - -## Deploy the sample application - - -The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API. - -To use the SAM CLI, you need the following tools. - -* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) -* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) - -You may need the following for local testing. -* [Python 3 installed](https://www.python.org/downloads/) - -To build and deploy your application for the first time, run the following in your shell: - -```bash -sam build -sam deploy --guided -``` - -The `sam build` command builds the application, and the `sam deploy --guided` command prompts you to configure the deployment settings. The guided deployment will also save your settings to `samconfig.toml` for future deployments. - -The first command will build a docker image from a Dockerfile and then copy the source of your application inside the Docker image. The second command will package and deploy your application to AWS, with a series of prompts: - -* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name. -* **AWS Region**: The AWS region you want to deploy your app to. -* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes. -* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modifies IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command. -* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application. - -You can find your API Gateway Endpoint URL in the output values displayed after deployment. - -## Use the SAM CLI to build and test locally - -Build your application with the `sam build` command. - -```bash -python-sam-example$ sam build -``` - -The SAM CLI builds a docker image from a Dockerfile and then installs dependencies defined in `hello_world/requirements.txt` inside the docker image. The processed template file is saved in the `.aws-sam/build` folder. +### Option 2: Clone Existing Repository -You can invoke the function locally with the `sam local invoke` command: - -```bash -python-sam-example$ sam local invoke HelloWorldFunction -``` - -The SAM CLI can also emulate your application's API. Run the API locally with the following command: - -```bash -python-sam-example$ sam local start-api -python-sam-example$ curl http://localhost:3000/hello -``` - -## Add a resource to your application -The application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in [the SAM specification](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md), you can use standard [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html) resource types. - -## Fetch, tail, and filter Lambda function logs +1. **Clone Repository**: + ```bash + git clone https://github.com/newrelic/newrelic-lambda-extension.git + ``` -To simplify troubleshooting, SAM CLI has a command called `sam logs`. `sam logs` lets you fetch logs generated by your deployed Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug. +## Deploy the Application -`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM. +1. **Build Application**: + ```bash + sam build + ``` +2. **Deploy Application**: + ```bash + sam deploy --guided + ``` -```bash -python-sam-example$ sam logs -n HelloWorldFunction --stack-name "python-sam-example" --tail -``` +## Local Development -You can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html). +1. **Build Locally**: + ```bash + sam build + ``` +2. **Invoke Function Locally**: + ```bash + sam local invoke HelloWorldFunction + ``` +3. **Start Local API**: + ```bash + sam local start-api + curl http://localhost:3000/hello + ``` +## Fetch Logs -## Unit tests +1. **Fetch Lambda Logs**: + ```bash + sam logs -n HelloWorldFunction --stack-name "python-sam-example" --tail + ``` -Run unit tests using pytest: +## Run Unit Tests -```bash -python-sam-example$ pip install pytest pytest-mock --user -python-sam-example$ python -m pytest tests/ -v -``` +1. **Install Test Dependencies**: + ```bash + pip install pytest pytest-mock --user + ``` +2. **Run Tests**: + ```bash + python -m pytest tests/ -v + ``` ## Cleanup -To delete the deployed "Hello World" application, run: - -```bash -sam delete --stack-name "python-sam-example" -``` +1. **Delete Deployed Application**: + ```bash + sam delete --stack-name "python-sam-example" + ``` ## Resources -For more information about developing with SAM, visit the [AWS SAM developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html). - -Check out the [AWS Serverless Application Repository](https://aws.amazon.com/serverless/serverlessrepo/) to find ready-to-use serverless applications beyond simple samples. \ No newline at end of file +- [AWS SAM Developer Guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) +- [AWS Serverless Application Repository](https://aws.amazon.com/serverless/serverlessrepo/) From 6e0f6a6026ab91fbe1e3a098cf52a66b4eba0c85 Mon Sep 17 00:00:00 2001 From: Chodavarapu Naga Viswanadha Avinash Date: Wed, 23 Oct 2024 09:01:41 +0530 Subject: [PATCH 7/7] feat NR-305269 : Renaming the folder name. --- .../java-17-maven-sam-example/.gitignore | 0 .../java-17-maven-sam-example/HelloWorldFunction/Dockerfile | 0 .../java-17-maven-sam-example/HelloWorldFunction/pom.xml | 0 .../HelloWorldFunction/src/main/java/helloworld/App.java | 0 .../HelloWorldFunction/src/test/java/helloworld/AppTest.java | 0 .../java-17-maven-sam-example/README.md | 0 .../java-17-maven-sam-example/template.yaml | 0 .../nodejs-sam-example/.gitignore | 0 .../nodejs-sam-example/README.md | 0 .../nodejs-sam-example/hello-world/.npmignore | 0 .../nodejs-sam-example/hello-world/Dockerfile | 0 .../nodejs-sam-example/hello-world/app.mjs | 0 .../nodejs-sam-example/hello-world/package-lock.json | 0 .../nodejs-sam-example/hello-world/package.json | 0 .../nodejs-sam-example/hello-world/tests/unit/test-handler.mjs | 0 .../nodejs-sam-example/template.yaml | 0 .../python-sam-example/.gitignore | 0 .../python-sam-example/README.md | 0 .../python-sam-example/__init__.py | 0 .../python-sam-example/hello_world/Dockerfile | 0 .../python-sam-example/hello_world/__init__.py | 0 .../python-sam-example/hello_world/app.py | 0 .../python-sam-example/hello_world/requirements.txt | 0 .../python-sam-example/template.yaml | 0 .../python-sam-example/tests/__init__.py | 0 .../python-sam-example/tests/unit/__init__.py | 0 .../python-sam-example/tests/unit/test_handler.py | 0 27 files changed, 0 insertions(+), 0 deletions(-) rename examples/sam/{containerizedlambda => containerized-lambda}/java-17-maven-sam-example/.gitignore (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/java-17-maven-sam-example/HelloWorldFunction/Dockerfile (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/java-17-maven-sam-example/HelloWorldFunction/pom.xml (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/java-17-maven-sam-example/HelloWorldFunction/src/main/java/helloworld/App.java (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/java-17-maven-sam-example/HelloWorldFunction/src/test/java/helloworld/AppTest.java (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/java-17-maven-sam-example/README.md (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/java-17-maven-sam-example/template.yaml (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/nodejs-sam-example/.gitignore (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/nodejs-sam-example/README.md (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/nodejs-sam-example/hello-world/.npmignore (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/nodejs-sam-example/hello-world/Dockerfile (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/nodejs-sam-example/hello-world/app.mjs (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/nodejs-sam-example/hello-world/package-lock.json (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/nodejs-sam-example/hello-world/package.json (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/nodejs-sam-example/hello-world/tests/unit/test-handler.mjs (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/nodejs-sam-example/template.yaml (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/python-sam-example/.gitignore (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/python-sam-example/README.md (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/python-sam-example/__init__.py (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/python-sam-example/hello_world/Dockerfile (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/python-sam-example/hello_world/__init__.py (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/python-sam-example/hello_world/app.py (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/python-sam-example/hello_world/requirements.txt (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/python-sam-example/template.yaml (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/python-sam-example/tests/__init__.py (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/python-sam-example/tests/unit/__init__.py (100%) rename examples/sam/{containerizedlambda => containerized-lambda}/python-sam-example/tests/unit/test_handler.py (100%) diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/.gitignore b/examples/sam/containerized-lambda/java-17-maven-sam-example/.gitignore similarity index 100% rename from examples/sam/containerizedlambda/java-17-maven-sam-example/.gitignore rename to examples/sam/containerized-lambda/java-17-maven-sam-example/.gitignore diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/Dockerfile b/examples/sam/containerized-lambda/java-17-maven-sam-example/HelloWorldFunction/Dockerfile similarity index 100% rename from examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/Dockerfile rename to examples/sam/containerized-lambda/java-17-maven-sam-example/HelloWorldFunction/Dockerfile diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/pom.xml b/examples/sam/containerized-lambda/java-17-maven-sam-example/HelloWorldFunction/pom.xml similarity index 100% rename from examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/pom.xml rename to examples/sam/containerized-lambda/java-17-maven-sam-example/HelloWorldFunction/pom.xml diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/src/main/java/helloworld/App.java b/examples/sam/containerized-lambda/java-17-maven-sam-example/HelloWorldFunction/src/main/java/helloworld/App.java similarity index 100% rename from examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/src/main/java/helloworld/App.java rename to examples/sam/containerized-lambda/java-17-maven-sam-example/HelloWorldFunction/src/main/java/helloworld/App.java diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/src/test/java/helloworld/AppTest.java b/examples/sam/containerized-lambda/java-17-maven-sam-example/HelloWorldFunction/src/test/java/helloworld/AppTest.java similarity index 100% rename from examples/sam/containerizedlambda/java-17-maven-sam-example/HelloWorldFunction/src/test/java/helloworld/AppTest.java rename to examples/sam/containerized-lambda/java-17-maven-sam-example/HelloWorldFunction/src/test/java/helloworld/AppTest.java diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/README.md b/examples/sam/containerized-lambda/java-17-maven-sam-example/README.md similarity index 100% rename from examples/sam/containerizedlambda/java-17-maven-sam-example/README.md rename to examples/sam/containerized-lambda/java-17-maven-sam-example/README.md diff --git a/examples/sam/containerizedlambda/java-17-maven-sam-example/template.yaml b/examples/sam/containerized-lambda/java-17-maven-sam-example/template.yaml similarity index 100% rename from examples/sam/containerizedlambda/java-17-maven-sam-example/template.yaml rename to examples/sam/containerized-lambda/java-17-maven-sam-example/template.yaml diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/.gitignore b/examples/sam/containerized-lambda/nodejs-sam-example/.gitignore similarity index 100% rename from examples/sam/containerizedlambda/nodejs-sam-example/.gitignore rename to examples/sam/containerized-lambda/nodejs-sam-example/.gitignore diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/README.md b/examples/sam/containerized-lambda/nodejs-sam-example/README.md similarity index 100% rename from examples/sam/containerizedlambda/nodejs-sam-example/README.md rename to examples/sam/containerized-lambda/nodejs-sam-example/README.md diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/.npmignore b/examples/sam/containerized-lambda/nodejs-sam-example/hello-world/.npmignore similarity index 100% rename from examples/sam/containerizedlambda/nodejs-sam-example/hello-world/.npmignore rename to examples/sam/containerized-lambda/nodejs-sam-example/hello-world/.npmignore diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/Dockerfile b/examples/sam/containerized-lambda/nodejs-sam-example/hello-world/Dockerfile similarity index 100% rename from examples/sam/containerizedlambda/nodejs-sam-example/hello-world/Dockerfile rename to examples/sam/containerized-lambda/nodejs-sam-example/hello-world/Dockerfile diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/app.mjs b/examples/sam/containerized-lambda/nodejs-sam-example/hello-world/app.mjs similarity index 100% rename from examples/sam/containerizedlambda/nodejs-sam-example/hello-world/app.mjs rename to examples/sam/containerized-lambda/nodejs-sam-example/hello-world/app.mjs diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/package-lock.json b/examples/sam/containerized-lambda/nodejs-sam-example/hello-world/package-lock.json similarity index 100% rename from examples/sam/containerizedlambda/nodejs-sam-example/hello-world/package-lock.json rename to examples/sam/containerized-lambda/nodejs-sam-example/hello-world/package-lock.json diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/package.json b/examples/sam/containerized-lambda/nodejs-sam-example/hello-world/package.json similarity index 100% rename from examples/sam/containerizedlambda/nodejs-sam-example/hello-world/package.json rename to examples/sam/containerized-lambda/nodejs-sam-example/hello-world/package.json diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/hello-world/tests/unit/test-handler.mjs b/examples/sam/containerized-lambda/nodejs-sam-example/hello-world/tests/unit/test-handler.mjs similarity index 100% rename from examples/sam/containerizedlambda/nodejs-sam-example/hello-world/tests/unit/test-handler.mjs rename to examples/sam/containerized-lambda/nodejs-sam-example/hello-world/tests/unit/test-handler.mjs diff --git a/examples/sam/containerizedlambda/nodejs-sam-example/template.yaml b/examples/sam/containerized-lambda/nodejs-sam-example/template.yaml similarity index 100% rename from examples/sam/containerizedlambda/nodejs-sam-example/template.yaml rename to examples/sam/containerized-lambda/nodejs-sam-example/template.yaml diff --git a/examples/sam/containerizedlambda/python-sam-example/.gitignore b/examples/sam/containerized-lambda/python-sam-example/.gitignore similarity index 100% rename from examples/sam/containerizedlambda/python-sam-example/.gitignore rename to examples/sam/containerized-lambda/python-sam-example/.gitignore diff --git a/examples/sam/containerizedlambda/python-sam-example/README.md b/examples/sam/containerized-lambda/python-sam-example/README.md similarity index 100% rename from examples/sam/containerizedlambda/python-sam-example/README.md rename to examples/sam/containerized-lambda/python-sam-example/README.md diff --git a/examples/sam/containerizedlambda/python-sam-example/__init__.py b/examples/sam/containerized-lambda/python-sam-example/__init__.py similarity index 100% rename from examples/sam/containerizedlambda/python-sam-example/__init__.py rename to examples/sam/containerized-lambda/python-sam-example/__init__.py diff --git a/examples/sam/containerizedlambda/python-sam-example/hello_world/Dockerfile b/examples/sam/containerized-lambda/python-sam-example/hello_world/Dockerfile similarity index 100% rename from examples/sam/containerizedlambda/python-sam-example/hello_world/Dockerfile rename to examples/sam/containerized-lambda/python-sam-example/hello_world/Dockerfile diff --git a/examples/sam/containerizedlambda/python-sam-example/hello_world/__init__.py b/examples/sam/containerized-lambda/python-sam-example/hello_world/__init__.py similarity index 100% rename from examples/sam/containerizedlambda/python-sam-example/hello_world/__init__.py rename to examples/sam/containerized-lambda/python-sam-example/hello_world/__init__.py diff --git a/examples/sam/containerizedlambda/python-sam-example/hello_world/app.py b/examples/sam/containerized-lambda/python-sam-example/hello_world/app.py similarity index 100% rename from examples/sam/containerizedlambda/python-sam-example/hello_world/app.py rename to examples/sam/containerized-lambda/python-sam-example/hello_world/app.py diff --git a/examples/sam/containerizedlambda/python-sam-example/hello_world/requirements.txt b/examples/sam/containerized-lambda/python-sam-example/hello_world/requirements.txt similarity index 100% rename from examples/sam/containerizedlambda/python-sam-example/hello_world/requirements.txt rename to examples/sam/containerized-lambda/python-sam-example/hello_world/requirements.txt diff --git a/examples/sam/containerizedlambda/python-sam-example/template.yaml b/examples/sam/containerized-lambda/python-sam-example/template.yaml similarity index 100% rename from examples/sam/containerizedlambda/python-sam-example/template.yaml rename to examples/sam/containerized-lambda/python-sam-example/template.yaml diff --git a/examples/sam/containerizedlambda/python-sam-example/tests/__init__.py b/examples/sam/containerized-lambda/python-sam-example/tests/__init__.py similarity index 100% rename from examples/sam/containerizedlambda/python-sam-example/tests/__init__.py rename to examples/sam/containerized-lambda/python-sam-example/tests/__init__.py diff --git a/examples/sam/containerizedlambda/python-sam-example/tests/unit/__init__.py b/examples/sam/containerized-lambda/python-sam-example/tests/unit/__init__.py similarity index 100% rename from examples/sam/containerizedlambda/python-sam-example/tests/unit/__init__.py rename to examples/sam/containerized-lambda/python-sam-example/tests/unit/__init__.py diff --git a/examples/sam/containerizedlambda/python-sam-example/tests/unit/test_handler.py b/examples/sam/containerized-lambda/python-sam-example/tests/unit/test_handler.py similarity index 100% rename from examples/sam/containerizedlambda/python-sam-example/tests/unit/test_handler.py rename to examples/sam/containerized-lambda/python-sam-example/tests/unit/test_handler.py