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.
Our app runs the MEAN stack. Feel free to check on this project’s repository, if you need some inspiration. One can achieve that by creating a pipeline in Heroku such:
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:
In this article, I show step by step how to configure it.
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”.
By running:
$ terraform init
To know what you are going to deploy, run:
$ terraform plan
If everything is correct, run:
$ terraform apply --auto-aprove
The output should be similar to this
Congratulations, your infrastructure is on! 💯
Double check it on Heroku’s dashboard:
That looks fine. Don’t forget to add yourself as the owner of the pipeline
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$ exit$ 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 😀
Entrepreneurship 🔥
My Journey As A Computer Science Student on Medium_And some tips on how to start writing._medium.com
Top 8 lessons I’ve learned in European Innovation Academy 2017_Imagine you are seeing the opportunity to improve yourself at every level. Would you take it?_blog.startuppulse.net