For production
- AWS CLI configured with appropriate permissions,
e.g. allow the following in an IAM policy
lambda:*, iam:*, cloudformation:*, apigateway:*, s3:*
Production url: https://api.app.gitactivity.com
Path | Headers | Query params | Comment |
---|---|---|---|
/oauth/github/login |
- | - | Begin Github authentication sequence |
/oauth/github/login/callback |
- | code (required) |
Github authentication callback, will redirect to client if successfully accepted |
Start a local server (similar to API Gateway in production)
sam local start-api --port 8080 --env-vars env.example.json
If the previous command ran successfully you should now be able to hit the following
local endpoint to invoke your function http://localhost:8080/oauth/github/login/callback
Invoke a separate function locally using a sample event payload
sam local invoke --no-event OauthGithubAuthorizeFunction --env-vars env.example.json
See script deploy.sh
- Create a
S3 bucket
to store the packaged lambda functions:
aws s3 mb s3://BUCKET_NAME
- Package Lambda functions (uploads to S3):
sam package \
--output-template-file packaged.yaml \
--s3-bucket BUCKET_NAME
- Create Cloudformation Stack and deploy packaged resources.
sam deploy \
--template-file packaged.yaml \
--stack-name github-activity-server \
--capabilities CAPABILITY_IAM
After deployment is complete you can run the following command to retrieve the API Gateway Endpoint URL:
aws cloudformation describe-stacks \
--stack-name github-activity-server \
--query 'Stacks[].Outputs[?OutputKey==`ApiUrl`]' \
--output table
NOTE
: This command works for all AWS Lambda functions; not just the ones you deploy using SAM.
sam logs -n OauthGithubAuthorizeFunction --stack-name github-activity-server --tail
In order to delete the deployed Serverless Application you can use the following AWS CLI Command:
aws cloudformation delete-stack --stack-name github-activity-server