Skip to content

kstcovflw/EKS-ALB-Terraform-Architecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

How to reproduce 503 error

This guide will walk you through the setup and deployment of the project using Terraform. Follow these steps to configure and deploy your infrastructure.

Step 1: Update Project Configuration

First, update the Terraform configuration to specify your project settings. Start by renaming the project bucket name in the Terraform variables.

Update Variables

Edit the variables.tf in the ready/ directory to set your project's bucket name for Terraform state management.

variable "project_bucket_name" {
  type        = string
  description = "Bucket name for Terraform state files"
  default     = "your-unique-bucket-name"  # Replace with a unique bucket name
}

Step 2: Configure Backend for Terraform

Next, link your backend configuration to the updated bucket name by modifying the main.tf in the deployment/ directory.

Update Backend Configuration

backend "s3" {
  bucket = "your-unique-bucket-name"  # Ensure this matches the bucket name specified above

  # Additional backend configuration...
}

Step 3: Create and Push Docker Image to AWS ECR

Create a Docker image for your Next.js application, which runs on port 3000. Follow the Next.js documentation for setup Next.js documentation.

Prepare the Dockerfile

Add this Dockerfile inside of your Next.js project directory, not in the Terraform directory:

FROM node:latest

WORKDIR /app

COPY package.json .

RUN npm install

COPY . .

RUN npm run build

CMD ["npm", "start", "--", "-p", "3000"]

Create and Push the Docker Image

First, authenticate your Docker client to your Amazon ECR registry:

aws ecr get-login-password --region your-region | docker login --username AWS --password-stdin your-account-id.dkr.ecr.your-region.amazonaws.com

Build the Docker image and tag it as next-frontend:latest:

docker build -t next-frontend:latest .

Create a repository in AWS ECR if it doesn't already exist:

aws ecr create-repository --repository-name next-frontend --region your-region

Tag your Docker image to match your repository in ECR:

docker tag next-frontend:latest your-account-id.dkr.ecr.your-region.amazonaws.com/next-frontend:latest

Finally, push the Docker image to your AWS ECR:

docker push your-account-id.dkr.ecr.your-region.amazonaws.com/next-frontend:latest

Replace variable with your actual ecr repo url

  description = "The Docker image for the Next.js application."
  // Replace with your actual image URL
  default     = "123456789012.dkr.ecr.us-east-1.amazonaws.com/next-frontend"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages