MatteoIorio11 / ghapp-deployer-aws

Automatic creation of a Lambda Function using two different technologies: aws cli and aws sam. With the aws sam I also support the decryption of the env variables using AWS KMS
ISC License
2 stars 1 forks source link
aws aws-lambda aws-sam cloudformation github-actions lambda serverless

ghapp-deployer-aws

Deployer of Probot app on AWS Lambda using AWS Sam


How does it work?

This repository uses a template.yml for the creation of the Lambda. Every env variables is set during the deploy of the Lambda. This Function has already configured the API-Trigger, so in order to attach the Function to your app just copy the API-Endpoint inside your webhook URL.

It requires APP_ID, PRIVATE_KEY and WEBHOOK_SECRET crypted inside the environment, crypted with KMS. This function automatically decrypt this variables and the create the probot in order to handle the event.


Build and Deploy the function locally

Build the function:

  sam build

Set up the env

Deploy the function:

  sam deploy --stack-name NAME-OF-THE-STACK \
  --on-failure DELETE \
  --s3-bucket YOUR-S3-BUCKET \
  #?? OPTIONAL --tags map-migrated=d-server-01068mdjl5jze3 ?? \
  --no-confirm-changeset \
  --parameter-overrides 'awsRole="ROLE-FOR-THE-FUNCTION" \
  functionName="YOUR-LAMBDA-FUNCTION-NAME" \
  secretId="YOUR-PREDEFINED-AWS-SECRET-ID"\
  githubOwner="OWNER-OF-THE-REPO" \
  githubRepository="NAME-OF-THE-REPO" \
  githubWorkflowName="NAME-OF-THE-WORKFLOW" \
  githubBranch="NAME-OF-THE-BRANCH" \
  githubJobFilter="NAME-OF-THE-FILTER"'

Delete the stack:

  sam delete --stack-name NAME-OF-THE-STACK --no-prompts --region REGION-OF-THE-FUNCTION

Update the code of your function

Every time a pushed is done, the action automatically runs the "deploy.yml". In this way your Function will always be updated.