This copier templates deploys a Slackbot into Google Cloud Platform!
The template assumes that already have experience an installation of gcloud and that you have a Google Cloud project to deploy the bot in.
The template creates:
- a Google Cloud source code repository to contain the slackbot source code.
- a CloudBuild CI/CD pipeline to build the container image.
- a CloudBuild CI/CD pipeline to deploy changes to the Terraform templates.
- a Google Cloud Compute Engine managed instance group to run the slackbot.
- a Slack application manifest to ease the configuration of the application
The slackbot implementation will be responding to mentions and commands.
The slackbot is running in socket mode, meaning there is no need to configure any incoming internet traffic and makes it easy to respond to Slack API requests within three seconds.
To create and deploy your bot, type:
$ pip install copier
$ copier https://github.com/binxio/slackbot-on-google-cloud-platform-template authority-scraper-slackbot
🎤 the human readable name of your slackbot
Authority Scraper
🎤 a short description of the Slackbot
chats about authority contributions
🎤 the name of the package
authority_scraper_slackbot
🎤 Your full name?
Mark van Holsteijn
🎤 Your email address?
mark.vanholsteijn@xebia.com
🎤 the google project to deploy to
speeltuin-mvanholsteijn
🎤 primary region to deploy the slackbot to
europe-west4
🎤 the replica region for slackbot artifacts
europe-west1
🎤 the artifact repository location to deploy the image to
europe
🎤 name of the terraform state bucket
speeltuin-mvanholsteijn-terraform-state
Copying from template version 0.0.0.post6.dev0+78d6734
create .
create terraform
create terraform/providers.tf
create terraform/user-data.yaml
create terraform/versions.tf
create terraform/.gitignore
create terraform/variables.tf
create terraform/pipeline.tf
create terraform/slackbot.tf
create Dockerfile.jinja
create cloudbuild
create cloudbuild/deploy.yaml
create cloudbuild/build.yaml
create Pipfile
create .copier-answers.yml
create .gitignore
create Pipfile.lock
create .gcloudignore
create src
create src/authority_scraper_slackbot
create src/authority_scraper_slackbot/__init__.py
create src/authority_scraper_slackbot/google_secrets.py
create src/authority_scraper_slackbot/__main__.py
create src/authority_scraper_slackbot/bot.py
> Running task 1 of 2: [[ ! -d .git ]] && ( git init --initial-branch master && git add . && git commit -m 'initial import' && git remote add origin https://source.developers.google.com/p/speeltuin-mvanholsteijn/r/authority-scraper-slackbot && git tag 0.0.0) || exit 0
Initialized empty Git repository in /private/tmp/slb/.git/
$ cd /tmp/slb
$ umask 077
This will create the following source code directory:
.
├── Dockerfile
├── LICENSE
├── Makefile
├── Makefile.mk
├── Pipfile
├── cloudbuild
│ ├── build.yaml
│ └── deploy.yaml
├── pyproject.toml
├── setup.cfg
├── tox.ini
├── src
│ └── authority_scraper_slackbot
│ ├── __init__.py
│ ├── __main__.py
│ ├── bot.py
│ ├── google_secrets.py
│ └── manifest.yaml
├── tests
│ ├── test_command_help.py
│ └── test_mention_help.py
├── terraform
│ ├── pipeline.tf
│ ├── providers.tf
│ ├── slackbot.tf
│ ├── user-data.yaml
│ ├── variables.tf
│ └── versions.tf
├── secrets
Before you deploy and run the application, you activate the required Google services:
$ make enable-services
To install the bot as an application in Slack, goto https://api.slack.com/apps and create a new application from the manifest generated in the source directory. Follow the wizard and install the app in the workspace.
To create the terraform state bucket to store the Terraform state in, type:
$ make state-bucket
To deploy the slack bot to Google Cloud Platform, type:
$ make state-bucket
$ cd terraform
$ terraform init
$ terraform apply
To deploy the secrets of the slack bot into the respective Google Secrets, type:
$ make configure-secrets
Now deploy your changes to the git repository. This will trigger a build of the container image and a deployment of the newly created image using Google CloudBuild.
$ git push
Now, check the Google Cloudbuild logs. once the build and deploy complete, your bot is ready to run.
You can now chat with your bot and change the implementation!