-
-
Save morten/3139f3ca80571f441f13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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