Categoryaws

Query data stored in an S3 bucket with AWS Athena

glue-athena

Note: I’m assuming that you’re an IAM user with admin access.

 Adding some data to an S3 bucket.

The data format we will be using for this example is a CSV. Below is a sample of the data and how it’s structured, nothing complicated.

Our bucket path will be:

 Creating a table and schema in AWS Athena

Head over to the Athena dashboard and lets create a new table manually. We will be going through the creation wizard. I will provide screenshots along the way. Note that we will also be creating a database along with our table. See step 1.

Lets kick things off.

Screen Shot 2018-03-08 at 5.42.14 PM

Step: 1

Screen Shot 2018-03-08 at 5.53.46 PM

Step: 2
Since we are working with CSV files we select the appropriate date format.

Screen Shot 2018-03-08 at 10.08.08 PM
Step: 3
This is were we define our schema for our data. The screenshot below gets cut off but just add all four columns and all of type string.

Screen Shot 2018-03-08 at 10.37.58 PM

Step: 4
Don’t worry about add partition section, this is a whole other topic to discuss. For now just click on create table.

Screen Shot 2018-03-08 at 10.41.03 PM

 

Adding additional profiles to AWS CLI

I use AWS Shell which is an integrated shell for working with the AWS CLI.

Navigate to ~/.aws/ on a mac. If you are on a windows, you will need to google the path. In this directory you will see .credentials and .config.

Open .credentials in your editor and you should see something like below.

If you already use the AWS CLI then you should already have a default profile with your tokens. Below we have added a new profile user2

You will also need to update .config with the below contents, yours may vary.

Now load the new named profile. For more information about named profiles.

 

 

© 2018 Aldomatic

Theme by Anders NorenUp ↑