-
Log in to the AWS Management Console as the Admin user.
-
Search for S3 in the search bar and select S3 to open the console.
-
Choose Create bucket.
-
Enter the following in Bucket name:
employee-photo-bucket-<your-initials>-<unique-number>Example:
employee-photo-bucket-al-907 -
Choose Create bucket.
- Click the name of your newly created bucket to open it.
- Choose Upload → Add files.
- Select a photo from your computer and click Open.
- Choose Upload.
- Confirm that Upload succeeded appears in green.
- Click Close.
- In the bucket's dashboard, go to the Permissions tab.
- Scroll to Bucket policy and click Edit.
- Paste the following JSON into the editor, updating placeholders:
{
"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>/*"
]
}
]
}
-
Replace:
<INSERT-ACCOUNT-NUMBER>→ your AWS account number<INSERT-BUCKET-NAME>→ your bucket name
Example:
"AWS": "arn:aws:iam::123456789012:role/S3DynamoDBFullAccessRole" "Resource": [ "arn:aws:s3:::employee-photo-bucket-al-907", "arn:aws:s3:::employee-photo-bucket-al-907/*" ]
-
Click Save changes.
-
Go to EC2 from the AWS Services menu.
-
In the Instances section, find the employee-directory-app instance (should be Stopped).
-
Choose Actions > Image and templates > Launch more like this.
-
Update the Name tag value to:
employee-directory-app-s3 -
Under Key pair name, select:
app-key-pair. -
Expand Network settings and set:
- Auto-assign Public IP → Enable
-
Scroll to Advanced details > User data, and update the script:
#!/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=employee-photo-bucket-al-907
export AWS_DEFAULT_REGION=us-west-2
export DYNAMO_MODE=on
FLASK_APP=application.py /usr/local/bin/flask run --host=0.0.0.0 --port=80
⚠️ Replace employee-photo-bucket-al-907 and us-west-2 with your actual bucket name and region if different.
- Click Launch instance.
-
Go to EC2 > Instances.
-
Wait for the new instance to show:
- Instance state:
Running - Status checks:
2/2 checks passed
- Instance state:
-
Copy the Public IPv4 address (do not click the link).
-
Open a new browser tab and paste the IP, using
http://(nothttps):http://<your-ec2-public-ip> -
You should see an Employee Directory placeholder page.
- Select the employee-directory-app-s3 instance in the EC2 console.
- Choose Instance state > Stop instance.
You've successfully:
- Created and configured an S3 bucket
- Uploaded a photo
- Applied a custom bucket policy
- Launched an EC2 app that pulls images from S3