Terraform and Nuxt: Deployment Automation

Terraform, created by HashiCorp, is one of the leading tools for professionals such as DevOps Engineers, Cloud Architects, and System Administrators. Its goal is to provision and manage infrastructure in a declarative, automated, and idempotent way, allowing users to create, modify, or destroy resources across providers such as AWS, Azure, GCP, and others. To demonstrate Terraform in practice, I developed a simple application using Nuxt, a framework based on Vue.js. The application is a static website, but it could easily serve as an MVP (Minimum Viable Product) for presentation on a production server — whether in an isolated demonstration environment or a more robust, planned deployment scenario. 1. CI with GitHub Actions I used GitHub Actions to create a simple Continuous Integration (CI) pipeline. The workflow builds the Nuxt project, generates a tarball as an artifact, and makes this file available as a release for download. This approach simulates the containerization stage, where the Docker image build could be pushed to a registry such as Docker Hub or Amazon ECR. 2. Terraform for Continuous Deployment Terraform is used in the Continuous Deployment phase (in this case, executed manually for demonstration purposes). It provisions the necessary infrastructure on AWS to host the application, automating the following steps: Fetching the latest available AMI from AWS. Setting up access using an SSH key pair. Creating and configuring VPC, subnets, and Security Group rules. Creating an EC2 instance with service setup (Nginx and Docker), EBS storage, and tag naming. Deploying the Nuxt.js application in real cloud infrastructure on AWS. Server Flow Overview The generated tarball contains the Nuxt build and a Dockerfile. On the server, the tarball is extracted, the Docker image is built and executed. An Nginx configuration file (.conf) is used to act as a reverse proxy, forwarding traffic from port 3000 (Docker) to port 80 (web). Final Notes Watch through to the end: with just a few Terraform commands, configuration files, and an SSH key pair, I deployed a web application automatically. Terraform’s idempotency is a crucial feature that allows modifying the current infrastructure state without rebuilding everything from scratch. For example, I can add more security configurations or deploy new applications on top of the existing setup. Links: Github heasy_terraform_aws: https://github.com/everton-tenorio/easy_terraform_aws/ Nuxt: https://nuxt.com/ Github Actions: https://docs.github.com/en/actions Terraform Registry | AWS Providers: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ AWS Free Tier: https://aws.amazon.com/en/free/ Fish Shell: https://fishshell.com/

Apr 11, 2025 - 23:57
 0
Terraform and Nuxt: Deployment Automation

Terraform, created by HashiCorp, is one of the leading tools for professionals such as DevOps Engineers, Cloud Architects, and System Administrators. Its goal is to provision and manage infrastructure in a declarative, automated, and idempotent way, allowing users to create, modify, or destroy resources across providers such as AWS, Azure, GCP, and others.

To demonstrate Terraform in practice, I developed a simple application using Nuxt, a framework based on Vue.js. The application is a static website, but it could easily serve as an MVP (Minimum Viable Product) for presentation on a production server — whether in an isolated demonstration environment or a more robust, planned deployment scenario.

1. CI with GitHub Actions

I used GitHub Actions to create a simple Continuous Integration (CI) pipeline. The workflow builds the Nuxt project, generates a tarball as an artifact, and makes this file available as a release for download. This approach simulates the containerization stage, where the Docker image build could be pushed to a registry such as Docker Hub or Amazon ECR.

2. Terraform for Continuous Deployment

Terraform is used in the Continuous Deployment phase (in this case, executed manually for demonstration purposes). It provisions the necessary infrastructure on AWS to host the application, automating the following steps:

  • Fetching the latest available AMI from AWS.
  • Setting up access using an SSH key pair.
  • Creating and configuring VPC, subnets, and Security Group rules.
  • Creating an EC2 instance with service setup (Nginx and Docker), EBS storage, and tag naming.
  • Deploying the Nuxt.js application in real cloud infrastructure on AWS.

Server Flow Overview

  • The generated tarball contains the Nuxt build and a Dockerfile.
  • On the server, the tarball is extracted, the Docker image is built and executed.
  • An Nginx configuration file (.conf) is used to act as a reverse proxy, forwarding traffic from port 3000 (Docker) to port 80 (web).

Final Notes

Watch through to the end: with just a few Terraform commands, configuration files, and an SSH key pair, I deployed a web application automatically.

Terraform’s idempotency is a crucial feature that allows modifying the current infrastructure state without rebuilding everything from scratch. For example, I can add more security configurations or deploy new applications on top of the existing setup.

Links: