Sha256: 79233c0b6b5cf30b2ea81b3f2b2836cb01f78dc6cb424454c4b1fc693067c0f6

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

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

require 'aws/cloud_front'

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

cloud_front = AWS::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.0.0 samples/cloud_front.rb
simple_aws-1.0.0.pre3 samples/cloud_front.rb
simple_aws-1.0.0.pre2 samples/cloud_front.rb
simple_aws-1.0.0.pre1 samples/cloud_front.rb
simple_aws-0.0.1d samples/cloud_front.rb