<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Carolyn J. Jankowski on Medium]]></title>
        <description><![CDATA[Stories by Carolyn J. Jankowski on Medium]]></description>
        <link>https://medium.com/@carolynjjankowski?source=rss-8be65b78c9a3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*DQsFcBDY0nlB33ji.</url>
            <title>Stories by Carolyn J. Jankowski on Medium</title>
            <link>https://medium.com/@carolynjjankowski?source=rss-8be65b78c9a3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 07:40:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@carolynjjankowski/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Using AWS to Untar a File and Transfer Files from EC2 to an S3 Bucket]]></title>
            <link>https://medium.com/@carolynjjankowski/using-aws-to-untar-a-file-and-transfer-files-to-an-s3-bucket-e24384045515?source=rss-8be65b78c9a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/e24384045515</guid>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Carolyn J. Jankowski]]></dc:creator>
            <pubDate>Wed, 13 Jun 2018 13:55:54 GMT</pubDate>
            <atom:updated>2018-06-13T14:15:56.492Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, I will outline the steps necessary to load a file to an S3 bucket in AWS, connect to an EC2 instance that will access the S3 file and untar the file, and finally, push the files back to S3.</p><ol><li><strong>Download the Yelp dataset</strong>. For purposes of this blog, I am downloading this locally to my laptop, however it is also possible to use the command wget &lt;path for file&gt; in the command line and download the file directly to EC2 once you are connected.</li></ol><p>2. <strong>Create an S3 bucket and upload the tar file.</strong> Go to the S3 section of AWS and create a bucket by giving it a unique name. Once your tar file has completed its download, upload the file to the S3 bucket you just created. Depending on the size of the file, this may take a few minutes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PBz4m68ChSubPYKV4WGUTA.jpeg" /></figure><p><strong>3. Create a role for EC2 instance to have full S3 access privileges.</strong> In the IAM console, select “Users” and “Create Role”. Select your use case. Here, we will select “EC2” and click “Next Permissions”. In the search box, type in S3 to find predefined roles. Select “Amazon S3 Full Access” and click “Next”. Enter a name for your role and click “Create Role”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jD6n6RosZXkEEfk5H1aDHw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7GhwxE8c0jH1VUetuOUGhg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o-M_Ktvu6ifZJNhqqMBcHw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YFWqxyhY1f-v6JnZIezFDQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-H8CcLRcY1Hl8jCCQMxgmA.jpeg" /></figure><p><strong>4. Create EC2 instance and assign the role for the S3 bucket to this instance.</strong> Log into the EC2 console and create an instance. I used a Redhat Linux Server and the t2 micro tier which are both free tier eligible. Prior to launching your instance, be sure to attach the IAM role created in the previous step to this instance, then launch. Once your instance has launched, click the “Connect” button at the top of the screen and note the SSH command. This will automatically create the command required with your key pair and instance id.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b-cCYZgJNVBjvYvuIxqwLQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*d7gMftEtYVhactylpsC_Tg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*S9aoigYg7BXHNs6QdF1Qkg.jpeg" /></figure><pre><strong>ssh -i &quot;Remi.pem&quot; ec2-user@ec2-18-207-227-93.compute-1.amazonaws.com</strong></pre><p>5. <strong>Navigate to the folder where your PEM file is located in order to SSH to your EC2 instance. </strong>Enter the SSH command above to connect to your EC2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*WrqxGwW_Z9ICRmViDQg2Iw.jpeg" /></figure><p><strong>6. Install PIP.</strong> Once connected, run the following command to get the current version of pip to install to your server:</p><p>$ <strong>curl -O </strong><a href="https://bootstrap.pypa.io/get-pip.py"><strong>https://bootstrap.pypa.io/get-pip.py</strong></a></p><p>Next, run the following python command:</p><p><strong>python get-pip.py --user</strong></p><p>Add an export command to your profile script:</p><p>export PATH=<em>~/.local/bin</em>:$PATH</p><p>Load the profile into your current session</p><p><strong>source ~/</strong><strong><em>.bash_profile</em></strong></p><p>check your pip installed correctly.</p><p><strong>pip --version</strong></p><p><strong>7. Install the AWS CLI using pip:</strong></p><p><strong>pip install awscli --upgrade --user</strong></p><p>Check the aws version:</p><p><strong>aws --version</strong></p><p>Add the AWA executable to your OS Path environment variable:</p><p>~/.local/bin</p><p>Finally, check the bin folder:</p><p>$ <strong>which python</strong></p><p><strong>8 . Create a folder on your server where you will store the tar file.</strong> I named mine s3.</p><p><em>Note: As a best practice, you should not download files directly to your root, so it is best to create a directory to hold your tar file.</em></p><p><strong>9. Sync your S3 folder to the EC2 instance.</strong> Enter the following command you copied earlier:</p><p>aws s3 sync s3://yelpcjc<em>/</em>/ home/ec2-user/s3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*vYBzcTvdxBVqOLj3UeY1kQ.jpeg" /></figure><p>Please note you will need to enter in your own bucket name and then the directory the file will be directed to on EC2.</p><p>When using the command line, it is important to understand that there is a “source” and a “destination”</p><p>In this case, the source is <strong>aws s3 sync s3://yelpcjc<em>/</em>/</strong></p><p>And the destination is <strong>home/ec2-user/s3.</strong></p><p>When entering this command, you must ensure there is a space between the source and the destination or your command will not execute.</p><p><strong>10. Run the ls command in the folder to check for its contents. </strong>You should see the file there as a tar file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*8x0oNnbGkvtURZPAwkJyoA.jpeg" /></figure><p><strong>11. Untar the file.</strong> To untar the file, run the following command:</p><p>tar xvf yelp_dataset.tar</p><p>The xvf stand for extract, verbose and filename. When the command executes, a directory is created called “dataset” which will contain the unpacked files. You can ls into that folder to verify the contents exist.</p><p><strong>12. Run the sync command to transfer the files to S3 remembering to switch the location of the source and destination.</strong> In this case, our source is the EC2-user and the destination is the s3 bucket:</p><p>aws s3 sync /home/ec2-user s3://<em>yelpcjc</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*WAvW0JxO835slKmRF-zSQQ.jpeg" /></figure><p>Again, depending on the size of the file, this may take a few minutes. The transfer will be complete once you see the instance prompt return.</p><p><strong>13. Finally, check the S3 bucket to ensure the contents have been transferred.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q7bXuShzKeejwSR-IF4Udw.jpeg" /></figure><p><strong>14. Do not forget to disconnect the EC2 instance and delete the bucket at the end of this assignment.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e24384045515" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>