Skip to content

Instantly share code, notes, and snippets.

@morten
Created April 19, 2011 16:45
Show Gist options
  • Save morten/3139f3ca80571f441f13 to your computer and use it in GitHub Desktop.
Save morten/3139f3ca80571f441f13 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'fog'
cdn = Fog::AWS::CDN.new(
:aws_access_key_id => $ACCESS_KEY,
:aws_secret_access_key => $SECRET_KEY
)
# Creating a new distribution
options = {
'CustomOrigin' => {
'DNSName' => 'assets.example.com',
'OriginProtocolPolicy' => 'http-only'
},
'Enabled' => 'true'
}
cdn.post_distribution(options)
# Getting existing distribution data
dist = cdn.get_distribution(distribution_id = 'some id')
# Updating an existing distribution
dist = cdn.get_distribution(distribution_id = 'some id')
options = dist.body["DistributionConfig"]
options["Comment"] = "It's a new comment!"
cdn.put_distribution_config(dist.body["Id"], dist.headers["ETag"], options)
# Deleting a distribution
dist = cdn.get_distribution(distribution_id = 'some id')
cdn.delete_distribution_config(dist.body["Id"], dist.headers["ETag"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment