Tutorial Highlights & Transcript
00:00 - Key Concepts
Before diving into it, we need a few key concepts. For those who are not familiar with GitHub Actions, it is a CI/CD tool that we can use very similar to GitLab workflows or very similar to Jenkins, not on the deployment, but on how we can manage it. We can manage it by using workflows. These are defined by YAML files, as you can see in the second picture. A workflow has multiple jobs that should run to deploy certain applications or to build certain artifacts. Some of the steps that we need in order to build or deploy an application can be used in multiple parts of a deployment or multiple pipelines. This is where reusable workflows it’s worked for. We can reuse certain workflows in different pipelines. This will make our code easier, easy to understand and modify in the future.
02:13 - Example 1
05:58 - Example 2
10:37 - Example 3
So here in the next step, I am running a Terraform plan in order to see what resources are being created, so going into the TF folder, and then running Terraform plan. For those who are a bit curious. The Terraform I have here is very basic. I’m just defining a provider for AWS defining a region and for the main TF, defining a simple S3 bucket. Nothing too complicated. If we run this, we should go to the GitHub UI. Go to demo three and then run the workflow.
Again, I’m going to use the development environment, but I could use any of those options. We should see the demo running the pipeline completed successfully going through the steps again. First, we have the checkout. This is running successfully, then we connect to AWS, again with the reusable workflows that I showed you before. After that, we do the Terraform setup. Again, using the reusable workflow. This uses the HashiCorp, setup Terraform v2, which basically installs Terraform into the machine and lets us use the Terraform command line. After that, we run the Terraform init command. This will enter the folder where we have our code on. After that, we try to select the dev workspace. But this doesn’t exist. So we created a workspace. And finally, after that, we were on the Terraform plan. So we run into the TF folder and then Terraform plan. Here we can see the plan for the resources that we are trying to create. As I said before, this is an example of a deployment with it for a client. I think reusable workflows are a great help for this because if not, we’ll have to, let’s say for example, we’ll have to have this piece of code in every time we call this action. We would have it in one or two workflows. We are saving code. We are not repeating ourselves and it’s way easier to manage and for people to understand when they are starting to see the pipelines that you’re working on.
Miguel Alvarado
DevOps Engineer
nClouds
Miguel is a DevOps Engineer at nClouds and an AWS Certified Cloud Practitioner.