Don't Slack Evil is the submission of the team "Les Gars" for the 2020 Slack App virtual hackathon
- Setup the serverless framework
- Set up shared AWS credentials:
- Ask Cyril for the shared AWS credentials
- Add to your AWS credentials file (
~/.aws/credentials) the following:
[dont-slack-evil-hackaton]
aws_access_key_id=SECRET_FROM_CYRIL
aws_secret_access_key=SECRET_FROM_CYRIL
- Add to your aws config file (
~/.aws/config) the following:
[profile dont-slack-evil-hackaton]
region=us-east-1
- Set up secret file:
cp example.secrets.dev.yml secrets.dev.ymland fill the secrets - Deploy:
make deploy - Configure your Slack app with your function URLs
- event subscriptions : use the /messages endpoint
- interactive components : use the /interactive endpoint
Currently if you need to update environment variables you need to
- update
example.secrets.dev.yml - update
secrets.dev.yml, the actual env file - update
serverless.ymlto inject the env variable where it is needed - update the "Create secrets file" section of
continuous_production.ymlto create the env file in CI
- Install the Go extension. When prompted, install the necessary Go Tools (
golint,goreturns,gopls) - Add these properties to your
settings.jsonfile:
{
"go.useLanguageServer": true,
"go.toolsEnvVars": {
"GO111MODULES": "on",
"GOFLAGS": "-mod=vendor"
}
}The first property, go.useLanguageServer, will activate the Language Server for Go, which will improve features such as autocompletion, when using modules.
The second property, go.toolsEnvVars, will export 2 env vars when code analysis is performed by VSCode:
GO111MODULES=on: this will activate the use of Golang modulesGOFLAGS=-mod=vendor: references to external packages will be looked up in the/vendorgitignored folder
You can make use of the following extra properties:
go.testOnSave: truefor triggeringgo teston each save (if autosave is disabled) or CTRL+S (if autosave is enabled)go.testOnSave: falsefor deactivating build on each save
Under Debug > open configurations, add the following ENV variables
"env": {
"DYNAMODB_TABLE_PREFIX": "dont-slack-evil-test-",
"AWS_REGION": "us-east-1"
},
Under Code > Preferences > Settings, search for "testEnvVars" and add your vars again under settings
"settings": {
"go.testEnvVars": {
"DYNAMODB_TABLE_PREFIX": "dont-slack-evil-test-",
"AWS_REGION": "us-east-1"
},
}
direnvwill execute the.envrcfile and leverage the 2 env variables- Install
golint(the linter) andgoreturns(the formatter)
go get -u golang.org/x/lint/golint
go get -u github.com/sqs/goreturns
- Before committing your code, run the formatter, and then, run the linter and correct any error it raises
go fmt ./..
$HOME/go/bin/golint ./..
WARNING: The linter will also show errors from the /vendor directory
- If you are using VSCode, the added dependency will be downloaded in the background. Otherwise, you will have to run
go get -u <Dependency_Path>
- Delete the
vendor/folder, cd into the project's root dir and run these 2 commands:
# Recreate the vendor/ folder
go mod vendor
# Update go.mod and go.sum
go mod tidy
Project-level tests can be run with this single command:
go test ./...
You can append the -v flag for verbose input
https://github.com/serverless/examples
# Deploy
serverless deploy function -f webhook
# OR
serverless deploy# Logs the activity of a lambda
serverless logs -t -f hello# Encrypt / Decrypt secrets
serverless encrypt --stage dev --password 'your-password'
serverless decrypt --stage dev --password 'your-password'# Remove all serverless services
serverless removeIf make deploy fails:
go get -u github.com/aws/aws-lambda-go/lambda