Getting started with the Terraform for managing a base free-tier AWS resources
Getting started with the Terraform for managing a base free-tier AWS resources.
This is a Terraform project for managing AWS resources.
It can build the next infrastructure:
VPC
VPC
IGW
, VPC
and Subnet
Subnet
with the HTTP(s) & SSH access~/.aws/credentials
does’t exist, create it and add you Terraform profile to the file. For example:
[terraform]
aws_access_key_id = Your access key
aws_secret_access_key = Your secret access key
./src/free-tier/backend/config.tf
that will contain information how to store state in a given bucket. See example.Create SSH key pair to connect to EC2 instance:
cd ./src/free-tier/provision/access
# it creates "free-tier-ec2-key" private key and "free-tier-ec2-key.pub" public key
ssh-keygen -f free-tier-ec2-key
cd ./src/free-tier
terraform init -backend-config="./backend/config.tf"
terraform plan
terraform apply
After building the infrastructure you can try to connect to you EC2 instance
via SSH:
cd ./src/free-tier
ssh -i ./provision/access/free-tier-ec2-key ubuntu@[EC2 public IP]
To check HTTP access you can install apache2
on your EC2 instance:
sudo apt update && sudo apt install apache2
(on EC2 machine)sudo service apache2 start
(on EC2 machine) http://[EC2 public IP]/
. You can see Apache2 Default Page
(something like this)To destroy infrastructure:
cd ./src/free-tier
terraform destroy