Skip to content

Commit c057b47

Browse files
committed
test
1 parent fc84f73 commit c057b47

File tree

11 files changed

+585
-0
lines changed

11 files changed

+585
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# AWS Extensions for Visual Studio Code
22
dumb change
33

4+
somthing else
5+
46
[![Coverage](https://img.shields.io/codecov/c/github/aws/aws-toolkit-vscode/master.svg)](https://codecov.io/gh/aws/aws-toolkit-vscode/branch/master)
57

68
This project is open source. We encourage issues, feature requests, code reviews, pull requests or

lambda-nodejs16.x/.gitignore

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
2+
# Created by https://www.toptal.com/developers/gitignore/api/osx,node,linux,windows,sam
3+
# Edit at https://www.toptal.com/developers/gitignore?templates=osx,node,linux,windows,sam
4+
5+
### Linux ###
6+
*~
7+
8+
# temporary files which can be created if a process still has a handle open of a deleted file
9+
.fuse_hidden*
10+
11+
# KDE directory preferences
12+
.directory
13+
14+
# Linux trash folder which might appear on any partition or disk
15+
.Trash-*
16+
17+
# .nfs files are created when an open file is removed but is still being accessed
18+
.nfs*
19+
20+
### Node ###
21+
# Logs
22+
logs
23+
*.log
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
lerna-debug.log*
28+
29+
# Diagnostic reports (https://nodejs.org/api/report.html)
30+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
31+
32+
# Runtime data
33+
pids
34+
*.pid
35+
*.seed
36+
*.pid.lock
37+
38+
# Directory for instrumented libs generated by jscoverage/JSCover
39+
lib-cov
40+
41+
# Coverage directory used by tools like istanbul
42+
coverage
43+
*.lcov
44+
45+
# nyc test coverage
46+
.nyc_output
47+
48+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
49+
.grunt
50+
51+
# Bower dependency directory (https://bower.io/)
52+
bower_components
53+
54+
# node-waf configuration
55+
.lock-wscript
56+
57+
# Compiled binary addons (https://nodejs.org/api/addons.html)
58+
build/Release
59+
60+
# Dependency directories
61+
node_modules/
62+
jspm_packages/
63+
64+
# TypeScript v1 declaration files
65+
typings/
66+
67+
# TypeScript cache
68+
*.tsbuildinfo
69+
70+
# Optional npm cache directory
71+
.npm
72+
73+
# Optional eslint cache
74+
.eslintcache
75+
76+
# Optional stylelint cache
77+
.stylelintcache
78+
79+
# Microbundle cache
80+
.rpt2_cache/
81+
.rts2_cache_cjs/
82+
.rts2_cache_es/
83+
.rts2_cache_umd/
84+
85+
# Optional REPL history
86+
.node_repl_history
87+
88+
# Output of 'npm pack'
89+
*.tgz
90+
91+
# Yarn Integrity file
92+
.yarn-integrity
93+
94+
# dotenv environment variables file
95+
.env
96+
.env.test
97+
.env*.local
98+
99+
# parcel-bundler cache (https://parceljs.org/)
100+
.cache
101+
.parcel-cache
102+
103+
# Next.js build output
104+
.next
105+
106+
# Nuxt.js build / generate output
107+
.nuxt
108+
dist
109+
110+
# Storybook build outputs
111+
.out
112+
.storybook-out
113+
storybook-static
114+
115+
# rollup.js default build output
116+
dist/
117+
118+
# Gatsby files
119+
.cache/
120+
# Comment in the public line in if your project uses Gatsby and not Next.js
121+
# https://nextjs.org/blog/next-9-1#public-directory-support
122+
# public
123+
124+
# vuepress build output
125+
.vuepress/dist
126+
127+
# Serverless directories
128+
.serverless/
129+
130+
# FuseBox cache
131+
.fusebox/
132+
133+
# DynamoDB Local files
134+
.dynamodb/
135+
136+
# TernJS port file
137+
.tern-port
138+
139+
# Stores VSCode versions used for testing VSCode extensions
140+
.vscode-test
141+
142+
# Temporary folders
143+
tmp/
144+
temp/
145+
146+
### OSX ###
147+
# General
148+
.DS_Store
149+
.AppleDouble
150+
.LSOverride
151+
152+
# Icon must end with two \r
153+
Icon
154+
155+
# Thumbnails
156+
._*
157+
158+
# Files that might appear in the root of a volume
159+
.DocumentRevisions-V100
160+
.fseventsd
161+
.Spotlight-V100
162+
.TemporaryItems
163+
.Trashes
164+
.VolumeIcon.icns
165+
.com.apple.timemachine.donotpresent
166+
167+
# Directories potentially created on remote AFP share
168+
.AppleDB
169+
.AppleDesktop
170+
Network Trash Folder
171+
Temporary Items
172+
.apdisk
173+
174+
### SAM ###
175+
# Ignore build directories for the AWS Serverless Application Model (SAM)
176+
# Info: https://aws.amazon.com/serverless/sam/
177+
# Docs: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-reference.html
178+
179+
**/.aws-sam
180+
181+
### Windows ###
182+
# Windows thumbnail cache files
183+
Thumbs.db
184+
Thumbs.db:encryptable
185+
ehthumbs.db
186+
ehthumbs_vista.db
187+
188+
# Dump file
189+
*.stackdump
190+
191+
# Folder config file
192+
[Dd]esktop.ini
193+
194+
# Recycle Bin used on file shares
195+
$RECYCLE.BIN/
196+
197+
# Windows Installer files
198+
*.cab
199+
*.msi
200+
*.msix
201+
*.msm
202+
*.msp
203+
204+
# Windows shortcuts
205+
*.lnk
206+
207+
# End of https://www.toptal.com/developers/gitignore/api/osx,node,linux,windows,sam
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Developing AWS SAM Applications with the AWS Toolkit For Visual Studio Code
2+
3+
This project contains source code and supporting files for a serverless application that you can locally run, debug, and deploy to AWS with the AWS Toolkit For Visual Studio Code.
4+
5+
A "SAM" (serverless application model) project is a project that contains a template.yaml file which is understood by AWS tooling (such as SAM CLI, and the AWS Toolkit For Visual Studio Code).
6+
7+
## Writing and Debugging Serverless Applications
8+
9+
The code for this application will differ based on the runtime, but the path to a handler can be found in the [`template.yaml`](./template.yaml) file through a resource's `CodeUri` and `Handler` fields.
10+
11+
AWS Toolkit For Visual Studio Code supports local debugging for serverless applications through VS Code's debugger. Since this application was created by the AWS Toolkit, launch configurations for all included handlers have been generated and can be found in the menu next to the Run button:
12+
13+
- lambda-nodejs16.x:HelloWorldFunction (nodejs16.x)
14+
- API lambda-nodejs16.x:HelloWorldFunction (nodejs16.x)
15+
16+
You can debug the Lambda handlers locally by adding a breakpoint to the source file, then running the launch configuration. This works by using Docker on your local machine.
17+
18+
Invocation parameters, including payloads and request parameters, can be edited either by the `Edit SAM Debug Configuration` command (through the Command Palette or CodeLens) or by editing the `launch.json` file.
19+
20+
AWS Lambda functions not defined in the [`template.yaml`](./template.yaml) file can be invoked and debugged by creating a launch configuration through the CodeLens over the function declaration, or with the `Add SAM Debug Configuration` command.
21+
22+
## Deploying Serverless Applications
23+
24+
You can deploy a serverless application by invoking the `AWS: Deploy SAM application` command through the Command Palette or by right-clicking the Lambda node in the AWS Explorer and entering the deployment region, a valid S3 bucket from the region, and the name of a CloudFormation stack to deploy to. You can monitor your deployment's progress through the `AWS Toolkit` Output Channel.
25+
26+
## Interacting With Deployed Serverless Applications
27+
28+
A successfully-deployed serverless application can be found in the AWS Explorer under region and CloudFormation node that the serverless application was deployed to.
29+
30+
In the AWS Explorer, you can invoke _remote_ AWS Lambda Functions by right-clicking the Lambda node and selecting "Invoke on AWS".
31+
32+
Similarly, if the Function declaration contained an API Gateway event, the API Gateway API can be found in the API Gateway node under the region node the serverless application was deployed to, and can be invoked via right-clicking the API node and selecting "Invoke on AWS".
33+
34+
## Resources
35+
36+
General information about this SAM project can be found in the [`README.md`](./README.md) file in this folder.
37+
38+
More information about using the AWS Toolkit For Visual Studio Code with serverless applications can be found [in the AWS documentation](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/serverless-apps.html) .

lambda-nodejs16.x/README.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# lambda-nodejs16.x
2+
3+
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.
4+
5+
- hello-world - Code for the application's Lambda function.
6+
- events - Invocation events that you can use to invoke the function.
7+
- hello-world/tests - Unit tests for the application code.
8+
- template.yaml - A template that defines the application's AWS resources.
9+
10+
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.
11+
12+
If you prefer to use an integrated development environment (IDE) to build and test your application, you can use the AWS Toolkit.
13+
The AWS Toolkit is an open source plug-in for popular IDEs that uses the SAM CLI to build and deploy serverless applications on AWS. The AWS Toolkit also adds a simplified step-through debugging experience for Lambda function code. See the following links to get started.
14+
15+
- [CLion](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
16+
- [GoLand](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
17+
- [IntelliJ](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
18+
- [WebStorm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
19+
- [Rider](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
20+
- [PhpStorm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
21+
- [PyCharm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
22+
- [RubyMine](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
23+
- [DataGrip](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
24+
- [VS Code](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/welcome.html)
25+
- [Visual Studio](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/welcome.html)
26+
27+
## Deploy the sample application
28+
29+
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.
30+
31+
To use the SAM CLI, you need the following tools.
32+
33+
- SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
34+
- Node.js - [Install Node.js 16](https://nodejs.org/en/), including the NPM package management tool.
35+
- Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community)
36+
37+
To build and deploy your application for the first time, run the following in your shell:
38+
39+
```bash
40+
sam build
41+
sam deploy --guided
42+
```
43+
44+
The first command will build the source of your application. The second command will package and deploy your application to AWS, with a series of prompts:
45+
46+
- **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.
47+
- **AWS Region**: The AWS region you want to deploy your app to.
48+
- **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.
49+
- **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.
50+
- **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.
51+
52+
You can find your API Gateway Endpoint URL in the output values displayed after deployment.
53+
54+
## Use the SAM CLI to build and test locally
55+
56+
Build your application with the `sam build` command.
57+
58+
```bash
59+
lambda-nodejs16.x$ sam build
60+
```
61+
62+
The SAM CLI installs dependencies defined in `hello-world/package.json`, creates a deployment package, and saves it in the `.aws-sam/build` folder.
63+
64+
Test a single function by invoking it directly with a test event. An event is a JSON document that represents the input that the function receives from the event source. Test events are included in the `events` folder in this project.
65+
66+
Run functions locally and invoke them with the `sam local invoke` command.
67+
68+
```bash
69+
lambda-nodejs16.x$ sam local invoke HelloWorldFunction --event events/event.json
70+
```
71+
72+
The SAM CLI can also emulate your application's API. Use the `sam local start-api` to run the API locally on port 3000.
73+
74+
```bash
75+
lambda-nodejs16.x$ sam local start-api
76+
lambda-nodejs16.x$ curl http://localhost:3000/
77+
```
78+
79+
The SAM CLI reads the application template to determine the API's routes and the functions that they invoke. The `Events` property on each function's definition includes the route and method for each path.
80+
81+
```yaml
82+
Events:
83+
HelloWorld:
84+
Type: Api
85+
Properties:
86+
Path: /hello
87+
Method: get
88+
```
89+
90+
## Add a resource to your application
91+
92+
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.
93+
94+
## Fetch, tail, and filter Lambda function logs
95+
96+
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.
97+
98+
`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM.
99+
100+
```bash
101+
lambda-nodejs16.x$ sam logs -n HelloWorldFunction --stack-name lambda-nodejs16.x --tail
102+
```
103+
104+
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).
105+
106+
## Unit tests
107+
108+
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.
109+
110+
```bash
111+
lambda-nodejs16.x$ cd hello-world
112+
hello-world$ npm install
113+
hello-world$ npm run test
114+
```
115+
116+
## Cleanup
117+
118+
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:
119+
120+
```bash
121+
sam delete --stack-name lambda-nodejs16.x
122+
```
123+
124+
## Resources
125+
126+
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.
127+
128+
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/)

0 commit comments

Comments
 (0)