AWS Classroom Series – 17/Apr/2020

Configure EC2 Instance

Preview Preview Preview

Scenarios:

  1. Ensure the EC2 machine created has
    • some softwares (like git etc ) instance
    • services like apache/tableu etc are started
    • some files downloaded from internet
    • Solution:
      • for software installations we might create an ami (but ami requires storage cost)
      • Services can be automatically started if they are configured in that way in AMI otherwise change AMI to meet your needs
      • If we write some kind of startup script, which gets executed when the machine is created, then it will help.
  2. Lets install apache server on amazon linux instance
    • As shown in the image below create an instance by changing user-data Preview

Cloud-init

  • A Startup script which gets launched when the vm is created and this approach is adopted by multiple clouds using a standard called as cloud-init.

  • In Cloud-init, user is expected to write a yaml file as mentioned over here

  • For overall documentation of cloud-init refer here

  • Userdata is stored in a service running in the ec2 machine on the ipaddress ‘169.254.169.254’

    • To get latest userdata
    curl http://169.254.169.254/latest/user-data
    
    • To run user-data without restarting the machine
    sudo -i
    curl http://169.254.169.254/latest/user-data > userdata.sh
    sh ./userdata.sh
    
    • The logs of the user data are stored in /var/log/cloud-init-output.log
  • Instance-Metadata: Refer Here

  • Refer Here for simple cloud-init

  • simple example of cloud-init

#cloud-config
repo_update: true
repo_upgrades: all

packages:
  - git
  - tree

runcmd:
  - [echo, 'helloworld']
  - [echo, 'helloworld1']

Preview

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Network Widget by Acurax Small Business Website Designers

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube