Skip to content

Commit c852fdb

Browse files
committed
Amend RESTAPI examples
1 parent bd3edcd commit c852fdb

File tree

15 files changed

+100
-401
lines changed

15 files changed

+100
-401
lines changed

apigw-rest-api-lambda-dotnet/README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Hello World AWS Lambda and Amazon API Gateway REST API
1+
# Hello World AWS Lambda and Amazon API Gateway REST API (.NET)
22

33
This project contains source code and supporting files for a serverless application that you can deploy with the AWS SAM CLI. It includes the following files and folders.
44

5-
- src/HelloWorld - Code for the application's Lambda function.
5+
- hello_world - Code for the application's Lambda function.
66
- events - Invocation events that you can use to invoke the function.
77
- template.yaml - A template that defines the application's AWS resources.
88

@@ -25,22 +25,21 @@ The AWS Toolkit is an open source plug-in for popular IDEs that uses the AWS SAM
2525

2626
## Deploy the sample application
2727

28-
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.
28+
The AWS Serverless Application Model Command Line Interface (AWS SAM CLI) is a framework 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.
2929

3030
To use the AWS SAM CLI, you need the following tools.
3131

3232
### Requirements
3333

3434
* AWS SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
35-
* .NET Core - [Install .NET Core](https://www.microsoft.com/net/download)
36-
* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community)
35+
* Docker - [Install Docker Desktop](https://hub.docker.com/search/?type=edition&offering=community)
3736

3837
To build and deploy your application for the first time, run the following in your shell:
3938

4039
```bash
41-
$ cd apigw-rest-api-lambda-dotnet
42-
$ sam build --use-container
43-
$ sam deploy --guided
40+
cd apigw-rest-api-lambda-dotnet
41+
sam build --use-container
42+
sam deploy --guided
4443
```
4544

4645
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:
@@ -50,30 +49,32 @@ The first command will build the source of your application. The second command
5049
* **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.
5150
* **HelloWorldFunction has no authentication. Is this okay? [y/N]:**: Select `y` for the purposes of this sample application. As a result, anyone will be able to call this example REST API without any form of authentication. For production applications, you should [enable authentication for the API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-control-access-to-api.html) using one of several available options and [follow the API Gateway security best practices](https://docs.aws.amazon.com/apigateway/latest/developerguide/security-best-practices.html). If `N` is selected for this question, this deployment will not succeed.
5251
* **Allow AWS 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.
53-
* **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.
52+
* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project.
53+
*
54+
For future deploys, you can run `sam deploy` without parameters to deploy changes to your application.
5455

55-
You can find your API Gateway Endpoint URL in the output values displayed after deployment.
56+
You can find your API Gateway endpoint URL in the output values displayed after deployment.
5657

57-
## Use the AWS SAM CLI to test locally
58+
## Use AWS SAM CLI to test locally
5859

59-
The SAM CLI installs dependencies defined in `src/HelloWorld.csproj`, creates a deployment package, and saves it in the `.aws-sam/build` folder.
60+
The AWS SAM CLI installs dependencies defined in `hello_world/package.json`, creates a deployment package, and saves it in the `.aws-sam/build` folder.
6061

61-
Ypu can 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.
62+
You can 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.
6263

6364
Run functions locally and invoke them with the `sam local invoke` command.
6465

6566
```bash
66-
$ sam local invoke HelloWorldFunction --event events/event.json
67+
sam local invoke HelloWorldFunction --event events/event.json
6768
```
6869

69-
The AWS SAM CLI can also emulate your application's API. Use the `sam local start-api` to run the API locally on port 3000.
70+
AWS SAM CLI can also emulate your application's API. Use the `sam local start-api` to run the API locally on port 3000.
7071

7172
```bash
72-
$ sam local start-api
73-
$ curl http://localhost:3000/
73+
sam local start-api
74+
curl http://localhost:3000/
7475
```
7576

76-
The AWS SAM CLI reads the application template to determine the API's routes and the functions they invoke. The `Events` property on each function's definition includes the route and method for each path.
77+
AWS SAM CLI reads the application template to determine the API's routes and the functions they invoke. The `Events` property on each function's definition includes the route and method for each path.
7778

7879
```yaml
7980
Events:
@@ -84,13 +85,13 @@ The AWS SAM CLI reads the application template to determine the API's routes and
8485
Method: get
8586
```
8687
87-
## Use the AWS SAM CLI to test remotely
88+
## Use AWS SAM CLI to test remotely
8889
After you have deployed your application, you can remotely invoke your Lambda function to test it in the cloud.
8990
9091
Invoke functions remotely with the `sam remote invoke` command.
9192

9293
```bash
93-
$ sam remote invoke HelloWorldFunction --event-file events/event.json
94+
sam remote invoke HelloWorldFunction --event-file events/event.json
9495
```
9596

9697
You can also go to the API Gateway endpoint URL that was output after the deployment of your application, which will similarly invoke your deployed Lambda function.
@@ -101,12 +102,11 @@ To simplify troubleshooting, AWS SAM CLI has a command called `sam logs`. `sam l
101102
`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using AWS SAM.
102103

103104
```bash
104-
$ sam logs -n HelloWorldFunction --stack-name "YOUR_STACK_NAME_HERE" --tail
105+
sam logs -n HelloWorldFunction --stack-name "YOUR_STACK_NAME_HERE" --tail
105106
```
106107

107108
You can find more information and examples about filtering Lambda function logs in the [AWS SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html).
108109

109-
110110
## Cleanup
111111

112112
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:
@@ -117,4 +117,4 @@ $ sam delete
117117

118118
## Resources
119119

120-
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.
120+
See the [AWS SAM developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) for an introduction to AWS SAM specification, the AWS SAM CLI, and serverless application concepts.

apigw-rest-api-lambda-dotnet/apigw-rest-api-lambda-dotnet.json

Lines changed: 0 additions & 76 deletions
This file was deleted.

apigw-rest-api-lambda-dotnet/example-pattern.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"title": "Hello World AWS Lambda and Amazon API Gateway REST API",
3-
"description": "Create a simple Lambda Function connected to a REST API.",
3+
"description": "Create a simple Lambda function connected to a REST API.",
44
"language": ".NET",
55
"level": "200",
66
"framework": "SAM",
77
"introBox": {
88
"headline": "How it works",
99
"text": [
10-
"This sample project demonstrates how to trigger a simple Lambda function using a REST API.",
11-
"This pattern deploys one Lambda Function, andn one API Gateway REST API."
10+
"This sample project shows how to trigger a simple Lambda function using a REST API.",
11+
"This pattern deploys one Lambda function and one API Gateway REST API."
1212
]
1313
},
1414
"gitHub": {
@@ -22,7 +22,7 @@
2222
"resources": {
2323
"bullets": [
2424
{
25-
"text": "Trigger Lambda with a REST API",
25+
"text": "Invoking a Lambda function using an Amazon API Gateway endpoint",
2626
"link": "https://docs.aws.amazon.com/lambda/latest/dg/services-apigateway.html"
2727
},
2828
{

apigw-rest-api-lambda-dotnet/template.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
AWSTemplateFormatVersion: '2010-09-09'
22
Transform: AWS::Serverless-2016-10-31
33
Description: >
4-
Sample SAM Template for REST API Lambda Hello World
4+
Hello World AWS Lambda and Amazon API Gateway REST API
5+
6+
Sample AWS SAM template to create a simple Lambda function connected to a REST API.
57
68
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
79
Globals:

0 commit comments

Comments
 (0)