How to Create EC2 Instance by AWS Cli Command Line



Check the Ami in Aws cli :-

aws ec2 describe-images   --output table   --query 'Images[*].[VirtualizationType,Name,ImageId]'   --owners 309956199498   --filters     Name=root-device-type,Values=ebs     Name=image-type,Values=machine     Name=is-public,Values=true     Name=hypervisor,Values=xen     Name=architecture,Values=x86_64

----------------------------------------------------------------------------
|                              DescribeImages                              |
+-----+---------------------------------------------------+----------------+
|  hvm|  RHEL-7.3_HVM-20170613-x86_64-4-Hourly2-GP2       |  ami-29bdc246  |
|  hvm|  RHEL-7.4_HVM_Beta-20170518-x86_64-1-Hourly2-GP2  |  ami-3496eb5b  |
|  hvm|  RHEL-6.7_HVM-20160412-x86_64-1-Hourly2-GP2       |  ami-49bcd626  |
|  hvm|  RHEL-6.9_HVM-20170424-x86_64-2-Hourly2-GP2       |  ami-5444393b  |
|  hvm|  RHEL-6.9_HVM_Beta-20161219-x86_64-2-Hourly2-GP2  |  ami-6164120e  |
|  hvm|  RHEL-7.3_HVM-20170424-x86_64-2-Hourly2-GP2       |  ami-66453809  |
|  hvm|  RHEL-6.9_HVM-20170613-x86_64-3-Hourly2-GP2       |  ami-69bdc206  |
|  hvm|  RHEL-7.3_HVM_GA-20161026-x86_64-1-Hourly2-GP2    |  ami-7c9bef13  |
|  hvm|  RHEL-7.2_HVM-20161025-x86_64-1-Hourly2-GP2       |  ami-917205fe  |
|  hvm|  RHEL-7.3_HVM-20170424-x86_64-1-Hourly2-GP2       |  ami-926416fd  |
|  hvm|  RHEL-6.6_HVM_GA-20150601-x86_64-3-Hourly2-GP2    |  ami-c2b0daad  |
|  hvm|  RHEL-6.8_HVM_GA-20160503-x86_64-1-Hourly2-GP2    |  ami-cbb0daa4  |
|  hvm|  RHEL-7.2_HVM-20160301-x86_64-3-Hourly2-GP2       |  ami-cdbdd7a2  |
|  hvm|  RHEL-7.1_HVM-20150803-x86_64-1-Hourly2-GP2       |  ami-fcbfd593  |
|  hvm|  RHEL-6.9_HVM_GA-20170319-x86_64-1-Hourly2-GP2    |  ami-fdd5a592  |
+-----+---------------------------------------------------+----------------+

If you have a security group then check in command line :-

aws ec2 describe-security-groups --group-names --output table | less

Create the EC2 Instance :--
aws ec2 run-instances --image-id ami-29bdc246 --security-group-ids sg-1aae5272 --count 1 --instance-type t2.micro --key-name indiakey --query 'Instances[0].InstanceId'
And output show :--
"i-0b7c796de22f1d574"   ( instance id)

Delete the EC2 intance from AWS Cli :---
aws ec2 terminate-instances --instance-ids i-1234567890abcdef0
Stop the EC2 intance from AWS Cli  :--
aws ec2 stop-instances --instance-ids i-1234567890abcdef0




How to Create EC2 Instance by AWS Cli Command Line How to Create EC2 Instance by AWS Cli Command Line Reviewed by Unknown on October 31, 2017 Rating: 5

1 comment:

  1. Really nice blog! Keep update and share your information with us AWS Online Training

    ReplyDelete

Scribe

http://feeds.feedburner.com/LinuxAndAws
Powered by Blogger.
X

Get Updates On

Linux Tutorial

AWS Tutorial

Devops Tutorial

We are going to send you our resources for free. To collect your copy at first, join our mailing list. So don't miss any updates, stay connected!