AWS Lambda aufsetzen
Umgebungsvariablen definieren
Bevor mit dem AWS Lambda Setup gestartet wird, muss eine lokale .env Datei im Root Ordner des Projekts angelegt werden. Hier werden alle Variablen definiert, die die Umgebung benötigt. Zusätzlich werden auch die Daten des Bot Benutzers für Google Sheets als Environment Variablen gespeichert.
Beispiel in .env.example
example
## Slack config
SLACK_SIGNING_SECRET=
SLACK_BOT_TOKEN=
## Spreadsheet config
GOOGLE_SERVICE_ACC_EMAIL= #email of google service account
GOOGLE_SERVICE_ACC_PRIVATE_KEY='-----BEGIN PRIVATE KEY-----
key
key
key
-----END PRIVATE KEY-----
' #private key of google service account in this exact format (no special characters like line breaks)
## App config
APP_ADMIN= #admin of the app who should receive logs
PORT=8080
APP_ADMIN_CHANNEL= #channel for logs as files can't be sent in direct messages anymore
## Staette config
STAETTE_CHANNEL= #channel for staette polls
CRONJOB_LOG_TO_ADMIN=X #X for log
## Signature config
SIGNATURE_SIGNING_SECRET= #signing secret in docuseal for webhooks
SIGNATURE_HEADER_NAME=X-Sam-Signature #header name for signature verification
APPLICATION_FORM_TEMPLATE_ID= #template ID for application form in docuseal
SIGNATURE_WORKFLOW_SLACK_WEBHOOK='https://hooks.slack.com/triggers/xxxx' # slack webhook URL to start application process
## Arbeitsstunden config
SPREADSHEET_ID_MASTERDATA= #spreadsheet with masterdata
## Meldungen config
SPREADSHEET_ID_MELDUNGEN= #spreadsheet with meldungen
MELDUNGEN_ADMIN_CHANNEL= #channel for meldungen admin messagesAWS Lambda Setup für Slack
Dem Guide bei Slack für AWS Lambda folgen.
- AWS Account anlegen
- Person anlegen mit Zugriffsschlüssel
- AWS CLI in der Entwicklungsumgebung installieren
- AWS konfigurieren
aws configure
AWS Access Key ID [None]: #
AWS Secret Access Key [None]: #
Default region name [None]: eu-central-1
Default output format [None]: json- serverless installieren und einloggen mit Free-Plan Konto bei Serverless
WARNUNG
Keine Lizenz benötigt!
serverless.ymlregion, org und service anpassen- AWS Lambda Funktion deployen
serverless deploy- bereitgestellte URL, die auf
/slack/eventsendet in den Slack Bot eintragen als Endpunkt (nächstes Kapitel)