- AWS CLI already configured with Administrator permission
- NodeJS 10.10+ installed
- Docker installed
Invoking function locally using a local sample payload
sam local invoke --no-event OauthGithubAuthorizeFunction --parameter-overrides ParameterKey=GithubClientId,ParameterValue=foobar
Invoking function locally through local API Gateway
sam local start-api --parameter-overrides 'ParameterKey=GithubClientId,ParameterValue=XXXXXXX ParameterKey=GithubClientSecret,ParameterValue=XXXXXXX ParameterKey=GithubOatuhCallbackUrl,ParameterValue=http://127.0.0.1:8080/callback.html'
If the previous command ran successfully you should now be able to hit the following local endpoint to invoke your function http://localhost:3000/$FunctionPath
Create S3 bucket
:
aws s3 mb s3://BUCKET_NAME
Package Lambda (uploads to S3):
sam package \
--output-template-file packaged.yaml \
--s3-bucket BUCKET_NAME
Create Cloudformation Stack and deploy your SAM 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 our Serverless Application recently deployed you can use the following AWS CLI Command:
aws cloudformation delete-stack --stack-name github-activity-server