S3 Buckets

Authors
  • avatar
    Name
    Michael Bui
    Twitter

Overview

Documentation: AWS docs

Buckets are containers for storing data objects in AWS. In this lab, we'll go through a few of the settings available with S3 buckets.

We'll look at:

  • Creating a bucket
  • Allowing object versioning
  • Setting bucket access
  • Lifecycle rules

Creating a Bucket

  1. Navigate to S3 -> Create Bucket
  2. Provide a name that is unique across all AWS
  3. Decide on public access rules
  4. Enable / disable versioning
  5. Decide on encryption - (Server-side encryption means that data is encrypted at rest in the bucket)

Versioning

When you enable versioning S3 keeps a copy of past versions.

  • To see past versions press on show versions
  • You can also click on the object and select versions to see past versions

Access Permissions

You can set policies to decide how objects in the bucket can be accessed.

We're going to allow public anonymous access to only read the objects in our bucket.

  1. Under permissions edit the bucket policy
  2. Create a policy using the policy generator here
  3. Choose s3 policy for policy type
  4. Select allow and the * wildcard for everyone
  5. We're going to select s3:GetObject and s3:GetObjectVersion to get the objects from the bucket
  6. Apply the policy
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PublicRead",
      "Effect": "Allow",
      "Principal": "*",
      "Action": ["s3:GetObject", "s3:GetObjectVersion"],
      "Resource": "arn:aws:s3:::builab-bucket/*"
    }
  ]
}

Lifecycle

You can create lifecycle rules for all objects inside the bucket or based on prefixes, tags, or object size.

  1. Navigate to management to configure lifecycle rules
  2. Setting a rule scope - here we're going to only apply the rule to certain objects
  3. Set filters to apply to items - we'll apply this rule to objects with the documents prefix
  4. Select what you want to do to the objects
  5. Select where to move the items
  6. Now items inside the documents prefix (folder) will be placed in glacier deep archive after 15 days