Creating a S3 bucket

Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance. This means customers of all sizes and industries can use it to store and protect any amount of data for a range of use cases. Amazon S3 provides easy-to-use management features so you can organize your data and configure finely-tuned access controls to meet your specific business, organizational, and compliance requirements. Amazon S3 is designed for 99.999999999% (11 9’s) of durability, and stores data for millions of applications for companies all around the world.

You can read more about S3 here, including information about the different storage tiers and pricing.

Create an S3 Bucket for the workshop

We will use S3 in this workshop as a way to store files but also as an easy way to transfer files from your machine for use on AWS. To start, go to the S3 console by searching for S3 in the top search bar. You’ll then see a list of all your buckets. This will be empty if you’ve never used AWS before. You can see in the example below that buckets are globally accessible (notice the global region selection in the top right corner of the console) but are based in a particular region e.g Ireland (eu-west-1).

cloud9-1

Click on “Create Bucket” and enter a unique name that you will use for this workshop. Note that this name must be unique in a namespace that is shared by all AWS accounts. Incorporating your initials into the name can help to make it unique. Remember to pick the region that you’ll use for the rest of the workshop i.e Ireland (eu-west-1).

cloud9-1

Upload a File to S3 using the S3 console

Once created, select the bucket name and upload a file from your computer (for use with your particular code in the later sections).

cloud9-1

cloud9-1

cloud9-1

Access S3 from the Command Line Interface (CLI)

Whilst you can upload and download files from S3 using the GUI, many users may wish to do this from the command line. This is also the recommended method for files above 10GB. The Amazon Command Line Interface (CLI) tools can be installed on any machine, whether it’s Windows, Linux or Mac, and you can read how to do this here.

However, AWS recently released AWS CloudShell which is a browser-based shell that makes it easier to securely manage, explore, and interact with your AWS resources. CloudShell is pre-authenticated with your console credentials. Common development and operations tools are pre-installed, so there’s no need to install or configure software on your local machine. With CloudShell, you can quickly run scripts with the AWS Command Line Interface (AWS CLI), experiment with AWS service APIs using the AWS SDKs, or use a range of other tools to be more productive.

To begin, just click the CloudShell symbol (shown with the red circle) on any AWS page you’re on. This will load your own cloudshell session (which is confined to your particular region e.g the files you created in cloudshell within Ireland isn’t accessible in N.Virginia, however as we’ll show you can use S3 from any cloudshell session).

cloud9-1

From the command line, just type the following command, which will list all of your S3 buckets. You should see the name of the bucket you created previously.

 aws s3 ls

Next lets check the contents of the bucket, replace the word “bucketname” with the name of the bucket created previously.

 aws s3 ls s3://bucketname/

You should be able to see the file you uploaded previously. Now lets do a quick demonstration of how you can upload to and download from a S3 bucket using the CLI.

Firstly lets create a sample file using the command below.

 echo 'test' > test.txt

We can then upload this file to your bucket by using the following command:

 aws s3 cp test.txt s3://bucketname/

You can check if it’s there by typing:

 aws s3 ls s3://bucketname/

You can now copy it back using the following command:

 aws s3 cp s3://bucketname/test.txt .

You can check that this file is in the bucket by following the guide at the beginning of this page.

We are using AWS CloudShell in this example but if you install the CLI tools on your own machine, you can use these commands to copy back and forth files in the same way.