Automatic deployment and management of a Django website using Docker, Terraform, and EC2 instances in AWS.
-
What? This is a Terraform stack to construct, deploy and manage a website with EC2 instances.
-
Why? To demonstrate running a simple website in AWS on an EC2 instance.
-
How? This repo contains the Docker Compose files to run a Django website locally and also in AWS on an EC2 instance.
- AWS profile configuration and credentials set. AWS CLI Configuration User Guide
- AWS Region specified in ./terraform/variables.tfvars file.
- Optional Namespace setting for your stack set in ./terraform/variables.tfvars.
Set the prerequisite information, and then from the root of this repo, run:
make apply
This will begin the Terraform process in your AWS account and region specified in the ./terraform/variables.tfvars file noted above in the prerequisites. The image used in the EC2 instance to run the website can be found on Docker Hub at nungster/ec2_website or pulled via
docker pull nungster/ec2_website:latest
The stack created by this terraform module is composed of:
- Compute
- EC2 instance
- Network
- Virtual Private Cloud
- Internet Gateway
- Security Group
- Subnet
- Security
- SSH Key Pair
Name | Description | Type | Default | Required |
---|---|---|---|---|
aws-profile | The name of the AWS shared credentials account. | string | aws-profile |
yes |
aws-region | The AWS region | string | aws-region |
yes |
Name | Description |
---|---|
browser_connection_string | The URL of the website |
ssh_connection_string | SSH connection string to the webserver |
- Split out Database to RDS
- Use ECR for Docker image Repository instead of a public repo
- IAM roles and policies to allow EC2 instances to read and pull ECR images
- Implement load balancing and ability to use more EC2 instances