How do you setup Amazon’s CloudFront?
The S3 just provides a way to put content on Amazon’s system, so that it can then be distributed to CloudFront.
Once you’ve signed up with S3, you create a “bucket”, which is a storage vessel: a way of organizing your content. I created a single bucket for my single site, but you may need to create more than one. Into this bucket you’d put any content that needs to be stored. Following are the steps to follow:
- Login in to Amazon Cloud Front
2. Create a bucket.
Go to Service-> Select S3 , Create Bucket option is there.
3. Create distribution.
Go to service -> Select Cloud front, Create Distribution option is there
4. After click on Create Distribution button. Select Delivery method Web
5. After selection of Web
Origin Setting has Origin domain name field.
In that created bucket option will show. Choose it.
6. Distribution Settings area has
Price Class Field (Choose the region)
7. And Click on Create Distribution button on bottom.
8. And Cloud Front Distribution Screen will appear , The Distribution is going to deploy it takes at least 15 minutes. Check the Status is in progress and state is enabled. Once the Status is deployed we can use it.
9. To use this created resources we need to make bucket public just right click on bucket and make it public.
To Configure Amazon Cloud Front with Grails we need to configure some settings in Config.groovy.
Just put the below lines as per requirement either in dev mode or prod mode.
//Amazon Cloud Front Setting
grails.resources.mappers.baseurl.enabled = true
http://aersdeghyi.cloudfront.net // put here domain name.
grails.resources.mappers.bundle.excludes = ['**/*']
grails.resources.uri.prefix = “”
['/images/*', '/css/*', '/js/*', '/plugins/*']
To test it just hit the image request.
<img class=“imgSize” src=“http://amazoncloudfrontbucket.s3-us-west-2.amazonaws.com/resources/pump.jpg”/>
- Upload our content to Amazon S3 and grant permission.
- To automate upload and download. We need to Install bucket explorer.
- Serving Compressed or Uncompressed File doc.
ProsperaSoft offers Grails development solutions. You can email at email@example.com to get in touch with ProsperaSoft Grails experts and consultants.