Automating infrastructure nowadays is becoming fairly common and one of the first things that Enterprises look towards when modernizing their technology stack.
Enterprises are looking to move fast, and in order to move quickly, you have to decrease the amount of time it takes to provision and configure new infrastructure. We have countless blogs covering this with various automation languages such as Ansible and Terraform.
Today, I will make automation a little more fun by provisioning instances on Google Cloud Platform using Google Assistant and Google Dialogflow. In the middle, I'm going to be using GitHub Actions to do the heavy lifting of completing this workflow.
What's GitHub Actions?
GitHub Actions is an API for cause and effect on GitHub: orchestrate any workflow, based on any event, while GitHub manages the execution, provides rich feedback, and secures every step along the way. With GitHub Actions, workflows and steps are just code in a repository, so you can create, share, reuse, and fork your software development practices.
With the Alpha release of GitHub Actions last year, CI/CD was introduced. GitHub Actions now makes it easier to automate how you build, test, and deploy your projects on any platform, including Linux, macOS, and Windows. Run your workflows in a container or in a virtual machine. Actions also support more languages and frameworks than ever, including Node.js, Python, Java, PHP, Ruby, C/C++, .NET, Android, and iOS.
What's Dialogflow?
Dialogflow is a natural language processing (NLP) platform that can be used to build conversational applications and experiences on multiple platforms. The Google-powered product enables developers to create text-based and voice conversation interfaces for responding to customer queries in different languages.
For example, Dialogflow can be used to create messaging bots that respond to queries in platforms like Alexa, Google Assistant, Slack and several other messaging integrations.
What's Google Assistant?
You probably know:
Let's get started!
Workflow:

By saying the number of instances to Google Assistant, an issue will be opened or closed. This issue will contain the number of instances I'm requesting for. GitHub Actions will parse the number from the issue and execute a Terraform plan to create GCP instances.
Configuring GitHub Actions workflow:
The main GitHub Actions file used is here:
The repo for the above file is here. The above Actions workflow is also leveraging a custom Action which is available on the GitHub Marketplace
GitHub Actions has a secret store which is utilized for GOOGLE_CREDENTIALS while GITHUB_TOKEN is pre-configured in GitHub Actions. For configuring this follow here
Configuring Dialogflow:
I'm not going to get into how to get started with Dialogflow. Once the app has been created, create a Fulfillment with the following code which will call GitHub's API to close or open an Issue:
Next, create the following Intents:

The above could be anything and could be customized to your liking. The important one is the numberofvm which looks like the following:

Additional components:
I've also configured a custom Action for Terraform Destroy, which is available here. This is referenced in the second GitHub Actions file on the repo
See it in action:
I presented this demo at a GitHub meetup last month in Toronto. The workflow starts at 01:01.
Hope this was a fun read! Interested in learning more?