Skip to content

This project provisions a VPC and an EC2 instance on AWS through Terraform.

License

Notifications You must be signed in to change notification settings

diogofiaminghi/terraform-project-01

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VPC and EC2 provisioning on AWS using Terraform

GitHub language count Repository size GitHub last commit License Stargazers

Status: Finished

DescriptionPre-requisitesHow it worksTech StackAuthorLicense

Description

This project provisions a VPC and an EC2 instance on AWS through Terraform. In this project, the terraform.tfstate file is stored remotely in an S3 bucket. In addition, we have the creation of a Subnet, AWS Internet Gateway, Route Table and AWS Security Group. Finally, an EC2 instance is created within the Subnet. All resources will be created in the us-east-1 region.


Pre-requisites

Before you begin, you will need to have the following tools installed on your machine: [Terraform] (https://www.terraform.io/) and [Git] (https://git-scm.com). You will need to have a [AWS Account] (https://aws.amazon.com/). In addition, it is good to have an editor to work with the code like [VSCode] (https://code.visualstudio.com/).


How it works

1 - Clone this repository.

git clone git@github.com:diogofiaminghi/terraform-project-01.git

2 - Create an S3 bucket on AWS manually.

3 - Open de Project Folder in VSCode

4 - Edit the main.tf file. On line 13, paste the name of your S3 bucket.

bucket = "your-S3-bucket-name-here"

5 - Open a new bash terminal in VSCode. Create an SSH key pair named 'aws-key'.

ssh-keygen

6 - You must now configure your AWS Access Keys using the bash terminal.

export AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXX
export AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

7 - Terraform Commands in Project Folder

terraform init
terraform fmt
terraform validate
terraform plan -out=plan.out
terraform apply plan.out

8 - Now, to prove that everything worked, get the 'vm_ip' in 'output' and let's connect via ssh to the newly created instance.

ssh -i "aws-key" ubuntu@the-public-ip-here
exit

9 - Do not forget to destroy the provisioned structure otherwise you will be able to receive invoices.

terraform destroy

Tech Stack

The following tools were used in the construction of the project:


Author

Diogo Fiaminghi

Linkedin Badge Gmail Badge


License

This project is under the license MIT.

Made with love by Diogo Fiaminghi 👋🏽 Get in Touch!


About

This project provisions a VPC and an EC2 instance on AWS through Terraform.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages