Sunday, 18 May 2014

How to work with S3 using the AWS Toolkit in Eclipse

This is another in a series of videos that I am producing for my YouTube channel HowDoYouDoStuff.


In this video, I am going to show you how to work with S3 using the AWS Toolkit in Eclipse


You can read the transcript below.


HTML 5 Player



Transcript

Hi guys. I'm Phil Stirpe.

In this video, I am going to show you how to work with S3 using the AWS Toolkit in Eclipse.

In an earlier video I showed you how to install the AWS Toolkit into Eclipse and associate it with an IAM user I created earlier.

In fact if I go into the menu and select preferences, you can see that with already configured Eclipse to identify itself as an IAM user called Frank when connecting to Amazon web services. This involves using the user’s access key and secret key.

In the AWS Explorer window in Eclipse you can see a number of AWS services that you can work with. They are the services it is assumed you might work with when working in Eclipse.

In this video I want to work with S3 so let me just expand that node.

The very fact that I can see some buckets listed, proves that Eclipse has been authenticated by Amazon web services and that the AWS user account has privileges to access S3.

In this video I’m not going to show how to use SDK to interact with S3 using code, rather I want to show how you might use S3 as a developer within Eclipse. For example the creation of buckets and copying of files.

Let me begin by creating a bucket.

A right click the S3 node and select create new bucket.

I want to call this bucket demobucket. Now have to be careful because bucket names must be globally unique as you can see that name is already taken.

Let me try adding a hyphen and calling it demo-bucket. No that’s also in use.

Let me try qa-demo-bucket. That’s okay.

So that’s a thing to remember. This is not an Eclipse thing or and AWS toolkit thing, it’s an S3 thing.

I’ll click the Finish button and now I have a bucket.

It may well be that when you’re working in Eclipse you need an S3 bucket is not worth the effort to write code to create one. As you have seen you can use simple right click to create one.

Now that created a bucket in Eclipse, let’s look at something else I might want to do. I might simply want to upload some files into a bucket whilst I’m working away in Eclipse.

Well I can just do that with a drag and drop.

If I open up Windows Explorer, I can just drag a file onto a bucket in the AWS Explorer window and the AWS toolkit will take care of the upload for me.

The AWS toolkit prompts me for a keyname. I’m actually uploading a file S3 uses a mechanic of a keyname. The keyname can be the same as the filename although doesn’t have to be.

So I’ll just accept the file name as a keyname and click OK to upload the file.

If I want to view the file in the bucket within Eclipse I just need to right click the bucket name and select Open in S3 Bucket Editor.

When that window opens we can see the item in the bucket.

You can see the keyname and also the owner. Interestingly although eclipses connecting to Amazon web services using an IAM user called Frank, this field is actually showing the root account name which happens to be Phil Stirpe.

Window also shows that we using S3 standard storage rather than reduced redundancy storage. The storage class is not something that we can modify in this window.

Another thing I can do in this window is select the key and edit the bucket ACL or access control list.

This is one way of managing permission. I.e. you could use access control lists rather than IAM policies. In fact you could use a combination.

I don’t want to use access control lists so I’ll just cancel that dialog.

As I have assigned any privileges, no one should be able to access this file. Unless is the root account or an IAM user with full privileges to access S3.

Let me just show you this file in the AWS console.

The reason I have come here is so that I can right click the file and select properties. One of the properties is a URL that could publish and share with users in order to locate it. This URL isn’t available within Eclipse.

If I copy that URL and then open and incognito window. By the way I’m doing this because I already have another window open and authenticated with Amazon web services in it.

If I try to navigate using that URL you will see that I get an access denied.

Clearly there is a file up there and we got it there via Eclipse. By default S3 prevents any access.

Here’s something we are able to do in Eclipse. We can right click the file or key and select Generate Pre-signed URL. At the same time you can specify an expiry date and time for the URL. So I’ll try publishing a URL that will expire in an hour’s time.

So I’ll copy the new URL into the clipboard and switch back to the browser and try that in the address bar instead. As you can see the URL includes an expiry time and an access key.

When I press enter, I now retrieve the file from S3.

Now there are lots of things that might want to do with S3 but the I’m just focusing on those simple tasks carry out within Eclipse using the AWS toolkit. What we’ve been able to do with the AWS toolkit is create a bucket, drag a file into the bucket. And if I can drag a file in, I could easily delete it.

I’ve also shown how create a Pre-signed URL to give users temporary access to a file in S3.

As I said start this video, I’m just focusing on those management tasks that you can perform in Eclipse rather than what we might be able to achieve using the SDK programmatically. That would be material for another video.

There you have it.

In this video, I have shown you how easy it is to work with S3 using the AWS Toolkit in Eclipse.

Thanks for watching and please feel free to comment on my blog (www.philipstirpe.com) and Facebook page (www.facebook.com/philip.stirpe.tutorials). Perhaps you could suggest more video topics? Most of all, don't forget to subscribe to keep up with my videos as I release them.

Bye for now.





Flash Player








See you soon

Phil Stirpé
"I don't do average!"






7 comments: