There are a lot of ways to set up a CDN and you don't even need to be a programmer to do so. Cyberduck seems to have worked for some people.

Found fog gem recently and it's working except that their documentation hasn't been updated. "Enabled" option is now required.

require 'rubygems'
require 'fog'

cdn = Fog::CDN.new({
  provider: 'AWS',
  aws_access_key_id: "xx", 
  aws_secret_access_key: "xx"
})

data = cdn.post_distribution({
  'CustomOrigin' => {
    'DNSName' => 'xx.yourdomain.com',
    'HTTPPort' => 80, 
    'OriginProtocolPolicy'  => 'match-viewer'
  }, 
  'CNAME' => 'cdn.yourdomain.com',
  'Enabled' => true
})

# parse the response for stuff you'll need later
distribution_id   = data.body['Id']
caller_reference  = data.body['CallerReference']
etag              = data.headers['ETag']
cdn_domain_name   = data.body['DomainName']

Hope that helps someone.

comments powered byDisqus

Hello! I am Kat. I've been a developer for several years. When I'm not sitting down, reading and working for long hours, I am traveling to some place of interest.
If you want to reach out, you can send me an email or add me up on Google Plus.