Skip to content

maxence-charriere/ninfra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ninfra

A terraform module that creates:

  • A load balancer
  • An auto scalling group
  • 5 ububtu VM with Apache that serve "hello world"

Install

  • Run those commands:

    # Tools
    brew install terraform
    brew install packer
    
    # Build Ububtu with Apache
    packer build apache-packer.json
  • Create a KeyPair and save it on disk.

  • Change image_id and key_name in main.tf

    module "ninfra" {
    source = "./infra"
    
    # Use the image_id created with:
    # packer build apache-packer.json
    # https://us-west-2.console.aws.amazon.com/ec2/v2/home?region=us-west-2#Images:visibility=owned-by-me;sort=name
    image_id = "ami-081c4a2dcf94faaa0"
    
    
    # Use the key-pair created in:
    # https://us-west-2.console.aws.amazon.com/ec2/v2/home?region=us-west-2#KeyPairs:sort=keyName
    key_name = "ssh-key"
    }
  • Build the infra

    terraform init
    terraform apply

Test autoscalling

Remove instance by hand

Make a instance unhealthy

  • Find an instance ip on the EC2 instance dashboard

  • Go to a terminal and ssh to that instance

    # Change acl of the key downloaded when keyPair was created.
    chmod 0600 ssh-key.pem.txt
    
    # Ssh to the instance.
    ssh -i ssh-key.pem.txt ubuntu@INSTANCE_IP
    
    # Kill apache.
    sudo killall -9 apache2

Monitoring

Uninstall

  • Deregister ami-ninfra

  • Destroy the infra

    terraform destroy
    

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published