Skip to content

Dasmicrobot/github-activity-server

Repository files navigation

github-activity-server

Tests Deploy to AWS API Gateway GitHub issues GitHub last commit

Requirements

For production

  • AWS CLI configured with appropriate permissions, e.g. allow the following in an IAM policy lambda:*, iam:*, cloudformation:*, apigateway:*, s3:*

API

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

Local development

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

Packaging and deployment

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

Fetch, tail, and filter Lambda function logs

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

Cleanup

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

Releases

No releases published

Packages

No packages published