An AWS API deployed with Serverless CLI
- Install Serverless CLI:
npm i -g serverless
- Configure Serverless:
serverless
- Optionally set up a Serverless account
- Configure your AWS credentials
serverless config credentials --provider aws --key <aws_access_key> --secret <aws_access_key_secret>
- Basic invoke
serverless invoke local --function <function_name>
- Invoke with data
serverless invoke local --function <function_name> --path data.json
- Create the custom domain:
serverless create_domain --stage <stage_name> --profile <your_profile> --domainName <your_domain>
- Package your code:
serverless package --stage <stage_name> --profile <your_profile> --domainName <your_domain>
- Deploy your package:
serverless deploy --stage <stage_name> --profile <your_profile> --domainName <your_domain>
- Test your endpoint:
curl https://<your_custom_domain>/demo/hello
curl https://<your_custom_domain>/demo/hello?name=<name>
- Tear down custom domain:
serverless delete_domain --stage <stage_name> --profile <your_profile> --domainName <your_domain>
- Teardown Serverless resources
serverless remove --stage <stage_name> --profile <your_profile> --domainName <your_domain>
In order to get more detailed logs when running Serverless commands export SLS_DEBUG=*
environment variable