MultiCloud Classroom notes 13/Feb/2025

CLI contd …

Lets create an ubuntu 24.04 ec2 instance in mumbai region

  • output: ec2 instance with a public ip
  • inputs:
    • tags: Name: from-cli
    • ami: ami-00bb6a80f01f03502
    • instance type: t2-micro
    • subnet: subnet-067813a42fb6cbebe
    • key pair: my_idrsa
    • security group: docker
    • region: ap-south-1
  • lets find a command to create ec2 instance
  • Running on Powershell
aws ec2 run-instances `
    --image-id "ami-00bb6a80f01f03502" `
    --instance-type "t2.micro" `
    --key-name "my_idrsa" `
    --subnet-id "subnet-067813a42fb6cbebe" `
    --tag-specifications "ResourceType=instance,Tags=[{Key=Name,Value=from-cli}]" `
    --associate-public-ip-address `
    --security-group-ids "sg-077690d1b4c7e9836"
  • Running on bash
aws ec2 run-instances \
    --image-id "ami-00bb6a80f01f03502" \
    --instance-type "t2.micro" \
    --key-name "my_idrsa" \
    --subnet-id "subnet-067813a42fb6cbebe" \
    --tag-specifications "ResourceType=instance,Tags=[{Key=Name,Value=from-cli}]" \
    --associate-public-ip-address \
    --security-group-ids "sg-077690d1b4c7e9836"

Preview

Lets get the ec2 instance id of the machine created above

  • Command
aws ec2 describe-instances --query "Reservations[0].Instances[0].InstanceId"

Lets get the names of all key pairs

  • Command
aws ec2 describe-key-pairs

Lets get all the security group ids

  • Command
aws ec2 describe-security-groups --query "SecurityGroups[].GroupId"

Lets get the security id for a security group with name docker

  • Command
 aws ec2 describe-security-groups --query "SecurityGroups[?GroupName == 'docker'].GroupId"

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

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

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company

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