PhD researcher (Blockchain); https://rafaelapb.github.io/
I’m currently a teacher assistant 👨💻@ Técnico Lisboa, and I’m working closely with Dr. Professor Rui Cruz 👨🏫at the It Infrastructure Management and Administration 🖥, a masters level course @ Técnico Lisboa.
My experience as a professor opened my mind on how to use certain tools to achieve goals that me, as a student, want to reach. As a student, I’m responsible for a student’s group, GCE. Our project had some problems: it was very difficult and time-consuming to move from the conceptualization of an idea to its actually delivery.
A good, automated infrastructure was the answer to our problem. It allowed saving lots of time and effort, which translated into a better product delivered faster. This technique is meant for the ones that want to deliver as much as possible to the client as quickly as possible.
This allows for extreme flexibility. The workflow can be something like:
At the end of the day, you have saved lots of precious minutes, which can be very representative in one semester.
The idea is to have a virtual machine as the machine which will configure our infrastructure on Heroku, through Terraform. We will manage this virtual machine using Vagrant.
If you want to know how Terraform works, check this tutorial (up to “Requirements”, 1min read). You can achieve the same purpose without a virtual machine. In that case, skip directly to Step 2. What we will do is well condensed in the following scheme:
Now, open your console and run:
$ vagrant up --provision && vagrant ssh
The virtual machine is booting, installing all the required dependencies. This may take a while.
Wait a bit. Done. Nice. Kudos to you 👍
Fork this repository containing the support files and then clone it to your computer. Put it in the folder that is being synced with your guest machine.
Now, replace the GitHub repositories and Heroku credentials on the file terraform-vars.tfvars.
Notice what it’s being done on terraform-apps.tf.
To authenticate, run:
$ heroku login --interactive
Put your credentials and login. Next, we need to generate an access token to Terraform to be able to communicate with Heroku. Run:
$ heroku authorizations:create
This will return you something like this:
Go to terraform-vars.tf and paste the token obtained in the field “heroku_api_key”.
$ terraform init
To know what you are going to deploy, run:
$ terraform plan
If everything is correct, run:
$ terraform apply --auto-aprove
Congratulations, your infrastructure is on! 💯
Double check it on Heroku’s dashboard:
I recommend you to configure the deployment method on each app, by choosing a GitHub repository and associate it with a branch. For instance, we could associate the “develop” branch to the development app. When a commit occurs, it will be automatically deployed.
With two commands you will end the experiment and shut down the virtual machine. These are:
$ terraform destroy -auto-approve
$ vagrant halt
If you want to destroy the virtual machine you created, run:
$ vagrant destroy --auto-approve
Congratulations! 💯 You reached the end! 🦄
This is a very good infrastructure for MVPs, although it might not be the best in the long run. Nextly, I’m going to talk about Kubernetes and how we can deliver an infrastructure similar to this, but much more scalable. Stay tuned 😀
Create your free account to unlock your custom reading experience.