- First
- Create a new service
$ serverless create --template aws-nodejs --path my-service
- Deploy
- Getting your AWS credentials using OKTA CLI
~/.okta/awscli sts get-caller-identity
serverless deploy --aws-profile okta-rnd-team_524621635179
- Second
- Lambda
- Trigger Events
- S3 bucket upload
- an SNS topic
- HTTP endpoints created via API Gateway
- ...
- Invoke Lambda Function Locally
- Trigger Events
- Lambda
serverless invoke local --function hello
- API Gateway 1. Add Trigger Event
events:
- http:
path: index
method: get
How to lauch serverless locally
serverless offline
- DynamoDB
- AWS Resources Anything that can be defined in CloudFormation is supported by the Serverless Framework
- Launch DynamoDB Locally
var putParams = {
TableName: 'testTable',
Item: {
userId: 'Lucy.Tu'
}
};
docClient.put(putParams, function(err, data) {
if (err) {
console.log('===err', err);
}
else {
console.log('successfully!');
}
});
How to Start and Remove Dynamodb Locally
In CLI:
Start: sls dynamodb start
Remove: sls dynamodb remove
In Your JS File:
new AWS.DynamoDB.DocumentClient({
region: 'localhost',
endpoint: 'http://localhost:8000'
})
- The way of deployment
- Packaging service
- Excluding development dependencies
- Creating Stack
- Checking Stack create progress
- Uploading CloudFormation file to S3
- Uploading artifacts
- Uploading service serverless-nodejs.zip file to S3
- Validating template
- Updating Stack