- Log in to AWS console, on the eu-central-1 region. Region is hardcoded, so other regions will not work with this code.
- Setup IAM role 'ec2-with-s3': with AmazonS3FullAccess
- Create S3 bucket. Make sure that it is publicly readable. Make note of name, to be used below
To make the bucket open for public, you can configure the following bucket policy. This is not actually necessary for this application but may help with debugging.
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadGetObject",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::example-bucket/*"]
}]
}
Note that "example-bucket" in the policy above needs to be replaced with the bucket name you're using.
- Create EC2 instance: Amazon AMI, t2.micro
- IAM role: 'ec2-with-s3'
- Advanced details: user data: paste install.sh
- Before moving on, paste name of S3 bucket to replace "ACTUALBUCKETNAME" in the user data
- Configure security group: add HTTP rule.
- Review and Launch + Launch
- Go to external IP and refresh. Expected time to launch is around 45-50 seconds.
- Upload images to the bucket
- Refresh ec2 url to see images