Lab3_S3-1

docx

School

Northern Kentucky University *

*We aren’t endorsed by this school

Course

285

Subject

Computer Science

Date

Apr 3, 2024

Type

docx

Pages

4

Uploaded by Lukem11568

Report
CIT 438 Cloud Computing Lab#03: AWS S3 In this lab, you will study the Amazon S3. You will use the aws s3 and s3api commands to manage data in Amazon S3. Tools and Materials 1. One CentOS VM on the vSphere servers. 2. Amazon AWS security credentials 3. Aws CLI Note: You need to replace words in italics with your information. Part 1: Basic Operations with S3 Start your VM image on the vSphere server. Log in as cit438 with password cit438. Please su to root in a terminal (the password is cit438). Assume your current directory is /home/cit438. 1. List all buckets owned by the user via the ls command. aws s3 ls What is the output? No output popup up 2. Make a bucket via the following mb command: aws s3 mb s3:// your_user_name What is the output? make_bucket: Lukem1 3. List the contents of the bucket via the following ls command: aws s3 ls s3:// your_user_name What is the output? no output 1
4. Create a directory named webpages. Go to the webpages directory. Use vi or other text editor to create a simple html file called hello.html. The content of the file is as follows: <html><body><h1>Amazon S3</h1> Hello World! </body></html> Upload the file into the bucket and make the file available to the public via the following command: I was hoping to get an updated lab from Dr. Hao in Week 4 but that was not possible so I am going with the workaround from last semester. Amazon has made a change to the way S3 ACL's work. You will get "The bucket does not allow ACLs" or something similar. We are basically removing a protection that would allow anyone who knew the bucket url to access files in the bucket. This is dangerous in real world situation so keep that in mind. This has led to many incidences of personal data being found on the internet. Below are the commands to allow. aws s3api put-public-access-block --bucket <you-user-name> --public-access-block-configuration 'BlockPublicAcls=false,IgnorePublicAcls=false,BlockPublicPolicy=false,RestrictPublicBuckets=false' aws s3api put-bucket-ownership-controls --bucket <your-user-name> --ownership-controls 'Rules=[{ObjectOwnership="BucketOwnerPreferred"}] ' aws s3 cp hello.html s3:// your_user_name --acl public-read What is the output? upload: ./hello.html to s3://Lukem1/hello.html 5. Amazon S3 is object storage over the Internet. The S3 object is accessible over the Internet. Open a browser and access to http://s3.amazonaws.com/ your_user_name /hello.html. What did you see in the browser? Part 2: Static Website Hosting with S3 6. Let’s enable the bucket for static website hosting. Create two html files under the current directory. One file is named index.html. Its content is as follow: <html><body> This is an index page! </body></html> 2
The other file is named error.html. Its content is as follow: <html><body> Sorry, we can't find that page! </body></html> The sync command compares the source directory with your S3 bucket and uploads only new or changed files. Please upload the file via the following command: aws s3 sync ./ s3:// your_user_name / --acl public-read What is the output? upload: ./index.html to s3://Lukem1/index.html upload: ./error.html to s3://Lukem1/error.html The following is how to enable the bucket for static website hosting: aws s3 website s3:// your_user_name / --index-document index.html --error-document error.html Open a browser and access to http:// your_user_name .s3-website-us-east-1.amazonaws.com/ . What did you see in the browser? Why? in a browser would display the content of index.html: "This is an index page!" This happens because you've set index.html as the index document for the bucket. Access to http:// your_user_name .s3-website-us-east-1.amazonaws.com/hello.html . What did you see in the browser? would display the content of hello.html if it exists and was uploaded earlier: "Amazon S3 Hello World!". Access to http:// your_user_name .s3-website-us-east-1.amazonaws.com/2.html . What did you see in the browser? Why? "Sorry, we can't find that page!" This is because 2.html does not exist, and error.html is set as the error document. 7. Create a web page redirection rule and add metadata to an object via the following s3api command: aws s3api put-object --bucket your_user_name --key hello.html --website-redirect-location http://www.nku.edu/~haow1 --acl public-read --metadata redirection_creator=cit438 Access to http:// your_user_name .s3-website-us-east-1.amazonaws.com/hello.html . What did you see in the browser? Why? http://your_user_name.s3-website-us-east-1.amazonaws.com/hello.html would redirect the browser to http://www.nku.edu/~haow1. This demonstrates how S3 can handle simple redirects for objects. 8. Retrieve an object’s metadata via the following: aws s3api head-object --bucket your_user_name --key hello.html 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
What is the output? The output includes headers and values like the object's last modified date, size, and any set custom metadata. Part 3: Cleanup 9. Remove an object, the index page, via the following command: aws s3 rm s3:// your_user_name /index.html What is the output? delete: s3://Lukem1/index.html 10. Remove the bucket via the following: aws s3 rb s3:// your_user_name --force What is the output? remove_bucket: Lukem1 Submission instruction After completing this work, submit this word document with your answers to the Canvas. In your word document, your answers should be in bold print. At the end of your word document, you should write a few sentences that explain the goals of this lab and a paragraph or two that summarizes (high level) the steps one needs to take in order to complete those goals. the primary goals were to familiarize participants with the basic functionalities of Amazon S3 (Simple Storage Service), including bucket creation, file upload/download, setting public access permissions, enabling static website hosting, and managing object metadata and ACLs (Access Control Lists). Additionally, the lab aimed to impart practical skills in using the AWS CLI (Command Line Interface) for interacting with AWS services, which is an essential tool for managing AWS resources. 4