This repository contains Terraform code for deploying AWS infrastructure resources. The provided code provisions the following AWS resources:
- AWS Key Pair
- Virtual Private Cloud (VPC)
- Subnet
- Internet Gateway
- Route Table
- Route Table Association
- Security Group
- EC2 Instance
Before you begin, ensure you have the following:
- Terraform installed on your local machine.
- AWS CLI configured with your AWS access and secret keys.
In order to deploy this infrastructure, you may need to customize the following parameters in the main.tf file:
- AWS region: Replace the
regionin the AWS provider block with your desired AWS region.
provider "aws" {
region = "us-east-1" # Replace with your desired AWS region.
}-
Key Pair: You should replace the
key_nameandpublic_keywith your preferred values in theaws_key_pairresource block. -
VPC CIDR Block: You can change the VPC CIDR block in the
variableblock in themain.tffile. -
EC2 AMI: Replace the
amiin theaws_instanceresource block with the desired Amazon Machine Image (AMI) ID. -
SSH Configuration: Modify the SSH connection settings in the
aws_instanceresource block to match your preferred configuration. -
Provisioning: Customize the provisioner sections to suit your application's needs.
-
Clone this repository to your local machine.
-
Open your terminal and navigate to the repository folder.
-
Initialize Terraform by running:
terraform init- Plan the infrastructure deployment to verify the changes:
terraform plan- Deploy the infrastructure by running:
terraform apply- Confirm and apply the changes when prompted.
If you want to tear down the infrastructure created by this Terraform configuration, run:
terraform destroy- Make sure to protect your AWS access keys and do not hardcode them in your code. Consider using environment variables or AWS profile for secure access.
- Review the security group and network settings to ensure they align with your application's requirements.
Please be cautious when deploying and destroying infrastructure, as it can result in real-world financial costs and potential data loss.