HW5
Step 1:
- Go to AWS.com click top right create an AWS Account.
- regesiter with your school or personal email, choose basic support plan
Step2(after regesiter) Apply credit:
-
Login as Root User with your email!
-
Then you should see the console dashboard
-
On the Top right of the user name, click and there should be a drop down menu
-
click Billing dashboard
-
click credit on the left menu and then click redeem credit to apply credit and this where we can add our credit
Billing Preference:
- Click Billing Preference in the Billing Dashboard
- Click Alert Preferences
optional Choose Receive AWS Free Tier alerts , enable Receive CloudWatch billing alerts and click update:
- check and update invoice deilvery preferences by email
Create Alarms:
- in search bar serch Cloudwatch
- in the Overview page, click ‘Create alarms’
- on top right, click region list and set to ohio
- Change region to to virgina
- click create alarm
and then select Metric
- in select metric page
select Billing
and then select Total Estimated Charge
select USD
and then select metric
- In the Specify metric and condition page, make sure set the condition and the period, then in the condition, set the threshold for the charge
This would notice you when threshold value is exceed. Then click next
- Add notification, choose new topic, add an email for notification and then create topic
you should recive an email
- after hit next, set the Alarm name and description
- hit next, and you should have a report of everything your set up
Check and create alarm
- Now we have the alarm
Note: East Coast is always cheaper!!!
AWS S3, EC2 and CLI:
Key word note: S3 is an object storage that we can store data:
- Object - Data(files)
- Object Keys - A unique identifier for an object
- Bucket - A container for object
- Bucket Policy - create rule for access
- Top left search S3 and click it
note: S3 is Global
- Click create bucket
, create bucket name and select ACLs disabled, block all access, disable the versioning. and then create bucket
- Once create bucket you should able to unload/create folder to place the file in the bucket,
- Bucket Permission able to grant access to the other users
- click edit bucket policy to edit the Permission
- Add resource to select bucket
- set condition for specific user etc
- click edit bucket policy to edit the Permission
- Upload:
- drag the file into the upload page and the upload
- click the specific object in the bucket, we would able to see the
- URI: Where the file located at.
- ARN: permission informations
- drag the file into the upload page and the upload
EC2:
EC2
EC2
Defination:
Elastic Compute Cloud
instance lifecycle: launch, pending, rebooting, running,stopping, stopped,terminate
Link to original
- Launch EC2:
- search EC2, click instance on left Menu, then launch instance
- create the instance with the name and tags. select the type of instance we need and os system.
Key pair is important for validate the user’s shh to AWS account
it will generate a pem file and make sure save the ssh key in a secure folder.
- after launch the instance, we should able to see the instance in the instance page
- Click ID and it will give the information for the current instance
- click security button, we can change the security rule in Security groups
- Edit inbound Rule and Outbound Rule
- AWS Key and Secret Access Key:
- in the search bar search key word IAM
- Add user name from the user page:
it allow us to add multiple user use resources
- set permissions for the user
then we can create user
- once user create, we can check user security credentials by click user’s name
, at here we can create access key for the user
. save the access key and security key
- AWS CLI:
- go to this link https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html and download Command line installer for Mac. Follow instruction, copy the download code into command script
- use AWS CLI:
- configure CLS output by use aws configure function then enter the access key and secret key created earlier
- configure CLS output by use aws configure function then enter the access key and secret key created earlier
- go to this link https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html and download Command line installer for Mac. Follow instruction, copy the download code into command script
- access server
- SSH method access EC2
- Change permission to read and write for the pem file download from the AWS earlier and then in the terminal type ssh -i filelocation and the use the instance ip locaiton as the ec2 user name
exit to get out ec2 server
- Change permission to read and write for the pem file download from the AWS earlier and then in the terminal type ssh -i filelocation and the use the instance ip locaiton as the ec2 user name
- CLI method:
- in the teminal type aws ec2-instance-connect ssh —instance-id(instance id) —private-key-file (ssh pem file)
- in the teminal type aws ec2-instance-connect ssh —instance-id(instance id) —private-key-file (ssh pem file)
- SSH method access EC2
Load data to EC2:
- once login EC2 in terminal do curl -O https://bootstrap.pypa.io/get-pip.py, then wrong the get-pip.py file
then pip install boto3, boto3
- create.py file:
- vi hw5.py
- then use bucket name and key name from s3
- connect ec2 to s3
- aws configure (access key and secret key)
- aws configure (access key and secret key)
- execute it by python3 hw5.py
- print the content, use [‘Body’].read from boto3
Empty bucket then delete bucket
Key words:
- instance: Where the computing is done, we can choose various instance types with different CPU, memory etc…
- we can use ssh to the instance
- we need to configure our instance including user permission and security group to open/close certain port