Skip to content

ritoban23/terraform-aws-nginx-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform AWS Nginx & Docker

A modular Terraform project that provisions a Virtual Private Cloud (VPC), subnets, and an EC2 web server instance on AWS. It handles automatic installation of Docker and Nginx on the target machine.

Architecture

The configuration is split into distinct modules for better maintainability:

  • subnet module: Responsible for provisioning the VPC, Subnet, Internet Gateway, and Default Route Table.
  • webserver module: Responsible for provisioning the EC2 instance, Security Group, and AMI logic. Also handles the execution of entry scripts via SSH to spin up services.

Prerequisites

  • Request an AWS account.
  • Install Terraform CLI.
  • Install AWS CLI.
  • Ensure you have an SSH Key Pair configured on your local machine (~/.ssh/id_ed25519).

Usage

  1. Create a terraform.tfvars file to store your uncommitted configuration:
vpc_cidr_block        = "10.0.0.0/16"
subnet_cider_block    = "10.0.10.0/24"
availability_zone     = "eu-central-1b"
env_prefix            = "dev"
my_ip                 = "YOUR_IP_ADDRESS/32"
instance_type         = "t2.micro"
public_key_path       = "~/.ssh/id_ed25519.pub"
private_key_location  = "~/.ssh/id_ed25519"
  1. Initialize Terraform to download provider plugins and register modules:
terraform init
  1. Review the infrastructure plan:
terraform plan
  1. Apply the configuration to provision the AWS cloud resources:
terraform apply
  1. When done, destroy the resources to avoid incurring charges:
terraform destroy

About

A modular Terraform project to provision an AWS VPC, EC2 instance, and deploy Nginx/Docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors