![Page 1: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/1.jpg)
Better (and Cheaper!) Content Storage with Amazon S3, CloudFront, and ColdFusion
Brian KlaasJohns Hopkins Bloomberg School of Public [email protected]@brian_klaas
![Page 2: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/2.jpg)
The Problem
![Page 3: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/3.jpg)
I need to upload a !le
1The Problem
![Page 4: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/4.jpg)
How big will the !les be?How many !les?
What’s the projected growth?
1The Problem
![Page 5: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/5.jpg)
Is the drive big enough?
1The Problem
Free Space2%
Used Space98%
![Page 6: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/6.jpg)
Storage is cheap.
1The Problem
But you’ve got to manage it.
![Page 7: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/7.jpg)
Set up redundant storage
1The Problem
■ SAN
■ High–Speed I/O to servers
■ Multiple nodes in the data center
■ Authentication and authorization
![Page 8: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/8.jpg)
What happens when they stop uploading Word !les and start
uploading PDFs? ZIP !les? MP4s?
1The Problem
![Page 9: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/9.jpg)
You can't delete anything.
1The Problem
EVER
![Page 10: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/10.jpg)
What about bandwidth costs?
1The Problem
![Page 11: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/11.jpg)
What about my customers in China?
1The Problem
in Australia?in Brazil?
in Ireland?
![Page 12: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/12.jpg)
$1
The Problem
![Page 13: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/13.jpg)
A solution from AWS
1The Problem
![Page 14: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/14.jpg)
AWS + S3 + CloudFront
![Page 15: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/15.jpg)
EC2 Route 53
VPCElastic Map
Reuce
DirectConnect
Cloud Formation
Cloud Watch
Data Pipeline
Elastic BeanStalk
IAM OpsWorks
Cloud Search
Elastic Transcoder SES SNS SQS SWF
DynamoDB
ElastiCache RDS Redshift
CloudFront Glacier S3 Storage
Gateway
![Page 16: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/16.jpg)
2AWS Overview
S3: Store all the things
![Page 17: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/17.jpg)
1 byte
2AWS Overview
5 terabytes
![Page 18: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/18.jpg)
Regions
2AWS Overview
■ US Standard (NoVA or Washington)
■ US West (Oregon)
■ US West (NorCal)
■ EU (Ireland)
■ Asia Paci!c (Singapore)
■ Asia Paci!c (Sydney)
■ Asia Paci!c (Tokyo)
■ South America (São Paulo)
![Page 19: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/19.jpg)
Versioning
2AWS Overview
![Page 20: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/20.jpg)
Static website hosting
2AWS Overview
![Page 21: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/21.jpg)
99.999999999% durability*
2AWS Overview
99.99% availability
*Yes, stuff can get lost.
![Page 22: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/22.jpg)
$0.095 per GB
$0.01 per 10,000 GET
$0.01 per 1,000 PUT
$0.12 per GB out after 1GB
2AWS Overview
![Page 23: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/23.jpg)
2AWS Overview
CloudFront:Distribute all the things
![Page 24: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/24.jpg)
2AWS Overview
Would you prefer...?
Beijing
Hong Kong
Seattle
Washington, DC
Raleigh
Beijing
Hong Kong
![Page 25: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/25.jpg)
2AWS Overview
Origin
CloudFront Distribution
Edge Farm Edge Farm Edge Farm Edge Farm Edge Farm Edge Farm
![Page 26: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/26.jpg)
Conditional GET
2AWS Overview
![Page 27: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/27.jpg)
Download
Streaming (via FMS)
2AWS Overview
![Page 28: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/28.jpg)
Current CloudFront Server Farms
2AWS Overview
![Page 29: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/29.jpg)
CloudFront Pricing
2AWS Overview
![Page 30: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/30.jpg)
AWS Overview
AWS
IAM
S3
CloudFront
2
![Page 31: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/31.jpg)
AWS is HTTP–based Development
2AWS Overview
![Page 32: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/32.jpg)
2AWS Overview
PUT /photos/puppy.jpg HTTP/1.1Content-Type: image/jpegContent-Length: 94328Host: johnsmith.s3.amazonaws.comDate: Tue, 27 Mar 2007 21:15:45 +0000
Authorization: AWS AKIAIOSFODNN7EXAMPLE:MyyxeRY7whkBe+bq8fHCL/2kKUg=
![Page 33: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/33.jpg)
AWS SDKs for:
2AWS Overview
■ Java*
■ PHP
■ Ruby
■ Node.js
■ Python
■ .NET
■ Android
■ iOS
*ColdFusion
![Page 34: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/34.jpg)
AWS Account Security
![Page 35: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/35.jpg)
Master AWS Account
3AWS Account Security
IAM Account Key Pair
Access KeySecret Key
Key Pair IDPublic KeyPrivate Key
![Page 36: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/36.jpg)
IAM accounts can create other IAM accounts
Master AWS account can create key pairs
3AWS Account Security
![Page 37: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/37.jpg)
S3: IAM accounts
CloudFront: Key pairs
3AWS Account Security
![Page 38: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/38.jpg)
Master AWS Account
3AWS Account Security
Groups ACL
Authenticated UsersAll Users
Log DeliveryPolicies
![Page 39: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/39.jpg)
Sample Policy
3AWS Account Security
{ "Version":"2008-10-17", "Statement":[{ "Sid":"AddPerm", "Effect":"Allow", "Principal": { "AWS": "*" }, "Action":["s3:GetObject"], "Resource":["arn:aws:s3:::bucket/*" ] } ]}
![Page 40: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/40.jpg)
Requests from a Speci!c Domain Policy
3AWS Account Security
{ "Version":"2008-10-17", "Id":"http referer policy example", "Statement":[ { "Sid":"Allow get requests referred by www.mysite.com and mysite.com", "Effect":"Allow", "Principal":"*", "Action":"s3:GetObject", "Resource":"arn:aws:s3:::example-bucket/*", "Condition":{ "StringLike":{ "aws:Referer":[ "http://www.mysite.com/*", "http://mysite.com/*" ] } } } ]}
![Page 41: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/41.jpg)
Working with S3
![Page 42: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/42.jpg)
4Working with S3
Bucket
my!les.s3.amazonaws.com
![Page 43: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/43.jpg)
4Working with S3
Bucket
Object
![Page 44: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/44.jpg)
4Working with S3
Everything is an object
![Page 45: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/45.jpg)
4Working with S3
Objects have metadata
![Page 46: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/46.jpg)
Everything in S3 is private by default.
4Working with S3
![Page 47: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/47.jpg)
4Working with S3
![Page 48: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/48.jpg)
4Working with S3
http://mybucket.s3.amazonaws.com/path/to/file.png
![Page 49: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/49.jpg)
4Working with S3
Sample .NET Request
BasicAWSCredentials basicCredentials = new BasicAWSCredentials("*** Access Key ID ***", "*** Security Access Key ***");
AmazonS3Client s3Client = new AmazonS3Client(basicCredentials); var response = s3Client.ListBuckets();
![Page 50: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/50.jpg)
4Working with S3
Sample Java Request
AWSCredentials myCredentials = new BasicAWSCredentials(myAccessKeyID, mySecretKey);
AmazonS3 s3client = new AmazonS3Client(myCredentials);
List <Buckets> = s3client.listBuckets();
![Page 51: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/51.jpg)
4Working with S3
C:/
s3://
![Page 52: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/52.jpg)
4Working with S3
Basic ColdFusion Integration
<cffile action=“read”file=“s3://somebucket/somefile.txt” variable=“fileData” />
<cffile action=“write”file=“s3://somebucket/somefile.txt”output=“#someStuff#” />
![Page 53: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/53.jpg)
4Working with S3
Basic ColdFusion Integration
<cffile action=“delete”file=“s3://somebucket/somefile.txt” />
<cffile action=“copy”source=“s3://somebucket/somefile.txt”destination=“s3://anotherbucket/someCopy.txt” />
![Page 54: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/54.jpg)
4Working with S3
Basic ColdFusion Integration
<cfdirectory action=“create”directory=“s3://somebucket/someDirectory” />
<cfdirectory action=“list”directory=“s3://somebucket/someDirectory” />
![Page 55: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/55.jpg)
4Working with S3
ColdFusion Example<cfif not directoryExists("s3://somebucket.s3.amazonaws.com")> <cfset perms = [ {group="all", permission="read"},{id="canonicalIDofYourAWSAccount", permission="full_control"} ]> <cfdirectory action="create" directory="s3://somebucket.s3.amazonaws.com" storeacl="#perms#"></cfif>
<cfset fileWrite("s3://somebucket.s3.amazonaws.com/myFile.txt", "#someOutput#")>
<cfset files = directoryList("s3://somebucket.s3.amazonaws.com")>
![Page 56: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/56.jpg)
4Working with S3
Tags Which Support S3
■ cffile*
■ cfdirectory
■ cfdocument
■ cfftp
■ cffeed
■ c!mage
■ c$oop†
*Except rename† Looping over directory information
![Page 57: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/57.jpg)
4Working with S3
Functions Which Support S3■ !leOpen
■ !leClose
■ !leCopy
■ !leDelete
■ !leExists
■ !leisEOF
■ !leMove
■ !leWrite
■ !leRead
■ !leReadBinary
■ !leReadLine
■ !leSetLastModi!ed
■ getFileInfo
■ getDirectoryFromPath
■ directoryCreate
■ directoryDelete
■ directoryExists
■ directoryList
■ imageNew
■ imageRead
■ imageWrite
■ imageWriteBase64
■ isImageFile
■ isPDFFile
![Page 58: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/58.jpg)
4Working with S3
Don’t you need credentials?
![Page 59: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/59.jpg)
4Working with S3
Setting AWS IAM credentials
1. In the individual S3 call
2. In application.cfc
![Page 60: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/60.jpg)
4Working with S3
Setting AWS IAM credentials
<cffile action=“read”file=“s3://accessKeyId:awsSecretKey@somebucket/somefile.txt” variable=“fileData” />
![Page 61: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/61.jpg)
4Working with S3
Setting AWS IAM credentials
In application.cfc:
this.s3.accessKeyId="accessKey"; this.s3.awsSecretKey="secretKey";
![Page 62: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/62.jpg)
4Working with S3
ColdFusion Example<cfif not directoryExists("s3://somebucket.s3.amazonaws.com")> <cfset perms = [ {group="all", permission="read"},{id="canonicalIDofYourAWSAccount", permission="full_control"} ]> <cfdirectory action="create" directory="s3://somebucket.s3.amazonaws.com" storeacl="#perms#"></cfif>
<cfset fileWrite("s3://somebucket.s3.amazonaws.com/myFile.txt", "#someOutput#")>
<cfset files = directoryList("s3://somebucket.s3.amazonaws.com")>
![Page 63: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/63.jpg)
Everything in S3 is private by default.
4Working with S3
![Page 64: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/64.jpg)
4Working with S3
ColdFusion Example<cfif not directoryExists("s3://somebucket.s3.amazonaws.com")> <cfset perms = [ {group="all", permission="read"},{id="canonicalIDofYourAWSAccount", permission="full_control"} ]> <cfdirectory action="create" directory="s3://somebucket.s3.amazonaws.com" storeacl="#perms#"></cfif>
<cfset fileWrite("s3://somebucket.s3.amazonaws.com/myFile.txt", "#someOutput#")>
<cfset files = directoryList("s3://somebucket.s3.amazonaws.com")>
![Page 65: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/65.jpg)
4Working with S3
Get ACL with storeGetACL()
Set ACL with storeSetACL()
![Page 66: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/66.jpg)
4Working with S3
Setting permissions with ACLs
<cfset permissions = storeGetACL(fileOnS3) /><cfset arrayAppend(permissions,{group="all",permission="read"}) /><cfset storeSetACL(fileOnS3, "#permissions#") />
![Page 67: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/67.jpg)
4Working with S3
Get object metadata with storeGetMetadata()
Set object metadata with storeSetMetadata()
![Page 68: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/68.jpg)
4Working with S3
<cfset metadataStruct.content_type="video/webm" /><cfset storeSetMetadata(s3File, "#metadataStruct#") />
Setting content type
![Page 69: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/69.jpg)
4Working with S3
Standard Keys in S3 Metadata
■ last_modi!ed
■ date
■ owner
■ etag
■ content_length
■ content_type
■ content_encoding
■ content_disposition
■ content_language
■ content_md5
■ md5_hash
![Page 70: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/70.jpg)
4Working with S3
Multiparting Large Uploads
this.s3.minsizeformultipart=10;
*CF10–only
Files above this size (in MB) will be split and sent in parallel.
![Page 71: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/71.jpg)
4Working with S3
ACF 9.0.1/2 bug
Solution: Get your current ACL, make the metadata change, then set the ACL again
![Page 72: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/72.jpg)
2AWS Overview
S3: The Next Level
![Page 73: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/73.jpg)
4Working with S3
Custom Signing Requests
![Page 74: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/74.jpg)
4Working with S3
Custom Signing Requests
Signature = Base64( HMAC-SHA1( YourSecretAccessKeyID, UTF-8-Encoding-Of( StringToSign ) ) );
StringToSign = HTTP-Verb + "\n" + Content-MD5 + "\n" + Content-Type + "\n" + Date + "\n" + CanonicalizedAmzHeaders + CanonicalizedResource;
![Page 75: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/75.jpg)
4Working with S3
Expiring the URL
![Page 76: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/76.jpg)
4Working with S3
Expiring the URL
1. Specify the object URL
2. Specify an expiration time for the request
3. Sign the request with your IAM secret key using HMAC encoding
4. Make the HTTP call
http://bucket.s3.amazonaws.com/someObject?AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE&Expires=1177363698&Signature=vjSAMPLENmGa%2ByT272YEAiv4%3D
![Page 77: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/77.jpg)
4Working with S3
Changing !le properties on a per-request basis
■ File name
■ Content–disposition
■ MIME–type
■ Adding custom metadata
![Page 78: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/78.jpg)
4Working with S3
Changing !le properties per request
1. Specify the object URL
2. Specify your request headers
3. Sign the request with your IAM secret key using HMAC encoding
4. Make the HTTP call
![Page 79: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/79.jpg)
4Working with S3
S3RequestSigningUtils on GitHub
github.com/brianklaas/ctlS3Utils
*Requires CF10
![Page 80: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/80.jpg)
4Working with S3
Direct Upload to S3from the Browser
www.bennadel.com/blog/2500-Uploading-Files-To-Amazon-S3-Using-A-Form-Post-And-ColdFusion.htm
![Page 81: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/81.jpg)
4Working with S3
Upload to S3 from the Browser
■ Can upload only one !le at a time.
■ Must specify the policy for the upload.
■ You still need to generate an authorization signature on the server and embed that as a form parameter.
■ Provide a success URL in the form. AWS posts the bucket and key to that URL on successful upload.
■ Failures are returned as the typical AWS error XML structure.
![Page 82: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/82.jpg)
2AWS Overview
S3: Issues to Consider
![Page 83: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/83.jpg)
4Working with S3
What happens when an upload fails?
![Page 84: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/84.jpg)
4Working with S3
S3 is storage, not a !le system
Can get basic !le info with<cfhttp url="http://bucket.s3.amazonaws.com/!lename" method="head">
![Page 85: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/85.jpg)
4Working with S3
What happens when AWS goes down?
![Page 86: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/86.jpg)
Working with CloudFront
![Page 87: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/87.jpg)
Working with CloudFront
AWS
IAM
S3
CloudFront
5
![Page 88: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/88.jpg)
CloudFront Work$ow
5Working with CloudFront
1. Put !les in your origin (S3).
2. Make the objects accessible.
3. Create a CloudFront distribution pointing at your origin.
4. Use URLs with the CloudFront distribution domain.
![Page 89: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/89.jpg)
http://d1xrz3abcdef8.cloudfront.net/image.jpg
5Working with CloudFront
If S3 is the origin for your CloudFront distribution, the bucket name is embedded
in the CloudFront distribution domain name.
Use the full path to the !le here, including folder name(s).
![Page 90: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/90.jpg)
Custom domain names
5Working with CloudFront
![Page 91: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/91.jpg)
Default TTL = 24 hours
5Working with CloudFront
![Page 92: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/92.jpg)
5Working with CloudFront
CloudFront: The Next Level
![Page 93: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/93.jpg)
Changing the TTL
5Working with CloudFront
![Page 94: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/94.jpg)
Versioning
5Working with CloudFront
?ver=2
![Page 95: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/95.jpg)
Custom HTTP headers
5Working with CloudFront
?response-content-disposition=attachment;!lename=someNewFileName.mp4
![Page 96: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/96.jpg)
Protecting For–Fee Content
5Working with CloudFront
![Page 97: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/97.jpg)
CloudFront distributions which allow signed requests have
additional setup parameters.
5Working with CloudFront
(See the docs.)
![Page 98: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/98.jpg)
Signing the Request5
Working with CloudFront
1. Specify the object URL2. Specify an expiration time for the request3. Sign the request with the CloudFront private key
from a trusted signer using HMAC encoding4. Make the HTTP call
https://d1y9l76vzamjxr.cloudfront.net/sample.pdf?ver=2&response-content-disposition=attachment%3Bfilename%3DtotalExample.mp4&Expires=1384467600&Signature=DAQ5Eoy-cKV0pqqaOxh199mHofuYEud3q4MzCHH4IKJqn25P8NJG1RbWPzkw0Dlp~PaUUl09EnqO7BEvKnjcx-pivmDkpZ9N9-wq44Ez09q088LaTuP31aXMSoS1~AMyR1zsvTuwkrmwrIucXPiOYiiQaidtgyFdtSRiVuJaLaY_&Key-Pair-Id=APKAIZXDNAH35HHVJAZQ
![Page 99: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/99.jpg)
CloudFront Private Key?
5Working with CloudFront
![Page 100: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/100.jpg)
Master AWS Account
3AWS Account Security
IAM Account Key Pair
Access KeySecret Key
Key Pair IDPublic KeyPrivate Key
![Page 101: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/101.jpg)
Trusted Signer?
5Working with CloudFront
![Page 102: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/102.jpg)
S3: Origin Access Identity
5Working with CloudFront
![Page 103: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/103.jpg)
CloudFront key pair+ Trusted signer+ Origin Access Identity= Signed CloudFront URLs
5Working with CloudFront
![Page 104: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/104.jpg)
Use a library for this.
5Working with CloudFront
(Seriously.)
![Page 105: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/105.jpg)
CloudFront Libraries
5Working with CloudFront
■ .NET — ThreeSharp
■ Java — JetS3t
■ PHP — AWS Samples
■ Ruby — RightScale gem
+ regular AWS SDKs
![Page 106: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/106.jpg)
5Working with CloudFront
CTL CloudFrontUtils on GitHub
github.com/brianklaas/ctlCloudFrontUtils
*Requires AWS SDK and CF10
![Page 107: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/107.jpg)
5Working with CloudFront
CTL CloudFrontUtils on GitHub
<cfset cfUtilsObj = new ctlCloudFrontUtils(initArgs) />
<cfset argCol = structNew() /><cfset argCol.originFilePath = "sample.pdf" /><cfset argCol.expiresOnDate = DateAdd("n", 1, Now()) /><cfset argCol.objectVersion = 3 /><cfset argCol.isAttachment = true /><cfset argCol.fileNameToUse = "lecture1a.pdf" />
<cfset signedURL = cfUtilsObj.createSignedURL(argumentCollection = argCol) />
![Page 108: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/108.jpg)
5Working with CloudFront
The Full Rundown on Setting Up a CloudFront Distribution for
Signed URLs and Using the CTL CloudFront Utils
www.iterateme.com/blog/index.cfm/2013/2/11/Creating-Signed-URLs-for-Amazon-CloudFront-in-ColdFusion
![Page 109: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/109.jpg)
5Working with CloudFront
CloudFront: Issues to Consider
![Page 110: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/110.jpg)
Everything fails.
5Working with CloudFront
![Page 111: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/111.jpg)
Multiple distributions, balanced.
5Working with CloudFront
*Requires external load balancing.
![Page 112: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/112.jpg)
Use a custom domain name.
5Working with CloudFront
![Page 113: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/113.jpg)
S3 as a CDN vs. CloudFront
5Working with CloudFront
![Page 114: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/114.jpg)
Go Do
![Page 115: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/115.jpg)
Session Evaluation
ncdevcon.com/sessions/
![Page 116: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/116.jpg)
Thank you!
Brian KlaasJohns Hopkins Bloomberg School of Public [email protected]@brian_klaaswww.iterateme.comgithub.com/brianklaas
![Page 117: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/117.jpg)
■ AWS Management Consolehttp://aws.amazon.com/console/
■ AWS Documentationhttp://aws.amazon.com/documentation/
■ AWS SDK’shttp://aws.amazon.com/tools/
■ ColdFusion ACL Object Informationhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSd160b5fdf5100e8f79a619d71281e7d6c97-8000.html
■ Adobe CF 9.0.1/2 storeSetMetadata() Bughttp://www.raymondcamden.com/index.cfm/2011/2/7/ColdFusion-S3-Implementation-bug-with-metadata-and-ACLs
Resources Used in Building this Presentation
![Page 118: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/118.jpg)
■ Direct Upload to S3 Using Fine Uploaderhttp://blog.!neuploader.com/2013/08/16/!ne-uploader-s3-upload-directly-to-amazon-s3-from-your-browser/
■ Ben Nadel’s Example of Direct Upload to S3 Using Pluploadhttp://www.bennadel.com/blog/2502-Uploading-Files-To-Amazon-S3-Using-Plupload-And-ColdFusion.htm
■ Creating a CloudFront Download Distributionhttp://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CreatingDownloadDistributions.html
■ Setting up a CloudFront Distribution for Signed URLshttp://www.iterateme.com/blog/index.cfm/2013/2/11/Creating-Signed-URLs-for-Amazon-CloudFront-in-ColdFusion
Resources Used in Building this Presentation
![Page 119: Better (and Cheaper!) Content Storage with Amazon S3, CloudFront…€¦ · Amazon S3, CloudFront, and ColdFusion Brian Klaas Johns Hopkins Bloomberg School of Public Health bklaas@jhsph.edu](https://reader034.vdocuments.us/reader034/viewer/2022050300/5f693523aa4b587bb503fd54/html5/thumbnails/119.jpg)
■ CloudFront Librarieshttp://aws.amazon.com/code/CloudFront
■ ColdFusion 10 Documentation on Using S3https://learn.adobe.com/wiki/display/coldfusionen/Optimizing+ColdFusion+applications
Resources Used in Building this Presentation