Skip to content

Getting started with the Terraform for managing a base free-tier AWS resources.

License

Notifications You must be signed in to change notification settings

Clausinho/terraform-aws-free-tier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform AWS Free Tier

Getting started with the Terraform for managing a base free-tier AWS resources

License: MIT

Project description

This is a Terraform project for managing AWS resources.

It can build the next infrastructure:

  • One VPC
  • One public Subnet in the VPC
  • One IGW to enable access to or from the internet for VPC
  • One Route Table to associate IGW, VPC and Subnet
  • One EC2 Instance in the public Subnet with the HTTP(s) access and SSH access

Pre steps

  1. Install Terraform
  2. Create AWS account
  3. Create ~/.aws/credentials file if not exists and add you Terraform profile. For example:
    [terraform]
    aws_access_key_id = Your access key
    aws_secret_access_key = Your secret access key 
    
  4. Create S3 bucket to store Terraform state
  5. Create config file ./src/free-tier/backend/config.tf that will contain information how to store state in a given bucket. See example.
  6. 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

Build infrastructure

  1. cd ./src/free-tier
  2. terraform init -backend-config="./backend/config.tf"
  3. terraform plan
  4. terraform apply

Post steps

After building the infrastructure you can try to connect to you EC2 instance via SSH:

  1. cd ./src/free-tier
  2. ssh -i ./provision/access/free-tier-ec2-key ubuntu@[EC2 public IP]

To check HTTP access you can install apache2 on your EC2 instance:

  1. ssh -i ./provision/access/free-tier-ec2-key ubuntu@[EC2 public IP]
  2. sudo apt install apache2 (on EC2 machine)
  3. sudo service apache2 start (on EC2 machine)
  4. Check in browser: http://[EC2 public IP]/. You can see Apache2 Default Page (Something like this)

To destroy infrastructure:

  1. cd ./src/free-tier
  2. terraform destroy

About

Getting started with the Terraform for managing a base free-tier AWS resources.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HCL 100.0%