This is a custom Infrastructure As Code (IaC) solution, written in Hashicorp Configuration Language (HCL). It facilitates the deployment of a single Elastic Compute Cloud (EC2) instance on Amazon Web Services (AWS). The solution includes a pool of EC2 instances under the Variable Component which can be tailored to meet specific requirements.
Terraform enables you to safely and predictably create, change and improve infrastructures. This allows a blueprint of your datacenter to be versioned and treated as you would any other code. Additionally, infrastuctures can be shared and re-used.
To deploy this infrastructure you will need:
- Terraform CLI (0.14.9+) installed.
- AWS CLI (2.10.4+) installed.
- AWS account.
- AWS Access Key. It is possible to generate a new AWS Access Key if desired.
- Clone the solution repository to your local device:
git clone https://github.com/etoromol/aws-single-node.git
cd aws-single-node- Initialize the working directory with Terraform:
terraform init- Authenticate your AWS account in AWS CLI using your terminal. You will be prompted to enter your AWS Access Key ID and Secret Access Key.
aws configureThe configuration process stores your credentials in a file at ~/.aws/credentials on MacOS and Linux, or %UserProfile%.aws\credentials on Windows.
- Navigate to the Variable Component (variable.tf) and customize the solution's details according to your requirements (description, tag, access_key etc.).
variable "project" {
description = "Cloud VM Infrastructure as Code" <-
type = map(string)
default = {
tag = "cloud" <-
access_key = "ssh-cloud-key" <-
}
}- Initiate the deployment process:
terraform applyIt is recommended that you review the deployment plan before with "terraform plan".
- Once your EC2 instance is ready, you may access it using your SSH key:
ssh -i "path/to-your/ssh_key" ec2-user@instance_public_ipYou can obtain the value of instance_public_ip running "terraform output"
- If the infrastructure is no longer required, it should be destroyed.:
terraform destroyTerraform will present the deployment and destruction plans before and after initialization. Proceed with the destruction/deployment by typing 'yes'; otherwise, Terraform will not proceed any further.
Copyright (c) 2023 Eduardo Toro.
Licensed under the MIT license.