From 0f75eb788156b132a99812a0069c6b80b7e1db78 Mon Sep 17 00:00:00 2001 From: Kyle Roach Date: Thu, 12 Dec 2019 13:29:02 -0400 Subject: [PATCH] feat: Remove nodejs6.10 init template (#1505) Since April 30, 2019, it's no longer possible to create new functions using nodejs6.10 https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html. --- samcli/local/common/runtime_template.py | 10 +- .../.gitignore | 168 -------------- .../LICENSE | 14 -- .../README.md | 19 -- .../cookiecutter.json | 4 - .../setup.cfg | 2 - .../{{cookiecutter.project_name}}/.gitignore | 129 ----------- .../{{cookiecutter.project_name}}/README.md | 211 ------------------ .../{{cookiecutter.project_name}}/event.json | 62 ----- .../hello-world/.npmignore | 1 - .../hello-world/app-deps.js | 34 --- .../hello-world/app.js | 23 -- .../hello-world/package.json | 19 -- .../hello-world/tests/unit/test-handler.js | 27 --- .../template.yaml | 39 ---- 15 files changed, 1 insertion(+), 761 deletions(-) delete mode 100644 samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/.gitignore delete mode 100644 samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/LICENSE delete mode 100644 samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/README.md delete mode 100644 samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/cookiecutter.json delete mode 100644 samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/setup.cfg delete mode 100644 samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/.gitignore delete mode 100644 samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/README.md delete mode 100644 samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/event.json delete mode 100644 samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/.npmignore delete mode 100644 samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/app-deps.js delete mode 100644 samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/app.js delete mode 100644 samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/package.json delete mode 100644 samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/tests/unit/test-handler.js delete mode 100644 samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/template.yaml diff --git a/samcli/local/common/runtime_template.py b/samcli/local/common/runtime_template.py index ac3ffcafde..67a03513f2 100644 --- a/samcli/local/common/runtime_template.py +++ b/samcli/local/common/runtime_template.py @@ -34,13 +34,7 @@ "dependency_manager": "npm", "init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-nodejs"), "build": True, - }, - { - "runtimes": ["nodejs6.10"], - "dependency_manager": "npm", - "init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-nodejs6"), - "build": True, - }, + } ], "dotnet": [ { @@ -83,7 +77,6 @@ "nodejs12.x": ["npm"], "nodejs10.x": ["npm"], "nodejs8.10": ["npm"], - "nodejs6.10": ["npm"], "dotnetcore2.1": ["cli-package"], "dotnetcore2.0": ["cli-package"], "dotnetcore1.0": ["cli-package"], @@ -115,7 +108,6 @@ # older nodejs runtimes "nodejs10.x", "nodejs8.10", - "nodejs6.10", # older python runtimes "python3.7", "python3.6", diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/.gitignore b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/.gitignore deleted file mode 100644 index 74ea25e0e5..0000000000 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/.gitignore +++ /dev/null @@ -1,168 +0,0 @@ - -# Created by https://www.gitignore.io/api/osx,linux,python,windows - -### 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 - -### 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/ - -### 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 - - -# End of https://www.gitignore.io/api/osx,linux,python,windows \ No newline at end of file diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/LICENSE b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/LICENSE deleted file mode 100644 index 14aabc346a..0000000000 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/LICENSE +++ /dev/null @@ -1,14 +0,0 @@ -Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this -software and associated documentation files (the "Software"), to deal in the Software -without restriction, including without limitation the rights to use, copy, modify, -merge, publish, distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/README.md b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/README.md deleted file mode 100644 index 4f15d02ce8..0000000000 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Cookiecutter legacy NodeJS Hello-world for SAM based Serverless App - -A cookiecutter template to create a legacy NodeJS Hello world boilerplate using [Serverless Application Model (SAM)](https://github.com/awslabs/serverless-application-model). - -## Requirements - -* [AWS SAM CLI](https://github.com/awslabs/aws-sam-cli) - -## Usage - -Generate a boilerplate template in your current project directory using the following syntax: - -* **NodeJS 6**: `sam init --runtime nodejs6.10` - -> **NOTE**: ``--name`` allows you to specify a different project folder name (`sam-app` is the default) - -# Credits - -* This project has been generated with [Cookiecutter](https://github.com/audreyr/cookiecutter) diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/cookiecutter.json b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/cookiecutter.json deleted file mode 100644 index 14bfbdc74f..0000000000 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/cookiecutter.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "project_name": "Name of the project", - "runtime": "nodejs6.10" -} \ No newline at end of file diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/setup.cfg b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/setup.cfg deleted file mode 100644 index 6302b3a02b..0000000000 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[install] -prefix= \ No newline at end of file diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/.gitignore b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/.gitignore deleted file mode 100644 index eb1db5fbec..0000000000 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/.gitignore +++ /dev/null @@ -1,129 +0,0 @@ - -# Created by https://www.gitignore.io/api/osx,node,linux,windows - -### 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* - -# 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 - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Typescript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env - - -### 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 - -### 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 - - -# End of https://www.gitignore.io/api/osx,node,linux,windows \ No newline at end of file diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/README.md b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/README.md deleted file mode 100644 index 2bf44aa835..0000000000 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/README.md +++ /dev/null @@ -1,211 +0,0 @@ -# {{ cookiecutter.project_name }} - -This is a sample template for {{ cookiecutter.project_name }} - Below is a brief explanation of what we have generated for you: - -```bash -. -├── README.MD <-- This instructions file -├── event.json <-- API Gateway Proxy Integration event payload -├── hello-world <-- Source code for a lambda function -│ └── app.js <-- Lambda function code -│ └── package.json <-- NodeJS dependencies and scripts -│ └── app-deps.js <-- Lambda function code with dependencies (Bringing to the next level section) -│ └── tests <-- Unit tests -│ └── unit -│ └── test-handler.js -├── template.yaml <-- SAM template -``` - -## Requirements - -* AWS CLI already configured with Administrator permission -* [{{ cookiecutter.runtime }} installed](https://nodejs.org/en/download/releases/) -* [Docker installed](https://www.docker.com/community-edition) - -## Setup process - -### Local development - -**Invoking function locally using a local sample payload** - -```bash -sam local invoke HelloWorldFunction --event event.json -``` - -**Invoking function locally through local API Gateway** - -```bash -sam local start-api -``` - -If the previous command ran successfully you should now be able to hit the following local endpoint to invoke your function `http://localhost:3000/hello` - -**SAM CLI** is used to emulate both Lambda and API Gateway locally and uses our `template.yaml` to understand how to bootstrap this environment (runtime, where the source code is, etc.) - The following excerpt is what the CLI will read in order to initialize an API and its routes: - -```yaml -... -Events: - HelloWorld: - Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api - Properties: - Path: /hello - Method: get -``` - -## Packaging and deployment - -AWS Lambda NodeJS runtime requires a flat folder with all dependencies including the application. SAM will use `CodeUri` property to know where to look up for both application and dependencies: - -```yaml -... - HelloWorldFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: hello-world/ - ... -``` - -Firstly, we need a `S3 bucket` where we can upload our Lambda functions packaged as ZIP before we deploy anything - If you don't have a S3 bucket to store code artifacts then this is a good time to create one: - -```bash -aws s3 mb s3://BUCKET_NAME -``` - -Next, run the following command to package our Lambda function to S3: - -```bash -sam package \ - --output-template-file packaged.yaml \ - --s3-bucket REPLACE_THIS_WITH_YOUR_S3_BUCKET_NAME -``` - -Next, the following command will create a Cloudformation Stack and deploy your SAM resources. - -```bash -sam deploy \ - --template-file packaged.yaml \ - --stack-name {{ cookiecutter.project_name.lower().replace(' ', '-') }} \ - --capabilities CAPABILITY_IAM -``` - -> **See [Serverless Application Model (SAM) HOWTO Guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-quick-start.html) for more details in how to get started.** - -After deployment is complete you can run the following command to retrieve the API Gateway Endpoint URL: - -```bash -aws cloudformation describe-stacks \ - --stack-name {{ cookiecutter.project_name.lower().replace(' ', '-') }} \ - --query 'Stacks[].Outputs[?OutputKey==`HelloWorldApi`]' \ - --output table -``` - -## 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 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 -sam logs -n HelloWorldFunction --stack-name {{ cookiecutter.project_name.lower().replace(' ', '-') }} --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). - -## Testing - -We use `mocha` for testing our code and it is already added in `package.json` under `scripts`, so that we can simply run the following command to run our tests: - -```bash -cd hello-world -npm install -npm run test -``` - -## Cleanup - -In order to delete our Serverless Application recently deployed you can use the following AWS CLI Command: - -```bash -aws cloudformation delete-stack --stack-name {{ cookiecutter.project_name.lower().replace(' ', '-') }} -``` - -## Bringing to the next level - -Here are a few things you can try to get more acquainted with building serverless applications using SAM: - -### Learn how SAM Build can help you with dependencies - -* Delete `hello-world/app.js` -* Rename `hello-world/app-deps.js` to `hello-world/app.js` -* Build the project with ``sam build --use-container`` -* Invoke with ``sam local invoke HelloWorldFunction --event event.json`` -* Update tests - -### Create an additional API resource - -* Create a catch all resource (e.g. /hello/{proxy+}) and return the name requested through this new path -* Update tests - -### Step-through debugging - -* **[Enable step-through debugging docs for supported runtimes]((https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-using-debugging.html))** - -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/) - -# Appendix - -### Building the project - -[AWS Lambda requires a flat folder](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-create-deployment-pkg.html) with the application as well as its dependencies in a node_modules folder. When you make changes to your source code or dependency manifest, -run the following command to build your project local testing and deployment: - -```bash -sam build -``` - -If your dependencies contain native modules that need to be compiled specifically for the operating system running on AWS Lambda, use this command to build inside a Lambda-like Docker container instead: -```bash -sam build --use-container -``` - -By default, this command writes built artifacts to `.aws-sam/build` folder. - -## SAM and AWS CLI commands - -All commands used throughout this document - -```bash -# Generate event.json via generate-event command -sam local generate-event apigateway aws-proxy > event.json - -# Invoke function locally with event.json as an input -sam local invoke HelloWorldFunction --event event.json - -# Run API Gateway locally -sam local start-api - -# Create S3 bucket -aws s3 mb s3://BUCKET_NAME - -# Package Lambda function defined locally and upload to S3 as an artifact -sam package \ - --output-template-file packaged.yaml \ - --s3-bucket REPLACE_THIS_WITH_YOUR_S3_BUCKET_NAME - -# Deploy SAM template as a CloudFormation stack -sam deploy \ - --template-file packaged.yaml \ - --stack-name {{ cookiecutter.project_name.lower().replace(' ', '-') }} \ - --capabilities CAPABILITY_IAM - -# Describe Output section of CloudFormation stack previously created -aws cloudformation describe-stacks \ - --stack-name {{ cookiecutter.project_name.lower().replace(' ', '-') }} \ - --query 'Stacks[].Outputs[?OutputKey==`HelloWorldApi`]' \ - --output table - -# Tail Lambda function Logs using Logical name defined in SAM Template -sam logs -n HelloWorldFunction --stack-name {{ cookiecutter.project_name.lower().replace(' ', '-') }} --tail -``` - -**NOTE**: Alternatively this could be part of package.json scripts section. diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/event.json b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/event.json deleted file mode 100644 index 070ad8e018..0000000000 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/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/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/.npmignore b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/.npmignore deleted file mode 100644 index e7e1fb04f4..0000000000 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/.npmignore +++ /dev/null @@ -1 +0,0 @@ -tests/* diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/app-deps.js b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/app-deps.js deleted file mode 100644 index fb7470c3ae..0000000000 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/app-deps.js +++ /dev/null @@ -1,34 +0,0 @@ -var axios = require('axios') -var url = 'http://checkip.amazonaws.com/'; -var response; - - -/** - * - * 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 - * - */ -exports.lambdaHandler = function (event, context, callback) { - axios(url) - .then(function (ret) { - response = { - 'statusCode': 200, - 'body': JSON.stringify({ - message: 'hello world', - location: ret.data.trim() - }) - } - callback(null, response); - }) - .catch(function (err) { - console.log(err); - callback(err); - }); -}; diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/app.js b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/app.js deleted file mode 100644 index cae4cec9a5..0000000000 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/app.js +++ /dev/null @@ -1,23 +0,0 @@ - -/** - * - * 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 - * - */ -exports.lambdaHandler = function (event, context, callback) { - var response = { - statusCode: 200, - body: JSON.stringify({ - message: 'hello world' - }) - } - - callback(null, response); -}; diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/package.json b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/package.json deleted file mode 100644 index 80086fd6db..0000000000 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "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-legacy", - "author": "SAM CLI", - "license": "MIT", - "dependencies": { - "axios": "^0.18.0" - }, - "scripts": { - "test": "mocha tests/unit/" - }, - "devDependencies": { - "chai": "^4.1.2", - "mocha": "^5.1.1" - } -} diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/tests/unit/test-handler.js b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/tests/unit/test-handler.js deleted file mode 100644 index 19b617b9af..0000000000 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/hello-world/tests/unit/test-handler.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; - -const app = require('../../app.js'); -const chai = require('chai'); -const expect = chai.expect; -var event, context; - -describe('Tests Handler', function () { - it('verifies successful response', function (done) { - app.lambdaHandler(event, context, function (err, result) { - try { - 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"); - // expect(response.location).to.be.an("string"); - done(); - } catch (e) { - done(e); - } - }); - }); -}); diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/template.yaml b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/template.yaml deleted file mode 100644 index 861221a315..0000000000 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs6/{{cookiecutter.project_name}}/template.yaml +++ /dev/null @@ -1,39 +0,0 @@ -AWSTemplateFormatVersion: '2010-09-09' -Transform: AWS::Serverless-2016-10-31 -Description: > - {{ cookiecutter.project_name }} - - Sample SAM Template for {{ cookiecutter.project_name }} - -# 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: - CodeUri: hello-world/ - Handler: app.lambdaHandler - Runtime: {{ cookiecutter.runtime }} - Events: - HelloWorld: - Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api - Properties: - Path: /hello - Method: get - -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 - HelloWorldApi: - Description: "API Gateway endpoint URL for Prod stage for Hello World function" - Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/" - 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