Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trevorrowe/4239c75781d627fd6ebe to your computer and use it in GitHub Desktop.
Save trevorrowe/4239c75781d627fd6ebe to your computer and use it in GitHub Desktop.
cf = Aws::CloudFront::Client.new
resp = cf.create_distribution(
distribution_config: {
caller_reference: Time.now.to_i.to_s,
aliases: {
quantity: 0
},
default_root_object: '',
origins: {
quantity: 1,
items: [
{
id: 'Custom-mywebsite',
domain_name: 'mywebsite.io',
custom_origin_config: {
http_port: 80,
https_port: 443,
origin_protocol_policy: 'http-only'
}
}
]
},
default_cache_behavior: {
target_origin_id: 'Custom-mywebsite',
forwarded_values: {
query_string: false,
cookies: { forward: 'none' },
headers: { quantity: 0 }
},
trusted_signers: {
enabled: false,
quantity: 0
},
viewer_protocol_policy: 'allow-all',
min_ttl: 0,
allowed_methods: {
quantity: 2,
items: %w(GET HEAD)
},
smooth_streaming: false
},
cache_behaviors: { quantity: 0 },
custom_error_responses: { quantity: 0 },
comment: 'mywebsite-distribution',
logging: {
enabled: false,
include_cookies: false,
bucket: '',
prefix: ''
},
price_class: 'PriceClass_100',
enabled: true,
viewer_certificate: {
cloud_front_default_certificate: true,
ssl_support_method: 'vip'
},
restrictions: {
geo_restriction: {
restriction_type: 'none',
quantity: 0
}
}
}
)
cf.update_distribution(
id: resp.distribution[:id],
distribution_config: resp.distribution[:distribution_config],
if_match: resp[:etag]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment