Source: Dev.to | Dec 30, 2025 (UTC)
Provisioning infrastructure and deploying applications manually is a recipe for inconsistency. Today, I took on the challenge of automating a server setup using Terraform to host a Spring Boot Java application. It wasn’t a straight path. I ran into regional payment blocks, architecture mismatches and SSH “ghosts” but here is exactly how I solved them.
The Pivot From DigitalOcean to AWS:
I was following a course where the instructor used DigitalOcean to deploy the Java app. I tried to follow along, but I hit a brick wall, DigitalOcean kept rejecting my cards because I am in Nigeria.
I felt bad for a few days, but then I remembered my #30ofAWSTerraform challenge. AWS is known for its complexity, but it’s also the industry leader. I decided to stop feeling bad and start building. If the course used a DigitalOcean “Firewall,” I knew I could translate that into an AWS Security Group. I decided to test my knowledge and gain real experience.
1. Provisioning Infrastructure with Terraform:
My goal was to use Infrastructure as Code (IaC) to create an EC2 instance. I used the aws_instance and aws_key_pair resources to define my server.
The Challenge: SSH Key Management
Initially, passing the public key as a raw string variable led to formatting errors.
The Solution:
I used the Terraform file() function to read my public key directly from my local disk. This ensured that the exact bytes on my Windows machine matched what AWS received.
resource "aws_key_pair" "my_ssh_key" { key_name = "zacks-key" public_key = file("C:/Users/Public/id_aws.pub") }
Enter fullscreen mode
Exit fullscreen mode







Залишити відповідь