Cloud Resume Challenge Part 5 - Automating Backend Deployment with Terraform and GitHub Actions

Cloud Engineer and DevOps enthusiast, just talking about AWS, Docker, Linux, Kubernetes, Python, and automation.
Search for a command to run...

Cloud Engineer and DevOps enthusiast, just talking about AWS, Docker, Linux, Kubernetes, Python, and automation.
Level up your AWS cloud skills with the AWS Cloud Resume Challenge Series. Build and deploy a serverless web app using AWS services, mastering cloud computing and CI/CD practices.
In this blog post, I will walk you through the process of building the backend infrastructure for your Cloud Resume Challenge website using AWS services and Terraform. By following the steps outlined below, you will be able to set up and manage the n...
Running your own home lab used to mean expensive hardware, complex networking, and hours of manual configuration. This project changes that. With a single Raspberry Pi, Docker Compose, and a few hundr

Welcome to an advanced hybrid directory demo where we'll guide you through setting up a hybrid environment, connecting to simulated on-premises infrastructure, creating a managed Microsoft AD within AWS, establishing a two-way forest trust, and integ...

Hello DevOps Community! Today marks the completion of the #90DaysOfDevOps Challenge, and it's a moment to reflect on the journey we've undertaken together. Throughout this period, I've engaged with various technologies, refining my skills in the DevO...

In a modern cloud infrastructure setup, creating a robust and scalable 2-tier architecture is essential. Such an architecture helps meet the demands of your applications while ensuring repeatability, reliability, and security. In this article, we'll ...

Welcome to Part 4 of my series on building a comprehensive CI/CD pipeline in AWS. In this article, I will explore AWS CodePipeline, a powerful service for building and deploying applications in a continuous integration and continuous delivery (CI/CD)...


As part of the Cloud Resume Challenge, automating infrastructure deployment is a key skill to showcase. In this step-by-step guide, we will explore how to automate the backend deployment of your Cloud Resume Challenge website using Terraform and GitHub Actions. By leveraging these powerful tools, you can streamline the deployment process, ensure reproducibility, and demonstrate your proficiency in infrastructure automation.
To begin, create a new file named .github/workflows/terraform-deployment.yml in your Cloud Resume Challenge repository. This file will define the GitHub Actions workflow for automating the deployment. Inside the file, add the following workflow configuration code:
name: "Terraform Deployment for Cloud Resume Challenge"
on:
push:
branches:
- main
jobs:
terraform-plan-and-apply:
name: "Terraform Init, Plan, and Apply"
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
defaults:
run:
working-directory: infra
To ensure the workflow has access to the repository's code, add the following step to the workflow configuration:
steps:
- name: Checkout Repository Code
uses: actions/checkout@v2
To use Terraform within the workflow, we need to set up the Terraform CLI. Add the following step to the workflow configuration:
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
Before deploying the infrastructure, initialize the Terraform working directory. Add the following step to the workflow configuration:
- name: Terraform Init
id: init
run: terraform init
To ensure the correctness of your Terraform configuration files, add the following step to the workflow configuration:
- name: Terraform Validate
id: validate
run: terraform validate -no-color
Consistent code formatting is essential for readability and maintainability. Use Terraform to check if your files adhere to the desired format. Add the following step to the workflow configuration:
- name: Terraform Format
run: terraform fmt -check
To review the changes that Terraform will apply to the infrastructure, generate and examine the execution plan. Add the following step to the workflow configuration:
- name: Terraform Plan
id: plan
run: terraform plan -no-color
After reviewing and approving the execution plan, apply the changes to deploy the infrastructure. Add the following step to the workflow configuration:
- name: Terraform Apply
run: terraform apply -auto-approve
To ensure that the GitHub Actions workflow is functioning correctly, it's essential to test it before relying on it for automated deployments. Follow these steps to test the workflow:
Commit and push your changes: Make a small change to your code or configuration files, such as modifying a comment or adding a new file.
Push the changes to your repository: Use the git push command to push the changes to your GitHub repository.
Monitor the workflow execution: Go to the "Actions" tab in your GitHub repository and navigate to the workflow you set up. You should see a new workflow run triggered by the push event.
Review the workflow logs: Click on the workflow run to view the details. Monitor the logs to ensure that each step is executed without errors. You should see the steps being executed, including the Terraform initialization, validation, formatting, planning, and applying.
Verify the deployment: After the workflow run completes, verify that the changes are successfully deployed to your infrastructure. Access your AWS account and confirm that the desired resources are created or modified according to your Terraform configuration.

Congratulations! You have successfully set up the GitHub Actions workflow to automate the backend deployment of your Cloud Resume Challenge website using Terraform.
With this automation in place, you can confidently iterate on your Cloud Resume Challenge project, focusing on enhancing the user experience, showcasing your skills, and achieving your goals.