<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>aws Archives - Tech Antidote</title>
	<atom:link href="https://techantidote.com/category/technology/aws/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>‎ &#124; LINUX &#124; Tech &#124; Security &#124;</description>
	<lastBuildDate>Sun, 12 Aug 2018 03:04:40 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>

<image>
	<url>https://techantidote.com/wp-content/uploads/2016/02/cropped-google-plus-profile-picture-32x32.png</url>
	<title>aws Archives - Tech Antidote</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">106369530</site>	<item>
		<title>A Simple Bash Script for deploying an EC2 instance in AWS</title>
		<link>https://techantidote.com/a-simple-bash-script-for-deploying-an-ec2-instance-in-aws/</link>
					<comments>https://techantidote.com/a-simple-bash-script-for-deploying-an-ec2-instance-in-aws/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Fri, 20 Jul 2018 20:33:17 +0000</pubDate>
				<category><![CDATA[aws]]></category>
		<category><![CDATA[Linux / Ubuntu]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[aws cli]]></category>
		<category><![CDATA[bash script]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[ec2 bash script]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">https://techantidote.com/?p=2689</guid>

					<description><![CDATA[<p>Below is a sample bash script that I created to deploy an EC2 instance in AWS. What does this script do? -Load the at the user defined values for VPC,Subnet, Security Policy. -Use aws cli to interact with AWS with the IAM user configured. -Create a new AWS key named &#8220;devenv-key&#8221; and store the corresponding &#8230; <a href="https://techantidote.com/a-simple-bash-script-for-deploying-an-ec2-instance-in-aws/" class="more-link">Continue reading <span class="screen-reader-text">A Simple Bash Script for deploying an EC2 instance in AWS</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://techantidote.com/a-simple-bash-script-for-deploying-an-ec2-instance-in-aws/">A Simple Bash Script for deploying an EC2 instance in AWS</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Below is a sample bash script that I created to deploy an EC2 instance in AWS.</p>
<p><strong>What does this script do?</strong></p>
<p>-Load the at the user defined values for VPC,Subnet, Security Policy.<br />
-Use aws cli to interact with AWS with the IAM user configured.<br />
-Create a new AWS key named &#8220;devenv-key&#8221; and store the corresponding key in your local machine.<br />
-Deploy an t2.micro ubuntu EC2 instance.<br />
-Upon deployment, it will wait for 60 seconds and SSH directly into the newly deployed ubuntu ec2 instance.</p>
<p><span style="text-decoration: underline;"><strong>Prerequisites:</strong></span></p>
<p>-An Amazon <strong>AWS account</strong>.(Free or Paid account)<br />
-An <strong>IAM user</strong> with Access Key and secret access key.<br />
&#8211;<strong>Pre-configured</strong> <strong>VPC</strong>, <strong>Subnets</strong>, Routes, Internet gateways, <strong>Security policy</strong>.<br />
-Any <strong>Linux</strong> <strong>Machine</strong> with <strong>aws cli utlity</strong> installed.<br />
[Refer to my previous blog post on how to install AWS CLI tool.]<br />
<strong>Link</strong>: <a href="https://techantidote.com/how-to-install-aws-cli-in-linux-auto-command-completion/">https://techantidote.com/how-to-install-aws-cli-in-linux-auto-command-completion/</a></p>
<p>&#8211; In host machine, run &#8220;<strong>aws configure</strong>&#8221; to <strong>configure</strong> your <strong>IAM user details</strong>.</p>
<p>[ PS: I am not a expert in scripting. ]</p>
<p><strong>Variables to be set before running the script:</strong></p>
<p>-I have added the following variables in the script:</p>
<pre>"vpc_id"
"sub_id"
"route_table"
"internet_gateway"
"sec_id"
"aws_image_id"
"i_type".
</pre>
<p>-Substitute values for these variables from that of your AWS environment in the script.</p>
<p><strong>How do I run the script?</strong></p>
<p><strong>Option 1: Git clone and run it<br />
</strong></p>
<p>-I have setup a public project in gitlab. You can clone and run the script (You would require git to clone the project.)</p>
<pre>git clone https://gitlab.com/techantidote/aws-bash.git
cd aws-bash</pre>
<p>-Edit the script getaws.sh and update values for vpc_id, sub_id and sec_id.<br />
-Once done, run the script:</p>
<pre>./getaws.sh</pre>
<p><strong>Option 2</strong>:<br />
-Create a file (getaws.sh), make it executable, copy the below contents to this file and run the script.</p>
<p><strong>Bash Script starts here:</strong></p>
<pre>#!/bin/bash
echo -e "\e[33m ========= AWS Automation Project =========\033[0m"

#AWS variables - Modify these as per your account
# Enter your VPC ID
vpc_id="vpc-12345"

# Enter your Subnet ID.
sub_id="subnet-12345"

#Enter your route table ID - Optional
#route_table="rtb-12345"

#Enter internet gateway - Optional
#internet_gateway="igw-12345"

# Enter your security group ID
sec_id="sg-12345"

# Enter the AWS Image ID you would like to deploy. The below image ID is for an Ubuntu EC2 instance.
aws_image_id="ami-41e9c52e"

#Set the type of instance you would like. Here, I am specifying a T2 micro instance.
i_type="t2.micro"

# Create an optional tag.
tag="Wakanda"

#Create the key name what you want
aws_key_name="devenv-key"
ssh_key="devenv-key.pem"

#Generate a random id - This is optional
uid=$RANDOM

# Generate AWS Keys and store in this local box
echo "Generating key Pairs"
aws ec2 create-key-pair --key-name devenv-key --query 'KeyMaterial' --output text 2&gt;&amp;1 | tee $ssh_key

#Set read only access for key
echo "Setting permissions"
chmod 400 $ssh_key

echo "Creating EC2 instance in AWS"
#echo "UID $uid"

ec2_id=$(aws ec2 run-instances --image-id $aws_image_id --count 1 --instance-type $i_type --key-name $aws_key_name --security-group-ids $sec_id --subnet-id $sub_id --associate-public-ip-address --tag-specifications 'ResourceType=instance,Tags=[{Key=WatchTower,Value="$tag"},{Key=AutomatedID,Value="$uid"}]' | grep InstanceId | cut -d":" -f2 | cut -d'"' -f2)

# Log date, time, random ID
date &gt;&gt; logs.txt
#pwd &gt;&gt; logs.txt
echo $ec2_id &gt;&gt; logs.txt
echo ""

echo "EC2 Instance ID: $ec2_id"
#echo "Unique ID: $uid"
elastic_ip=$(aws ec2 describe-instances --instance-ids $ec2_id --query 'Reservations[0].Instances[0].PublicIpAddress' | cut -d'"' -f2)
echo -e "Elastic IP: $elastic_ip"
echo $elastic_ip &gt;&gt; logs.txt
echo "=====" &gt;&gt; logs.txt

#echo "Copy paste the following command from this machine to SSH into the AWS EC2 instance"
#echo ""
#echo -e "\e[32m ssh -i $ssh_key ubuntu@$elastic_ip\033[0m"
echo ""
countdown_timer=60
echo "Please wait while your instance is being powered on..We are trying to ssh into the EC2 instance"
echo "Copy/paste the below command to acess your EC2 instance via SSH from this machine. You may need this later"
echo ""
echo "\033[0;31m ssh -i $ssh_key ubuntu@$elastic_ip\033[0m"

temp_cnt=${countdown_timer}
while [[ ${temp_cnt} -gt 0 ]];
do
printf "\rYou have %2d second(s) remaining to hit Ctrl+C to cancel that operation!" ${temp_cnt}
sleep 1
((temp_cnt--))
done
echo ""

ssh -i $ssh_key ubuntu@$elastic_ip
</pre>
<p>&nbsp;</p>
<p><strong>Note | Disclaimer:</strong></p>
<p>-I build this very basic script to learn about aws cli (Probably the hard way :P).</p>
<p>-There are way more easier ways to achieve the same result using templates.</p>
<p>-The intention of this script was to learn about AWS CLI and in the future implement methods to control to which VPC/Subnet/IG/Security policy that an EC2 instance needs to be attached on the fly.</p>
<p>-This is strictly to be run on test environments and not for production.</p>
<p>-Terminate your EC2 instance and its resources after testing so that you do not get charged. If you are using the AWS Free tier and within the trial period, you should be fine.</p>
<p>Do let me know your feedback (Good / Bad)in the comments section down below.</p>
<p>Happy Cloud computing <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>The post <a href="https://techantidote.com/a-simple-bash-script-for-deploying-an-ec2-instance-in-aws/">A Simple Bash Script for deploying an EC2 instance in AWS</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techantidote.com/a-simple-bash-script-for-deploying-an-ec2-instance-in-aws/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2689</post-id>	</item>
		<item>
		<title>How to install AWS CLI in Linux +  Auto command completion</title>
		<link>https://techantidote.com/how-to-install-aws-cli-in-linux-auto-command-completion/</link>
					<comments>https://techantidote.com/how-to-install-aws-cli-in-linux-auto-command-completion/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Fri, 20 Jul 2018 17:39:21 +0000</pubDate>
				<category><![CDATA[aws]]></category>
		<category><![CDATA[Linux / Ubuntu]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[aws autocompletion]]></category>
		<category><![CDATA[aws cli]]></category>
		<category><![CDATA[awscli]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mint]]></category>
		<guid isPermaLink="false">https://techantidote.com/?p=2641</guid>

					<description><![CDATA[<p>This is a guide on how to install aws cli utlity in Linux along with screenshots. Requirements: &#8211; Linux. &#8211; Python 2.6.5 or higher. [Tested on Linux Mint with bash shell. should work on Ubuntu as well.] Update your system and its packages: sudo apt update &#38;&#38; sudo apt upgrade -y Install Pip: sudo apt &#8230; <a href="https://techantidote.com/how-to-install-aws-cli-in-linux-auto-command-completion/" class="more-link">Continue reading <span class="screen-reader-text">How to install AWS CLI in Linux +  Auto command completion</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://techantidote.com/how-to-install-aws-cli-in-linux-auto-command-completion/">How to install AWS CLI in Linux +  Auto command completion</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This is a guide on how to install aws cli utlity in Linux along with screenshots.</p>
<p><strong>Requirements:</strong></p>
<p>&#8211; Linux.<br />
&#8211; Python 2.6.5 or higher.</p>
<p>[Tested on Linux Mint with bash shell. should work on Ubuntu as well.]</p>
<p><span style="text-decoration: underline;"><strong>Update your system and its packages:</strong></span></p>
<pre>sudo apt update &amp;&amp; sudo apt upgrade -y</pre>
<p><span style="text-decoration: underline;"><strong>Install Pip:</strong></span></p>
<pre>sudo apt install python-pip -y
sudo pip install --upgrade pip</pre>
<p><span style="text-decoration: underline;"><strong>Install the following modules:</strong></span></p>
<pre>sudo pip install setuptools
sudo pip install wheel</pre>
<p><span style="text-decoration: underline;"><strong>Install AWS CLI:</strong></span></p>
<pre>sudo pip install awscli</pre>
<p>To verify that the installation went well, you can run the following command.</p>
<pre>aws --version</pre>
<p>If the output shows the aws version, then you are all set.</p>
<p><span style="text-decoration: underline;"><strong>Enable AWS commands Auto completion:</strong></span></p>
<p>-To enable auto completion of sub commands, run the following to check where your &#8220;aws&#8221; and &#8220;aws_completer&#8221; are located.</p>
<pre>which aws
which aws_completer</pre>
<p>-Copy the output of &#8220;which aws_completer&#8221;. This would the path.</p>
<p>For example, if the output of &#8220;which aws_completer&#8221; was &#8220;/usr/local/bin/aws_completer&#8221;, then enter the following:</p>
<pre>complete -C '<span style="color: #ff0000;">/usr/local/bin/aws_completer</span>' aws</pre>
<p>Heres a screenshot reference:</p>
<p><img fetchpriority="high" decoding="async" data-attachment-id="2673" data-permalink="https://techantidote.com/how-to-install-aws-cli-in-linux-auto-command-completion/aws-complete/" data-orig-file="https://techantidote.com/wp-content/uploads/2018/07/aws-complete.png" data-orig-size="530,132" data-comments-opened="1" data-image-title="aws cli" data-image-description="" data-image-caption="" data-large-file="https://techantidote.com/wp-content/uploads/2018/07/aws-complete.png" class="alignnone wp-image-2673 size-full" src="https://techantidote.com/wp-content/uploads/2018/07/aws-complete.png" alt="setup aws awscli aws_completer setup for bash" width="530" height="132" srcset="https://techantidote.com/wp-content/uploads/2018/07/aws-complete.png 530w, https://techantidote.com/wp-content/uploads/2018/07/aws-complete-300x75.png 300w" sizes="(max-width: 530px) 100vw, 530px" /></p>
<p><span style="text-decoration: underline;"><strong>Verify if AWS command auto completion works:</strong></span></p>
<p>-Run the following command and press press TAB on your keyboard after typing &#8220;ec&#8221; and it should give you the possible options:</p>
<p>aws ec</p>
<p><img decoding="async" data-attachment-id="2672" data-permalink="https://techantidote.com/how-to-install-aws-cli-in-linux-auto-command-completion/aws-command-compleion/" data-orig-file="https://techantidote.com/wp-content/uploads/2018/07/aws-command-compleion.png" data-orig-size="556,103" data-comments-opened="1" data-image-title="aws-command-compleion" data-image-description="" data-image-caption="" data-large-file="https://techantidote.com/wp-content/uploads/2018/07/aws-command-compleion.png" class="alignnone wp-image-2672 size-full" src="https://techantidote.com/wp-content/uploads/2018/07/aws-command-compleion.png" alt="aws awscli autocompletion installation on linux mint" width="556" height="103" srcset="https://techantidote.com/wp-content/uploads/2018/07/aws-command-compleion.png 556w, https://techantidote.com/wp-content/uploads/2018/07/aws-command-compleion-300x56.png 300w" sizes="(max-width: 556px) 100vw, 556px" /></p>
<pre><span style="text-decoration: underline;"><strong>Add path to your .bashrc or .bash_profile:</strong></span></pre>
<p>To make the changes persistant for aws command completion, you can add the following to your &#8220;.bashrc&#8221; or &#8220;.bash_profile.</p>
<pre>echo "complete -C ‘<span style="color: #ff0000;">/usr/local/bin/aws_completer</span>’ aws" &gt;&gt; ~/.bashrc</pre>
<p>Hope this helps! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>Regards,<br />
<strong>ΞXΤЯ3МΞ</strong></p>
<p>The post <a href="https://techantidote.com/how-to-install-aws-cli-in-linux-auto-command-completion/">How to install AWS CLI in Linux +  Auto command completion</a> appeared first on <a href="https://techantidote.com">Tech Antidote</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techantidote.com/how-to-install-aws-cli-in-linux-auto-command-completion/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2641</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: techantidote.com @ 2026-10-24 02:54:39 by W3 Total Cache
-->