Skip to content

Commit 011ceef

Browse files
committed
fixed typos, added author
1 parent 1559702 commit 011ceef

File tree

2 files changed

+45
-44
lines changed

2 files changed

+45
-44
lines changed
Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Hello World AWS Lambda and Amazon API Gateway REST API
22

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.
3+
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-
- HelloWorldFunction/src/main - 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

9-
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.
9+
The application uses several AWS resources. 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. This application will deploy a Lambda function, as well as an API Gateway REST API that will be automatically created based on the Lambda function's Event mapping.
1010

1111
If you prefer to use an integrated development environment (IDE) to build and test your application, you can use the AWS Toolkit.
12-
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.
12+
The AWS Toolkit is an open source plug-in for popular IDEs that uses the AWS 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.
1313

1414
* [CLion](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
1515
* [GoLand](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
@@ -27,56 +27,53 @@ The AWS Toolkit is an open source plug-in for popular IDEs that uses the SAM CLI
2727

2828
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.
2929

30-
To use the SAM CLI, you need the following tools.
30+
To use the AWS SAM CLI, you need the following tools.
3131

32-
* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
32+
### Requirements
33+
34+
* AWS SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
3335
* java21 - [Install the Java 21](https://docs.aws.amazon.com/corretto/latest/corretto-21-ug/downloads-list.html)
34-
* Maven - [Install Maven](https://maven.apache.org/install.html)
3536
* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community)
3637

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

3940
```bash
40-
sam build
41-
sam deploy --guided
41+
$ cd apigw-rest-api-lambda-python
42+
$ sam build --use-container
43+
$ sam deploy --guided
4244
```
4345

4446
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:
4547

4648
* **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.
4749
* **AWS Region**: The AWS region you want to deploy your app to.
4850
* **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.
51+
* **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.
52+
* **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.
5053
* **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.
5154

5255
You can find your API Gateway Endpoint URL in the output values displayed after deployment.
5356

54-
## Use the SAM CLI to build and test locally
55-
56-
Build your application with the `sam build` command.
57-
58-
```bash
59-
$ sam build
60-
```
57+
## Use the AWS SAM CLI to test locally
6158

62-
The SAM CLI installs dependencies defined in `HelloWorldFunction/pom.xml`, creates a deployment package, and saves it in the `.aws-sam/build` folder.
59+
The SAM CLI installs dependencies defined in `hello_world/package.json`, creates a deployment package, and saves it in the `.aws-sam/build` folder.
6360

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.
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.
6562

6663
Run functions locally and invoke them with the `sam local invoke` command.
6764

6865
```bash
6966
$ sam local invoke HelloWorldFunction --event events/event.json
7067
```
7168

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.
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.
7370

7471
```bash
7572
$ sam local start-api
7673
$ curl http://localhost:3000/
7774
```
7875

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.
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.
8077

8178
```yaml
8279
Events:
@@ -87,32 +84,37 @@ The SAM CLI reads the application template to determine the API's routes and the
8784
Method: get
8885
```
8986
90-
## Add a resource to your application
91-
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.
87+
## Use the AWS SAM CLI to test remotely
88+
After you have deployed your application, you can remotely invoke your Lambda function to test it in the cloud.
9289
93-
## Fetch, tail, and filter Lambda function logs
90+
Invoke functions remotely with the `sam remote invoke` command.
9491

95-
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.
92+
```bash
93+
$ sam remote invoke HelloWorldFunction --event-file events/event.json
94+
```
95+
96+
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.
9697

97-
`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM.
98+
## Fetch, tail, and filter Lambda function logs
99+
To simplify troubleshooting, AWS 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.
100+
101+
`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using AWS SAM.
98102

99103
```bash
100-
$ sam logs -n HelloWorldFunction --stack-name YOUR_STACK_NAME --tail
104+
$ sam logs -n HelloWorldFunction --stack-name "YOUR_STACK_NAME_HERE" --tail
101105
```
102106

103-
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).
107+
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).
104108

105109

106110
## Cleanup
107111

108112
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:
109113

110114
```bash
111-
sam delete --stack-name YOUR_STACK_NAME
115+
$ sam delete
112116
```
113117

114118
## Resources
115119

116-
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.
117-
118-
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/)
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.

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
},
1414
"gitHub": {
1515
"template": {
16-
"repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/apig-rest-api-lambda-java",
17-
"templateURL": "serverless-patterns/apig-rest-api-lambda-java",
18-
"projectFolder": "apig-rest-api-lambda-java",
16+
"repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/apigw-rest-api-lambda-java",
17+
"templateURL": "serverless-patterns/apigw-rest-api-lambda-java",
18+
"projectFolder": "apigw-rest-api-lambda-java",
1919
"templateFile": "template.yaml"
2020
}
2121
},
@@ -47,12 +47,11 @@
4747
]
4848
},
4949
"authors": [
50-
{
51-
"name": "Your name",
52-
"image": "link-to-your-photo.jpg",
53-
"bio": "Your bio.",
54-
"linkedin": "linked-in-ID",
55-
"twitter": "twitter-handle"
56-
}
57-
]
58-
}
50+
{
51+
"name": "Seshu Brahma",
52+
"image": "https://i.postimg.cc/ZR0MyrTN/seshub-photo.jpg",
53+
"bio": "SDE II, Lambda, AWS",
54+
"linkedin": "seshu-brahma"
55+
}
56+
]
57+
}

0 commit comments

Comments
 (0)