Lec 4: Storage Flashcards
When a bucket is created, AWS provides features that can be managed. List and describe 5 key features.
Bucket versioning: keeps multiple versions of an object in the same bucket.
Tags: are key-value pairs that provide customized label to track costs from buckets.
Default Encryption: All objects uploaded to the bucket will be automatically encrypted using one server-side encryption.
Object Lock: prevent objects in a bucket from being deleted or overwritten for a fixed amount of time or indefinitely.
Server access logging: provides records for the requests that are made to a bucket.
Describe how S3 handles consistency of objects and how this approach affects the state of objects when they are read using a GET.
S3 deliversstrong read-after-write and list (i.e., GET, PUT and LIST operations) consistency automatically. Specifically, what a user write is what they will read, and the results of a LIST will be an accurate reflection of what’s in the bucket.
When GET is used to read an object, the read request immediately receives the latest content of the object.
You are asked to store data about music in a local DynamoDB table. Specifically, you need to record the artist name and their song names. Describe the AWSCLI commands you would use to create a table to store such information and write entries to that table.
From a terminal:
mkdir dynamodb; cd dynamodb
install jre if not done (sudo apt-get install default-jre)
wget https://s3-ap-northeast-1.amazonaws.com/dynamodb-local-tokyo/dynamodb_local_latest.tar.gz
tar -zxvf dynamodb_local_latest.tar.gz
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar –sharedDb
To create the table:
aws dynamodb create-table –table-name MusicAlbum
–attribute-definitions \
AttributeName=Artist,AttributeType=S \
AttributeName=Song,AttributeType=S \
–key-schema AttributeName=Artist,KeyType=HASH \
AttributeName=Song,KeyType=RANGE \
–provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 \
–endpoint-url=http://localhost:8000
Create table:
aws dynamodb create-table –table-name MusicAlbum
–attribute-definitions \
AttributeName=Artist,AttributeType=S \
AttributeName=Song,AttributeType=S \
–key-schema AttributeName=Artist,KeyType=HASH \
AttributeName=Song,KeyType=RANGE \
–provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 \
–endpoint-url=http://localhost:8000
Creates a table named “MusicAlbum” with two attributes (“Artist” and “Song”),
Sets up “Artist” as the partition key and “Song” as the sort key,
Assigns provisioned throughput capacity of 1 read capacity unit and 1 write capacity unit,
Connects to a DynamoDB instance running locally on http://localhost:8000.
Create items:
aws dynamodb put-item \
–table-name MusicAlbum \
–item \ ‘{“Artist”: {“S”: “Tom”}, “Song”: {“S”: “Call Me Today”}}’\
–return-consumed-capacity TOTAL –endpoint-url=http://localhost:8000
aws dynamodb put-item \
–table-name MusicAlbum \
–item ‘{“Artist”: {“S”: “Jerry”}, “Song”: {“S”: “Happy Day”}}’ \
–return-consumed-capacity TOTAL –endpoint-url=http://localhost:8000
Insert two items with values of the attributes,
Request information about the consumed capacity for the operations,
Specify a local DynamoDB for the connection.
Querying:
aws dynamodb query \
–table-name MusicAlbum \
–key-condition-expression “Artist = :artist” \
–expression-attribute-values ‘{“:artist”:{“S”:”Tom”}}’ \
–endpoint-url=http://localhost:8000
Queries the “MusicAlbum” table for items where the “Artist” is “Tom”.
‘artist’ works as a placeholder and can be changed by other word.
Scan:
aws dynamodb scan \
–table-name MusicAlbum \
–endpoint-url=http://localhost:8000
Outputs the whole table
What will the table be like if we create the first item with 3 attributes and the second item with 2 attributes?
Cell will be empty for the missing attribute for the second item
What does the code snippet do (slide 27)
This policy allows two operations to the bucket named “cits5503-123456-lecture” and its contents from IP addresses within the “192.0.2.0/24” range. This range covers all IP addresses from 192.0.2.0 to 192.0.2.255, inclusive.
What does 192.0.2.0/16 mean?
What is a cloud storage? Give examples.
Cloud storage, provided by a third-party cloud provider allows customers to store and access data over the internet.
Examples: Dropbox, Google drive, iCloud, Amazon S3
What is Amazon S3 (Simple Storage Service)?
It is a popular and widely used cloud storage service provided by AWS
It allows users to store and retrieve any amount of data at any time over the internet
Involved buckets and objects
Steps of creating a bucket in Amazon S3
- General configuration: bucket name, AWS region
Bucket name must be unique within the global namespace.
Bucket names must be unique across all AWS accounts in an AWS partition. A partition is a grouping of AWS Regions. AWS has three partitions:AWS(Standard Regions),AWS CN(China Regions), andAWS-US-Gov(US Gov Regions).
It must follow the bucket naming rules.
- Specify object ownership
-ACLs: access control lists
-ACLs: disable (recommended) or enable
*Bucket ACLs are old access-control mechanism for buckets. - Block (all) Public Access settings for this bucket
- Bucket versioning: disable / enable
- Tags (add)
- Default encryption: encryption type (SSE-S3, SSE-KMS, DSSE-KMS), bucket key: disable / enable
- Object lock: disable / enable
- Click create bucket
What are the rules for bucket naming?
The following rules apply for naming buckets in Amazon S3:
Bucket names must be between 3 (min) and 63 (max) characters long.
Bucket names can consist only of lowercase letters, numbers, dots (.), and hyphens
Bucket names must begin and end with a letter or number.
Bucket names must not contain two adjacent periods.
Bucket names must not be formatted as an IP address (for example, 192.168.5.4).
Bucket names must not start with the prefix xn– .
Bucket names must not start with the prefix sthree- and the prefix sthree-configurator
Bucket names must not end with the suffix -s3aIias . This suffix is reserved for access point alias names.
What is an object?
-It is an individual unit of data stored in a bucket
Can be a file of any type: documents, images, videos, etc
It contains both data and metadata:
-Data refers to file contents. Metadata include file attributes.
-e.g., a file called sunset.jpg is uploaded into a bucket.
How to identify an object? object key + version ID (if enabled)
Object key is a string specifying the object’s location and name, e.g., cits5503-123456-lecture/subdir/sunset.jpg
Version ID: denotes a specific version of an object, e.g., v1AbCdEfGhIjKlMnOpQrStUvWxYz1234567890
A combination of an object key and version ID uniquely identifies a specific version of an object in a bucket.