Tag Archives: Amazon Cloud Front

How to Configure Amazon Cloud Front with Grails Web Application

 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:

  1.  Login in to Amazon Cloud Front

https://console.aws.amazon.com/cloudfront/home

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

grails.resources.mappers.baseurl.default=

http://aersdeghyi.cloudfront.net // put here domain name.

grails.resources.mappers.bundle.excludes = ['**/*']

grails.resources.uri.prefix = “”

grails.resources.adhoc.patterns =

['/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”/>

Reference links:

  • Upload our content to Amazon S3 and grant permission.

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/GettingStarted.html

  • To automate upload and download. We need to Install bucket explorer.

http://www.bucketexplorer.com/

  • Serving Compressed or Uncompressed File doc.

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html

 


ProsperaSoft offers Grails development solutions. You can email at info@prosperasoft.com to get in touch with ProsperaSoft Grails experts and consultants.