AWS Classroom Series – 15/Apr/2020

AWS CLI in Action

  • Lets use the CLI to create a script to launch an ec2 instance
  • Lets write individual commands
    • to create ec2 instance
    • manage ec2 instances

Realize EC2 CLI

  • Create an aws ec2 instance with ubuntu ami in the us-west-2 region
aws ec2 run-instances --image-id 'ami-0d1cd67c26f5fca19' --instance-type 't2.micro' --key-name 'chef' --security-group-ids "sg-003772772f5073f26"  
  • Make a note of instance id (i-0ce835ae5156b19e5)
  • Now Stop the ec2-instance
aws ec2 stop-instances --instance-ids i-0ce835ae5156b19e5
  • Now Start the instance
aws ec2 start-instances --instance-ids i-0ce835ae5156b19e5
  • Now stop the instance and resize it to t2.nano
aws ec2 modify-instance-attribute  --instance-id i-0ce835ae5156b19e5  --instance-type 'Value=t2.nano'
  • Create an AMI from EC2 machine and view the image using CLI Preview Preview Preview
  • Note: Generally for Creating AMI’s most of the organizations use automated tools such as Packer.

Exercise: Take a closer look of creating a ec2 instance of every possible option

  • You can make a note/screenshot/mindmap especially configure instance Preview

Leave a Reply

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

About learningthoughtsadmin