{"id":6863,"date":"2016-01-18T06:59:18","date_gmt":"2016-01-18T05:59:18","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/"},"modified":"2016-01-18T06:59:18","modified_gmt":"2016-01-18T05:59:18","slug":"launching-a-vm-with-the-amazon-aws-command-line-tools","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/","title":{"rendered":"Launching a VM with the Amazon AWS command line tools"},"content":{"rendered":"<p>The cool thing with Amazon AWS is that you can use <a href=\"http:\/\/docs.aws.amazon.com\/cli\/latest\/userguide\/cli-chap-welcome.html\" target=\"_blank\">command line tools<\/a> on your workstation to bring up and manage your services. In this post I&#8217;ll look into how you can launch a Linux VM from the command line and how you can attach a storage volume to it. <\/p>\n<p>Before you can use the command line tools you&#8217;ll need to create a user that has the proper permissions to connect. This must be done in the IAM console:<\/p>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_iam_1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_iam_1.png\" alt=\"aws_rds_iam_1\" width=\"1229\" height=\"771\" class=\"aligncenter size-full wp-image-6610\" \/><\/a><\/p>\n<p>As I have no users available right now I&#8217;ll create one:<\/p>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_iam_2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_iam_2.png\" alt=\"aws_rds_iam_2\" width=\"1641\" height=\"699\" class=\"aligncenter size-full wp-image-6611\" \/><\/a><br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_iam_3.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_iam_3.png\" alt=\"aws_rds_iam_3\" width=\"1282\" height=\"467\" class=\"aligncenter size-full wp-image-6612\" \/><\/a><\/p>\n<p>Be sure to download the credentials right now as you&#8217;ll not be able to get the &#8220;Secret Access Key&#8221; later. You&#8217;ll need this key when we configure the command line tools later. <\/p>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_iam_4.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_iam_4.png\" alt=\"aws_rds_iam_4\" width=\"1905\" height=\"916\" class=\"aligncenter size-full wp-image-6613\" \/><\/a><\/p>\n<p>Once the user is created all the details are listed:<\/p>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_iam_5.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_iam_5.png\" alt=\"aws_rds_iam_5\" width=\"1879\" height=\"895\" class=\"aligncenter size-full wp-image-6614\" \/><\/a><\/p>\n<p>To be sure I can do everything I want I attached the &#8220;Administrator Access&#8221; policy to the user just created:<\/p>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_iam_6.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_iam_6.png\" alt=\"aws_rds_iam_6\" width=\"1915\" height=\"630\" class=\"aligncenter size-full wp-image-6616\" \/><\/a><\/p>\n<p>Having the user available we can now proceed and install the command line tools. You&#8217;ll need to have python available for that:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\ndwe@dwe:~\/Downloads$ python --version\nPython 2.7.6\n<\/pre>\n<p>The installation is quite easy:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\ndwe@dwe:~\/Downloads$ curl \"https:\/\/s3.amazonaws.com\/aws-cli\/awscli-bundle.zip\" -o \"awscli-bundle.zip\"\ndwe@dwe:~\/Downloads$ unzip awscli-bundle.zip\ndwe@dwe:~\/Downloads$ sudo .\/awscli-bundle\/install -i \/usr\/local\/aws -b \/usr\/local\/bin\/aws\nRunning cmd: \/usr\/bin\/python virtualenv.py --python \/usr\/bin\/python \/usr\/local\/aws\nRunning cmd: \/usr\/local\/aws\/bin\/pip install --no-index --find-links file:\/\/\/home\/dwe\/Downloads\/awscli-bundle\/packages awscli-1.9.20.tar.gz\nYou can now run: \/usr\/local\/bin\/aws --version\ndwe@dwe:~\/Downloads$ \/usr\/local\/bin\/aws --version\naws-cli\/1.9.20 Python\/2.7.6 Linux\/4.2.0-23-generic botocore\/1.3.20\ndwe@dwe:~\/Downloads\n<\/pre>\n<p>You can get help by issuing:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\ndwe@dwe:~\/Downloads$ \/usr\/local\/bin\/aws rds help\n<\/pre>\n<p>This brings up the manual similar to the Linux man pages:<\/p>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_help.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_help.png\" alt=\"aws_rds_help\" width=\"1116\" height=\"619\" class=\"aligncenter size-full wp-image-6609\" \/><\/a><\/p>\n<p>Now it is the time to configure the command line tools. You&#8217;ll need the contents of the credentials file you downloaded above:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\ndwe@dwe:~\/Downloads$ \/usr\/local\/bin\/aws configure\nAWS Access Key ID [None]: AKIAIZJEZEA4F4B6VWDQ\nAWS Secret Access Key [None]: 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\nDefault region name [None]: eu-west-1\nDefault output format [None]: json\n<\/pre>\n<p>A list of Regions and endpoints can be found <a href=\"http:\/\/docs.aws.amazon.com\/general\/latest\/gr\/rande.html#ec2_region\" target=\"_blank\">here<\/a>. <\/p>\n<p>For being able to launch a VM the next step is to create the ssh keys:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\ndwe@dwe:~\/Downloads$ aws ec2 create-key-pair --key-name MyKeyPair --query 'KeyMaterial' --output text &gt; MyKeyPair.pem\ndwe@dwe:~\/Downloads$ cat MyKeyPair.pem \n-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAiwnxikaNFmlgDB1v0lQhlmmWvT1bfVpCjfa0tjOw6enp5q5B6eahN36q+eCT\nW9jf6UTOakQxXxeNAXrbt\/SWmVmjZzOOx1SyvqpU+dFk8eBI7MCuEoQyGfxAau6XyFB9v+Juzyy2\nV2Z6kMtfwGSUST9uy9uoVmvH9J+aefJv6R5jQcv8c6AUIGPvOuO3LmHRT2IEuaLgC4bD332NuawB\ny5ZIpDpiDojU6ENrk0Q6Z8fClbD+smWISx\/cTV1Pj0zOpjNZDtnEnqxpZyhSmHdqX\/BbN4lVECzJ\nVypA0kbuHVu9tcYz+T7lsK3\/Itlm8hdtVeFQBd6S\/w5v3G\/j2uNaRwIDAQABAoIBAAc2lNlfn6Iy\nBVGblVmME9IB2Fgo\/r4aGKnUyrtJIzx\/bisRj0nbNTHz2FruU7bIIZWwhCTvNMCCMEaLYSrB\/a4n\nAFsySY39zuglXhM30czane3qcR10zkSa2ZyylB1IT73MuYL2Bt+x6VnpsyYAEdFbARyCYNFa9hyy\nywjYkwW9AbTxKewEwTN4DOfmfEXaP5t\/slXm1afq3cRFPUnoClFhXwK8TSPX6Dz521UUn+JUq\/xM\n0B36yBtG1HtKJEvcf+cUAPQ8\/+oyQgXI0RliKQQKUNg6g5Nmb\/RoWbO6zmS\/bGdbX5Ckz1IQ+UtM\nJ6oCdgCSQCXrc6l550TcFx+5l8ECgYEA79IdoWcLkrTuIjRuoDwA7Jit9SnbLkfaQwEBnjizO5j\/\nIzUSi9GectrkL7WvIt\/ylfjneiAa3wx8U2pGDPA2cI0QjZi\/u5amSf9a7EsU4m6LFLcH5CkgdDvW\nmOIKkMdYku2FW9UGNmc1m5wLiESp47m0tB59cvLefb+K\/WklYb0CgYEAlGs\/m7aLE8ZSO9yjwkpu\n8FP4SiuzjIMuyTdn8MXXU6TCfHdW1GuE4WIlYn8EJ0U7GUOULZ9TPPekJ7+n2yrF+KItonutTI4v\nXgwH6XMWdDNnUScawSwqzMLCB2fDu\/BhDCdxHRwPujbGcQ8gxYRO0Q\/OlnhGgKfHFIpE+gjg8lMC\ngYEA6HgdEN\/6b\/PDApUgx2Ji4vX9arFwLaSpBlprXxxHYXYlm9NObwp7NYrJtxW+92dul8H3YILO\niXho69MQpGoV23Rin196PDUEbKaDVJpTXEsbtrDVjW3wb7uxgfFbnIwgaAymQSZ2JzZU2Mqiwy0M\nIhtZ91+26z5SPkL2UD8kZWECgYEAhSFWozQwuIIyjWOyuLrPnF+V3eIpYibhtrguUfkE1xB5K\/BY\nQJ5ZSVoiMqHAdgFRq63Eos\/BeHSiGM1\/ocZSYl4HFTJfFsaLko60IiGLyJu7Vz3+b7xQf+9K4B2h\no1lRk\/dlLTlYmi47\/noVaVbu4\/SL2Mj2ZL0ahEAq8yU3seUCgYBnd8mJIBuWqKOPGWp5MSkco1OX\niIS2\/\/BEaJiOHXxqow6uS\/0TlTXk\/qZavEoEiUZ91bhLM4ThH9q\/yywBD2nu+YxUfbH2Lz9PeIeL\nSiOrK6HBKmU3P2sVUxCLO\/vQZN32rIK8U8Hv6h77ViUZyXRTvSxULduJsjRpHxIzVoWFmw==\n-----END RSA PRIVATE KEY-----\ndwe@dwe:~\/Downloads$ \n<\/pre>\n<p>Be sure to modify the permission of the generated key:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\ndwe@dwe:~\/Downloads$ chmod 400 MyKeyPair.pem\n<\/pre>\n<p>What type of instance do we want to create? You can get the full list of available images by using the &#8220;describe-images&#8221; sub command:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\ndwe@dwe:~\/.aws$ aws ec2 describe-images &gt; \/var\/tmp\/aws-images.json\n<\/pre>\n<p>As I wanted to know what &#8220;Amazon Linux&#8221; is based on I took this one:<\/p>\n<pre class=\"brush: text; gutter: true; first-line: 1\">\n\"ImageId\": \"ami-025e5676\"\n\"Description\": \"Amazon Linux AMI x86_64 EBS\"\n<\/pre>\n<p>Knowing what we want to launch we can now bring up the instance:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\ndwe@dwe:~\/Downloads$ aws ec2 run-instances --image-id ami-025e5676 --count 1 --instance-type t1.micro --key-name MyKeyPair\n{\n    \"OwnerId\": \"505389097308\", \n    \"ReservationId\": \"r-1abaa1a3\", \n    \"Groups\": [], \n    \"Instances\": [\n        {\n            \"Monitoring\": {\n                \"State\": \"disabled\"\n            }, \n            \"PublicDnsName\": \"\", \n            \"KernelId\": \"aki-71665e05\", \n            \"State\": {\n                \"Code\": 0, \n                \"Name\": \"pending\"\n            }, \n            \"EbsOptimized\": false, \n            \"LaunchTime\": \"2016-01-16T04:57:30.000Z\", \n            \"PrivateIpAddress\": \"172.31.43.22\", \n            \"ProductCodes\": [], \n            \"VpcId\": \"vpc-6c634009\", \n            \"StateTransitionReason\": \"\", \n            \"InstanceId\": \"i-07560b8a\", \n            \"ImageId\": \"ami-025e5676\", \n            \"PrivateDnsName\": \"ip-172-31-43-22.eu-west-1.compute.internal\", \n            \"KeyName\": \"MyKeyPair\", \n            \"SecurityGroups\": [\n                {\n                    \"GroupName\": \"default\", \n                    \"GroupId\": \"sg-ee31498a\"\n                }\n            ], \n            \"ClientToken\": \"\", \n            \"SubnetId\": \"subnet-dffbb186\", \n            \"InstanceType\": \"t1.micro\", \n            \"NetworkInterfaces\": [\n                {\n                    \"Status\": \"in-use\", \n                    \"MacAddress\": \"0a:32:b2:89:70:67\", \n                    \"SourceDestCheck\": true, \n                    \"VpcId\": \"vpc-6c634009\", \n                    \"Description\": \"\", \n                    \"NetworkInterfaceId\": \"eni-0fa82155\", \n                    \"PrivateIpAddresses\": [\n                        {\n                            \"PrivateDnsName\": \"ip-172-31-43-22.eu-west-1.compute.internal\", \n                            \"Primary\": true, \n                            \"PrivateIpAddress\": \"172.31.43.22\"\n                        }\n                    ], \n                    \"PrivateDnsName\": \"ip-172-31-43-22.eu-west-1.compute.internal\", \n                    \"Attachment\": {\n                        \"Status\": \"attaching\", \n                        \"DeviceIndex\": 0, \n                        \"DeleteOnTermination\": true, \n                        \"AttachmentId\": \"eni-attach-21ce50c7\", \n                        \"AttachTime\": \"2016-01-16T04:57:30.000Z\"\n                    }, \n                    \"Groups\": [\n                        {\n                            \"GroupName\": \"default\", \n                            \"GroupId\": \"sg-ee31498a\"\n                        }\n                    ], \n                    \"SubnetId\": \"subnet-dffbb186\", \n                    \"OwnerId\": \"505389097308\", \n                    \"PrivateIpAddress\": \"172.31.43.22\"\n                }\n            ], \n            \"SourceDestCheck\": true, \n            \"Placement\": {\n                \"Tenancy\": \"default\", \n                \"GroupName\": \"\", \n                \"AvailabilityZone\": \"eu-west-1a\"\n            }, \n            \"Hypervisor\": \"xen\", \n            \"BlockDeviceMappings\": [], \n            \"Architecture\": \"x86_64\", \n            \"StateReason\": {\n                \"Message\": \"pending\", \n                \"Code\": \"pending\"\n            }, \n            \"RootDeviceName\": \"\/dev\/sda1\", \n            \"VirtualizationType\": \"paravirtual\", \n            \"RootDeviceType\": \"ebs\", \n            \"AmiLaunchIndex\": 0\n        }\n    ]\n}\n<\/pre>\n<p>A lot of json ouput \ud83d\ude42 You can pass json files to command line utilities as well. The output fully describes your instance.<\/p>\n<p>Having a look at the AWS EC2 console we can see that the instance in deed was created and is being initialized currently:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/was_launch_instance_1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/was_launch_instance_1.png\" alt=\"was_launch_instance_1\" width=\"1901\" height=\"174\" class=\"aligncenter size-full wp-image-6618\" \/><\/a><\/p>\n<p>While the instance is set up it is good idea to give the instance a name:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\ndwe@dwe:~\/Downloads$ aws ec2 create-tags --resources i-07560b8a --tags Key=Name,Value=MyFirstInstance\n<\/pre>\n<p>Going back to the console the name is set and the instance is ready:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/was_launch_instance_2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/was_launch_instance_2.png\" alt=\"was_launch_instance_2\" width=\"1714\" height=\"151\" class=\"aligncenter size-full wp-image-6619\" \/><\/a><\/p>\n<p>Time to connect:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\ndwe@dwe:~\/Downloads$ ssh -i \/home\/dwe\/Downloads\/MyKeyPair.pem ec2-user@ec2-52-19-222-92.eu-west-1.compute.amazonaws.com\n\n       __|  __|_  )\n       _|  (     \/   Amazon Linux AMI\n      ___|\\___|___|\n\nhttps:\/\/aws.amazon.com\/amazon-linux-ami\/2012.09-release-notes\/\nAmazon Linux version 2015.09 is available.\n<\/pre>\n<p>Lets check if this instance is redhat based and we can use yum:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\n[ec2-user@ip-172-31-43-22 ~]$ yum search postgresql94-server\nLoaded plugins: priorities, update-motd, upgrade-helper\n=================================================== N\/S matched: postgresql94-server ====================================================\npostgresql94-server.x86_64 : The programs needed to create and run a PostgreSQL server\n\n  Name and summary matches only, use \"search all\" for everything.\n<\/pre>\n<p>Cool. What devices do I have available?<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\n[ec2-user@ip-172-31-43-22 ~]$ df -h\nFilesystem            Size  Used Avail Use% Mounted on\n\/dev\/xvda1            2.0G  686M  1.3G  35% \/\ntmpfs                 298M     0  298M   0% \/dev\/shm\n<\/pre>\n<p>Only the root volume was created. Not much if we want to some real work on the instance. So lets create a new volume (10gb):<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\ndwe@dwe:~\/Downloads$ aws ec2 create-volume --size 10 --availability-zone eu-west-1a\n{\n    \"AvailabilityZone\": \"eu-west-1a\", \n    \"Encrypted\": false, \n    \"VolumeType\": \"standard\", \n    \"VolumeId\": \"vol-fcb06c32\", \n    \"State\": \"creating\", \n    \"SnapshotId\": \"\", \n    \"CreateTime\": \"2016-01-16T05:17:33.615Z\", \n    \"Size\": 10\n}\n<\/pre>\n<p>Providing the name of the new volume it can be attached to the instance:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\ndwe@dwe:~\/Downloads$ aws ec2 attach-volume --volume-id vol-fcb06c32 --instance-id i-07560b8a --device \/dev\/sdb\n{\n    \"AttachTime\": \"2016-01-16T05:19:51.640Z\", \n    \"InstanceId\": \"i-07560b8a\", \n    \"VolumeId\": \"vol-fcb06c32\", \n    \"State\": \"attaching\", \n    \"Device\": \"\/dev\/sdb\"\n}\n<\/pre>\n<p>Seems this operation is online, lets check:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\ndwe@dwe:~\/Downloads$ ssh -i \/home\/dwe\/Downloads\/MyKeyPair.pem ec2-user@ec2-52-19-222-92.eu-west-1.compute.amazonaws.com\nLast login: Sat Jan 16 05:19:35 2016 from hsi-kbw-078-043-043-105.hsi4.kabel-badenwuerttemberg.de\n\n       __|  __|_  )\n       _|  (     \/   Amazon Linux AMI\n      ___|\\___|___|\n\nhttps:\/\/aws.amazon.com\/amazon-linux-ami\/2012.09-release-notes\/\nAmazon Linux version 2015.09 is available.\n[ec2-user@ip-172-31-43-22 ~]$ ls \/dev\/sd*\n\/dev\/sda1  \/dev\/sdb\n<\/pre>\n<p>Really, really cool. Do I have root access to create a partition on my new device?<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\n[ec2-user@ip-172-31-43-22 ~]$ sudo su -\n[root@ip-172-31-43-22 ~]# fdisk \/dev\/sdb\nDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel\nBuilding a new DOS disklabel with disk identifier 0x85f44e7c.\nChanges will remain in memory only, until you decide to write them.\nAfter that, of course, the previous content won't be recoverable.\n\nWarning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)\n\nWARNING: DOS-compatible mode is deprecated. It's strongly recommended to\n         switch off the mode (command 'c') and change display units to\n         sectors (command 'u').\n\nCommand (m for help): p\n\nDisk \/dev\/sdb: 10.7 GB, 10737418240 bytes\n255 heads, 63 sectors\/track, 1305 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x85f44e7c\n\n   Device Boot      Start         End      Blocks   Id  System\n\nCommand (m for help): n\nCommand action\n   e   extended\n   p   primary partition (1-4)\np\nPartition number (1-4): 1\nFirst cylinder (1-1305, default 1): \nUsing default value 1\nLast cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): \nUsing default value 1305\n\nCommand (m for help): w\nThe partition table has been altered!\n\nCalling ioctl() to re-read partition table.\nSyncing disks.\n\n[root@ip-172-31-43-22 ~]# ls -la \/dev\/sd*\nlrwxrwxrwx 1 root root 5 Jan 16 04:58 \/dev\/sda1 -&gt; xvda1\nlrwxrwxrwx 1 root root 4 Jan 16 05:21 \/dev\/sdb -&gt; xvdb\nlrwxrwxrwx 1 root root 5 Jan 16 05:21 \/dev\/sdb1 -&gt; xvdb1\n<\/pre>\n<p>Yes, I do. So creating a file system should be possible, too:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\n[root@ip-172-31-43-22 ~]# mkfs.ext4 \/dev\/sdb1\nmke2fs 1.42.3 (14-May-2012)\nFilesystem label=\nOS type: Linux\nBlock size=4096 (log=2)\nFragment size=4096 (log=2)\nStride=0 blocks, Stripe width=0 blocks\n655360 inodes, 2620595 blocks\n131029 blocks (5.00%) reserved for the super user\nFirst data block=0\nMaximum filesystem blocks=2684354560\n80 block groups\n32768 blocks per group, 32768 fragments per group\n8192 inodes per group\nSuperblock backups stored on blocks: \n\t32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632\n\nAllocating group tables: done                            \nWriting inode tables: done                            \nCreating journal (32768 blocks): done\nWriting superblocks and filesystem accounting information: done \n<\/pre>\n<p>Can I mount it?<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\n[root@ip-172-31-43-22 ~]# mkdir \/opt\/PostgreSQL\n[root@ip-172-31-43-22 ~]# mount \/dev\/sdb1 \/opt\/PostgreSQL\n[root@ip-172-31-43-22 ~]# df -h\nFilesystem            Size  Used Avail Use% Mounted on\n\/dev\/xvda1            2.0G  686M  1.3G  35% \/\ntmpfs                 298M     0  298M   0% \/dev\/shm\n\/dev\/xvdb1            9.9G  151M  9.2G   2% \/opt\/PostgreSQL\n<\/pre>\n<p>Yes, I have full control. So I could do whatever I want with this VM. Imagine how easy it becomes to bring up test systems this way. Create a little script which wraps all the commands and you&#8217;re done in a few minutes. <\/p>\n<p>As a lot of sensitive information was displayed here lets terminate the instance:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\ndwe@dwe:~\/.aws$ aws ec2 terminate-instances --instance-ids i-07560b8a \n{\n    \"TerminatingInstances\": [\n        {\n            \"InstanceId\": \"i-07560b8a\", \n            \"CurrentState\": {\n                \"Code\": 32, \n                \"Name\": \"shutting-down\"\n            }, \n            \"PreviousState\": {\n                \"Code\": 16, \n                \"Name\": \"running\"\n            }\n        }\n    ]\n}\n<\/pre>\n<p>Easy as well. Have fun with command line tools &#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The cool thing with Amazon AWS is that you can use command line tools on your workstation to bring up and manage your services. In this post I&#8217;ll look into how you can launch a Linux VM from the command line and how you can attach a storage volume to it. Before you can use [&hellip;]<\/p>\n","protected":false},"author":29,"featured_media":6873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[229],"tags":[289],"type_dbi":[],"class_list":["post-6863","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-database-administration-monitoring","tag-cloud-computing"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Launching a VM with the Amazon AWS command line tools - dbi Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Launching a VM with the Amazon AWS command line tools\" \/>\n<meta property=\"og:description\" content=\"The cool thing with Amazon AWS is that you can use command line tools on your workstation to bring up and manage your services. In this post I&#8217;ll look into how you can launch a Linux VM from the command line and how you can attach a storage volume to it. Before you can use [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2016-01-18T05:59:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_help-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1116\" \/>\n\t<meta property=\"og:image:height\" content=\"619\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Daniel Westermann\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@westermanndanie\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Daniel Westermann\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/\"},\"author\":{\"name\":\"Daniel Westermann\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d08e9bd996a89bd75c0286cbabf3c66\"},\"headline\":\"Launching a VM with the Amazon AWS command line tools\",\"datePublished\":\"2016-01-18T05:59:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/\"},\"wordCount\":566,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_help-1.png\",\"keywords\":[\"Cloud computing\"],\"articleSection\":[\"Database Administration &amp; Monitoring\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/\",\"name\":\"Launching a VM with the Amazon AWS command line tools - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_help-1.png\",\"datePublished\":\"2016-01-18T05:59:18+00:00\",\"author\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d08e9bd996a89bd75c0286cbabf3c66\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/#primaryimage\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_help-1.png\",\"contentUrl\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_help-1.png\",\"width\":1116,\"height\":619},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/www.dbi-services.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Launching a VM with the Amazon AWS command line tools\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d08e9bd996a89bd75c0286cbabf3c66\",\"name\":\"Daniel Westermann\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/31350ceeecb1dd8986339a29bf040d4cd3cd087d410deccd8f55234466d6c317?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/31350ceeecb1dd8986339a29bf040d4cd3cd087d410deccd8f55234466d6c317?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/31350ceeecb1dd8986339a29bf040d4cd3cd087d410deccd8f55234466d6c317?s=96&d=mm&r=g\",\"caption\":\"Daniel Westermann\"},\"description\":\"Daniel Westermann is Principal Consultant and Technology Leader Open Infrastructure at dbi services. He has more than 15 years of experience in management, engineering and optimization of databases and infrastructures, especially on Oracle and PostgreSQL. Since the beginning of his career, he has specialized in Oracle Technologies and is Oracle Certified Professional 12c and Oracle Certified Expert RAC\/GridInfra. Over time, Daniel has become increasingly interested in open source technologies, becoming \u201cTechnology Leader Open Infrastructure\u201d and PostgreSQL expert. \u00a0Based on community or EnterpriseDB tools, he develops and installs complex high available solutions with PostgreSQL. He is also a certified PostgreSQL Plus 9.0 Professional and a Postgres Advanced Server 9.4 Professional. He is a regular speaker at PostgreSQL conferences in Switzerland and Europe. Today Daniel is also supporting our customers on AWS services such as AWS RDS, database migrations into the cloud, EC2 and automated infrastructure management with AWS SSM (System Manager). He is a certified AWS Solutions Architect Professional. Prior to dbi services, Daniel was Management System Engineer at LC SYSTEMS-Engineering AG in Basel. Before that, he worked as Oracle Developper &amp;\u00a0Project Manager at Delta Energy Solutions AG in Basel (today Powel AG). Daniel holds a diploma in Business Informatics (DHBW, Germany). His branch-related experience mainly covers the pharma industry, the financial sector, energy, lottery and telecommunications.\",\"sameAs\":[\"https:\/\/x.com\/westermanndanie\"],\"url\":\"https:\/\/www.dbi-services.com\/blog\/author\/daniel-westermann\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Launching a VM with the Amazon AWS command line tools - dbi Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/","og_locale":"en_US","og_type":"article","og_title":"Launching a VM with the Amazon AWS command line tools","og_description":"The cool thing with Amazon AWS is that you can use command line tools on your workstation to bring up and manage your services. In this post I&#8217;ll look into how you can launch a Linux VM from the command line and how you can attach a storage volume to it. Before you can use [&hellip;]","og_url":"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/","og_site_name":"dbi Blog","article_published_time":"2016-01-18T05:59:18+00:00","og_image":[{"width":1116,"height":619,"url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_help-1.png","type":"image\/png"}],"author":"Daniel Westermann","twitter_card":"summary_large_image","twitter_creator":"@westermanndanie","twitter_misc":{"Written by":"Daniel Westermann","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/"},"author":{"name":"Daniel Westermann","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d08e9bd996a89bd75c0286cbabf3c66"},"headline":"Launching a VM with the Amazon AWS command line tools","datePublished":"2016-01-18T05:59:18+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/"},"wordCount":566,"commentCount":0,"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_help-1.png","keywords":["Cloud computing"],"articleSection":["Database Administration &amp; Monitoring"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/","url":"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/","name":"Launching a VM with the Amazon AWS command line tools - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/#primaryimage"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_help-1.png","datePublished":"2016-01-18T05:59:18+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d08e9bd996a89bd75c0286cbabf3c66"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/#primaryimage","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_help-1.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/aws_rds_help-1.png","width":1116,"height":619},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/launching-a-vm-with-the-amazon-aws-command-line-tools\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Launching a VM with the Amazon AWS command line tools"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d08e9bd996a89bd75c0286cbabf3c66","name":"Daniel Westermann","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/31350ceeecb1dd8986339a29bf040d4cd3cd087d410deccd8f55234466d6c317?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/31350ceeecb1dd8986339a29bf040d4cd3cd087d410deccd8f55234466d6c317?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/31350ceeecb1dd8986339a29bf040d4cd3cd087d410deccd8f55234466d6c317?s=96&d=mm&r=g","caption":"Daniel Westermann"},"description":"Daniel Westermann is Principal Consultant and Technology Leader Open Infrastructure at dbi services. He has more than 15 years of experience in management, engineering and optimization of databases and infrastructures, especially on Oracle and PostgreSQL. Since the beginning of his career, he has specialized in Oracle Technologies and is Oracle Certified Professional 12c and Oracle Certified Expert RAC\/GridInfra. Over time, Daniel has become increasingly interested in open source technologies, becoming \u201cTechnology Leader Open Infrastructure\u201d and PostgreSQL expert. \u00a0Based on community or EnterpriseDB tools, he develops and installs complex high available solutions with PostgreSQL. He is also a certified PostgreSQL Plus 9.0 Professional and a Postgres Advanced Server 9.4 Professional. He is a regular speaker at PostgreSQL conferences in Switzerland and Europe. Today Daniel is also supporting our customers on AWS services such as AWS RDS, database migrations into the cloud, EC2 and automated infrastructure management with AWS SSM (System Manager). He is a certified AWS Solutions Architect Professional. Prior to dbi services, Daniel was Management System Engineer at LC SYSTEMS-Engineering AG in Basel. Before that, he worked as Oracle Developper &amp;\u00a0Project Manager at Delta Energy Solutions AG in Basel (today Powel AG). Daniel holds a diploma in Business Informatics (DHBW, Germany). His branch-related experience mainly covers the pharma industry, the financial sector, energy, lottery and telecommunications.","sameAs":["https:\/\/x.com\/westermanndanie"],"url":"https:\/\/www.dbi-services.com\/blog\/author\/daniel-westermann\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/6863","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=6863"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/6863\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media\/6873"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=6863"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=6863"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=6863"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=6863"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}