EC2 Intro
- EC2 is IAAS(Infrastructure as Service)
- Provide access to virtual machine known as instance, an instance is an operation system
- EC2 is private AWS service, runs on private network zone
- EC2 is AZ resilient
- On-Demand billing
- 2 types of storages: local on-host storage and elastic block store
- Connect Windows EC2 instances on remote desktop protocol, on port 3389
- Connect Linux EC2 instances on SSH protocol on port 22
EC2 Instance Lifecycle
Once an instance is terminated, it is irreversible
When an instance is in running state, you will be charged on: disk, memory, CPU, networking
When an instance is stopped, you won’t be charged on: CPU, memory, networking, but you are still charged on disk because of storage
Relationship image(actually, an EC2 has more than these 3 states):
AMI(Amazon Machine Image)
AMI is an image of EC2 instance
AMI could be created from an EC2 instance, or be used to create an EC2 instance
AMI contains attached permission, deciding which accounts can and can’t use the AMI
- can be set as public, everyone can control
- can be set owner, only owner control it
- can be set explicit, add other AWS accounts to control it
AMI contains Root Volume, it is C drive in window. Drive to boot the operating system
AMI contains data Volume
AMI contains Block Device Mapping, determining which volume is root volume, which are data storage volume, mapping between volumes and operating system
Create and connect an EC2 Instance
Store key pairs once you created them, no second chance to get them
On your local system, you have to set permission on your local environment
connect EC2 instance using the key pair
S3(Simple Storage Service) Intro
Global storage platform
Regional based and regional resilient
Public service, but access can be private
Perfect for hosting large amount of data
Can be accessed via UI/CLI/API/HTTP
S3 = Object + Buckets
S3 Object
- Each object has an object key as identifier
- Each object has a value , represents the content being stored
S3 Bucket
Each bucket has a globally unique name(ex)
Bucket name should between 3-63 char, all lower case, no underscores(ex)
Bucket name starts with a **lowercase letter ** or a number(ex)
Bucket name can not be IP format e.g. 1.1.1.1(ex)
Bucket - 100 soft limit(only can have 100 buckets inside 1 account), **1000 hard per account(by increasing service you can have 1000 at most)(ex) **
Unlimited objects in bucket, can store infinite data
0 - 5TB data for largest object value(ex)
Object = key + value(ex)
One bucket is in a region
Bucket never leaves the region unless you ask
A bucket is infinitely scalable, it can hold infinite objects(not data, 5TB data at most)
It has a simple and flat structure, there is no folder in a S3 bucket and there is no file type in bucket
In bucket, folders are just prefix of the object names
S3 bucket structure diagram:
S3 Patterns and Anti-Patterns
- S3 is object store not file or block
- Can’t mount as drive
- Great for large scale data storage, distribution or upload, great for offload
- Should be default folder for input and output to many AWS products
Create S3 Bucket
Disable
Block all public access
, does not mean others could access the bucket without permission, it means: you can grant access to the publicAll resources in AWS has an unique identifier: ARN(Amazon Resource Name), same as for S3 bucket
when create a folder in S3 bucket, it does not really create a folder, instead, it create an object in /
name when create a file named
A.jpg
inside a folder namedarchive
, actually S3 does is to create a object namedarchive/A.jpg
to simulate the structurebefore **delete ** a s3 bucket, first we need to empty it