Sha256: 05fee9ca284acd217c599ad8add2f2d48bf3a5d050d70ba7f56d7a9a6a3e87f3

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

$: << File.expand_path("../../lib", __FILE__)

require 'simple_aws/cloud_front'

##
# Expects your Amazon keys to be in the environment, something like
#
# export AWS_KEY="KEY"
# export AWS_SECRET="SECRET"
##

cloud_front = SimpleAWS::CloudFront.new ENV["AWS_KEY"], ENV["AWS_SECRET"]

puts "First ten distribution items:", ""

cloud_front.get("/distribution", :params => {"MaxItems" => 10}).distribution_summary.each do |d|
  puts "ID: #{d.id}"
  puts "Domain: #{d.domain_name}"
  if d["CustomOrigin"]
    puts "Custom Origin: #{d.custom_origin.inspect}"
  elsif d["S3Origin"]
    puts "S3 Origin: #{d.s3_origin.inspect}"
  end
  puts "Status: #{d.status}"
  puts ""
end

# Leaving this commented out. It works, but you can't quickly
# delete the new distribution so you'll have to clean up manually
#
#puts "", "Creating new test distribution", ""
#
#response = cloud_front.post "/distribution", :xml => {
#  "DistributionConfig" => {
#    "CustomOrigin" => {
#      "DNSName" => "cnd.example.com",
#      "HTTPPort" => 80,
#      "OriginProtocolPolicy" => "http-only"
#    },
#    "CallerReference" => "simple_aws_testing_#{rand(100_000)}",
#    "Enabled" => false
#  }
#}
#
#p response
#
#id = response.id
#etag = response.headers["etag"]
#
#puts ""
#puts "Created distribution with id #{id} and etag #{etag}."
#puts "It's at domain #{response.domain_name}"

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simple_aws-1.2.3 samples/cloud_front.rb
simple_aws-1.2.2 samples/cloud_front.rb
simple_aws-1.2.1 samples/cloud_front.rb
simple_aws-1.2.0 samples/cloud_front.rb
simple_aws-1.1.0 samples/cloud_front.rb