Skip to content

Commit 650e54b

Browse files
committed
Added README to spring boot sample to address #127.
1 parent 8c4a437 commit 650e54b

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Serverless Spring Boot example
2+
A basic pet store written with the [Spring Boot framework](https://projects.spring.io/spring-boot/). The `LambdaHandler` object is the main entry point for Lambda.
3+
4+
The application can be deployed in an AWS account using the [Serverless Application Model](https://github.com/awslabs/serverless-application-model). The `sam.yaml` file in the root folder contains the application definition
5+
6+
## Installation
7+
To build and install the sample application you will need [Maven](https://maven.apache.org/) and the [AWS CLI](https://aws.amazon.com/cli/) installed on your computer.
8+
9+
In a shell, navigate to the sample's folder and use maven to build a deployable jar.
10+
```
11+
$ mvn package
12+
```
13+
14+
This command should generate a `serverless-spring-boot-example-1.0-SNAPSHOT.jar` in the `target` folder. Now that we have generated the jar file, we can use the AWS CLI to package the template for deployment.
15+
16+
You will need an S3 bucket to store the artifacts for deployment. Once you have created the S3 bucket, run the following command from the sample's folder:
17+
18+
```
19+
$ aws cloudformation package --template-file sam.yaml --output-template-file output-sam.yaml --s3-bucket <YOUR S3 BUCKET NAME>
20+
Uploading to xxxxxxxxxxxxxxxxxxxxxxxxxx 6464692 / 6464692.0 (100.00%)
21+
Successfully packaged artifacts and wrote output template to file output-sam.yaml.
22+
Execute the following command to deploy the packaged template
23+
aws cloudformation deploy --template-file /your/path/output-sam.yaml --stack-name <YOUR STACK NAME>
24+
```
25+
26+
As the command output suggests, you can now use the cli to deploy the application. Choose a stack name and run the `aws cloudformation deploy` command from the output of the package command.
27+
28+
```
29+
$ aws cloudformation deploy --template-file output-sam.yaml --stack-name ServerlessSpringBootSample --capabilities CAPABILITY_IAM
30+
```
31+
32+
Once the application is deployed, you can describe the stack to show the API endpoint that was created. The endpoint should be the `SpringBootPetStoreApi` key of the `Outputs` property:
33+
34+
```
35+
$ aws cloudformation describe-stacks --stack-name ServerlessSpringBootSample
36+
{
37+
"Stacks": [
38+
{
39+
"StackId": "arn:aws:cloudformation:us-west-2:xxxxxxxx:stack/JerseySample/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx",
40+
"Description": "Example Pet Store API written with spark with the aws-serverless-java-container library",
41+
"Tags": [],
42+
"Outputs": [
43+
{
44+
"Description": "URL for application",
45+
"OutputKey": "SpringBootPetStoreApi",
46+
"OutputValue": "https://xxxxxxx.execute-api.us-west-2.amazonaws.com/Prod/pets"
47+
}
48+
],
49+
"CreationTime": "2016-12-13T22:59:31.552Z",
50+
"Capabilities": [
51+
"CAPABILITY_IAM"
52+
],
53+
"StackName": "JerseySample",
54+
"NotificationARNs": [],
55+
"StackStatus": "UPDATE_COMPLETE"
56+
}
57+
]
58+
}
59+
60+
```
61+
62+
Copy the `OutputValue` into a browser to test a first request.

0 commit comments

Comments
 (0)