update readme and ready for review
This commit is contained in:
parent
b2dd36f607
commit
b2607010b4
@ -14,6 +14,26 @@ tags:
|
|||||||
Serverless eliminates the need to plan for infrastructure and let's you focus on your
|
Serverless eliminates the need to plan for infrastructure and let's you focus on your
|
||||||
application.
|
application.
|
||||||
|
|
||||||
|
Following are optimization katas you should be aware of while building a serverless
|
||||||
|
applications
|
||||||
|
|
||||||
|
* The Lean function
|
||||||
|
* Concise logic
|
||||||
|
* Efficient/single purpose code
|
||||||
|
* ephemeral environment
|
||||||
|
* Eventful Invocations
|
||||||
|
* Succinct payloads
|
||||||
|
* resilient routing
|
||||||
|
* concurrent execution
|
||||||
|
* Coordinated calls
|
||||||
|
* Decoupled via APIs
|
||||||
|
* scale-matched downstream
|
||||||
|
* secured
|
||||||
|
* Serviceful operations
|
||||||
|
* Automated operations
|
||||||
|
* monitored applications
|
||||||
|
* Innovation mindset
|
||||||
|
|
||||||
## Intent
|
## Intent
|
||||||
|
|
||||||
Whether to reduce your infrastructure costs, shrink the time you spend on ops tasks,
|
Whether to reduce your infrastructure costs, shrink the time you spend on ops tasks,
|
||||||
@ -58,6 +78,10 @@ an Event. Most of the Serverless Cloud Providers support following Events
|
|||||||
AWS supports processing event generated from AWS Services (S3/Cloudwatch/etc) and
|
AWS supports processing event generated from AWS Services (S3/Cloudwatch/etc) and
|
||||||
using aws as a compute engine is our first choice.
|
using aws as a compute engine is our first choice.
|
||||||
|
|
||||||
|
## (Backend as a Service or "BaaS")
|
||||||
|
This example creates a backend for ‘persons’ collection which uses DynamoDB NoSQL
|
||||||
|
database service also provided by Amazon.
|
||||||
|
|
||||||
## AWS lambda function implementation
|
## AWS lambda function implementation
|
||||||
|
|
||||||
AWS lambda SDK provides pre-defined interface `com.amazonaws.services.lambda.runtime
|
AWS lambda SDK provides pre-defined interface `com.amazonaws.services.lambda.runtime
|
||||||
@ -97,16 +121,23 @@ dependencies of the function.
|
|||||||
* `mvn clean package`
|
* `mvn clean package`
|
||||||
* `serverless deploy --stage=dev --verbose`
|
* `serverless deploy --stage=dev --verbose`
|
||||||
|
|
||||||
Based on the configuration in `serverless.yml` serverless framework creates a
|
Based on the configuration in `serverless.yml` serverless framework creates following
|
||||||
cloud formation stack for S3 (ServerlessDeploymentBucket), IAM Role
|
resources
|
||||||
(IamRoleLambdaExecution), cloud watch (log groups), API Gateway (ApiGatewayRestApi)
|
* cloud formation stack for S3 (ServerlessDeploymentBucket)
|
||||||
and the Lambda function.
|
* IAM Role (IamRoleLambdaExecution)
|
||||||
|
* cloud watch (log groups)
|
||||||
|
* API Gateway (ApiGatewayRestApi)
|
||||||
|
* Lambda function
|
||||||
|
* DynamoDB collection
|
||||||
|
|
||||||
The command will print out Stack Outputs which looks something like this
|
The command will print out Stack Outputs which looks something like this
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
endpoints:
|
endpoints:
|
||||||
GET - https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/info
|
GET - https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/info
|
||||||
|
POST - https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/api/person
|
||||||
|
GET - https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/api/person/{id}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@ -116,6 +147,38 @@ ServerlessDeploymentBucketName: lambda-info-http-endpoin-serverlessdeploymentbuc
|
|||||||
```
|
```
|
||||||
access the endpoint to invoke the function.
|
access the endpoint to invoke the function.
|
||||||
|
|
||||||
|
Use the following cURL commands to test the endpoints
|
||||||
|
|
||||||
|
```cURL
|
||||||
|
curl -X GET \
|
||||||
|
https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/info \
|
||||||
|
-H 'cache-control: no-cache'
|
||||||
|
```
|
||||||
|
|
||||||
|
```cURL
|
||||||
|
curl -X POST \
|
||||||
|
https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/api/person \
|
||||||
|
-H 'cache-control: no-cache' \
|
||||||
|
-H 'content-type: application/json' \
|
||||||
|
-d '{
|
||||||
|
"firstName": "Thor",
|
||||||
|
"lastName": "Odinson",
|
||||||
|
"address": {
|
||||||
|
"addressLineOne": "1 Odin ln",
|
||||||
|
"addressLineTwo": "100",
|
||||||
|
"city": "Asgard",
|
||||||
|
"state": "country of the Gods",
|
||||||
|
"zipCode": "00001"
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
```cURL
|
||||||
|
curl -X GET \
|
||||||
|
https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/api/person/{id} \
|
||||||
|
-H 'cache-control: no-cache'
|
||||||
|
```
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
* [serverless docs](https://serverless.com/framework/docs/)
|
* [serverless docs](https://serverless.com/framework/docs/)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user