Lab 5 Storage
Lab 5 Storage
[version_1.0]
©2021 Amazon Web Services, Inc. and its affiliates. All rights reserved. This work may not be
reproduced or redistributed, in whole or in part, without prior written permission from Amazon
Web Services, Inc. Commercial copying, lending, or selling is prohibited.
Errors or corrections? Contact us at https://support.aws.amazon.com/#/contacts/aws-training
Exercise: Storage
The exercises are designed to be completed in your AWS account, and will have an associated cost.
For this reason, in addition to the written instructions, this course includes video recordings of the
exercises. If you intend to attempt the exercises, familiarize yourself with AWS pricing, specifically
Amazon EC2 pricing, Amazon S3 pricing, and Amazon DynamoDB pricing and the AWS Free Tier.
For this scenario, you will create the S3 bucket where the employee photos will be housed. You
will also update the EC2 User Data to use the S3 bucket you create.
In this exercise, you will create a S3 bucket and upload some objects. Then, you will modify the
bucket policy and launch an EC2 instance. Finally, you will stop the EC2 instance to prevent future
costs.
Lab Steps
Stage 1 - Create an S3 bucket
1. Search for S3 in the search bar at the top. Choose S3.
2. Choose Create bucket.
3. For the Bucket name name it employee-photo-bucket- then use your initials and a unique
number.
Example:
employee-photo-bucket-al-007
4. Make sure the Region is the region where you have created the other services. Again, this
can be found at the top right.
5. Choose Create bucket.
https://aws-tc-largeobjects.s3-us-west-2.amazonaws.com/DEV-AWS-MO-GCNv2/lab-5-storage.html 1/4
02/10/2021, 15:17 lab-5-storage
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowS3ReadAccess",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<INSERT-ACCOUNT-
NUMBER>:role/S3DynamoDBFullAccessRole"
},
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::<INSERT-BUCKET-NAME>",
"arn:aws:s3:::<INSERT-BUCKET-NAME>/*"
]
}
]
}
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowS3ReadAccess",
"Effect": "Allow",
"Principal": {
"AWS":
"arn:aws:iam::000000000000:role/S3DynamoDBFullAccessRole"
},
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::employee-photo-bucket-al-007",
"arn:aws:s3:::employee-photo-bucket-al-007/*"
]
}
]
}
https://aws-tc-largeobjects.s3-us-west-2.amazonaws.com/DEV-AWS-MO-GCNv2/lab-5-storage.html 2/4
02/10/2021, 15:17 lab-5-storage
7. Scroll down to Advanced Details. And next to User data. You will update the
PHOTOS_BUCKET and AWS_DEFAULT_REGION variable.
#!/bin/bash -ex
wget https://aws-tc-largeobjects.s3-us-west-2.amazonaws.com/DEV-AWS-MO-
GCNv2/FlaskApp.zip
unzip FlaskApp.zip
cd FlaskApp/
yum -y install python3 mysql
pip3 install -r requirements.txt
amazon-linux-extras install epel
yum -y install stress
export PHOTOS_BUCKET=<INSERT-BUCKET-NAME-HERE>
export AWS_DEFAULT_REGION=<INSERT-REGION-NAME-HERE>
export DYNAMO_MODE=on
FLASK_APP=application.py /usr/local/bin/flask run --host=0.0.0.0 --port=80
export PHOTOS_BUCKET=employee-photo-bucket-al-007
employee-directory-app-s3
https://aws-tc-largeobjects.s3-us-west-2.amazonaws.com/DEV-AWS-MO-GCNv2/lab-5-storage.html 3/4
02/10/2021, 15:17 lab-5-storage
Congrats! You've launched an EC2 instance that uses the S3 bucket you created. To prevent future
costs, you will now stop the instance. (Note: do not terminate it, as the next lab will use this
instance.)
1. Search for EC2 in the search bar at the top. Choose EC2.
2. Choose Instances in the left side panel and select the employee-directory-app-s3 .
3. Choose Instance state and Stop instance. Choose Stop. The Instance state will eventually
go into the Stopped state.
Lab Complete
Congratulations! You have completed the lab.
For feedback, suggestions, or corrections, please contact us at:https://support.aws.amazon.co
m/#/contacts/aws-training
https://aws-tc-largeobjects.s3-us-west-2.amazonaws.com/DEV-AWS-MO-GCNv2/lab-5-storage.html 4/4