Sha256: 4b9ef462ca3c193fc5423e7fd67280357c20454a8009e37c423f807bb72184e5
Contents?: true
Size: 1.82 KB
Versions: 4
Compression:
Stored size: 1.82 KB
Contents
module Cloudster #==CloudFront resource #Output values : domain_name class CloudFront include Cloudster::Output # Initialize CloudFront # # ==== Notes # options parameter must include values for :name # # ==== Examples # cloud_front = Cloudster::CloudFront.new(:name => 'CloudFront') # # ==== Parameters # * options<~Hash> - # * :name: String containing the name of CloudFront resource def initialize(options = {}) require_options(options, [:name]) @name = options[:name] end # Merges the required CloudFormation template for adding an CloudFront to an s3 instance # # # ==== Examples # cloud_front = Cloudster::CloudFront.new(:name => 'CloudFrontDistribution') # s3 = Cloudster::S3.new( # :name => 'S3Resource', # :access_control => 'PublicRead' # ) # # cloud_front.add_to s3 # # ==== Parameters # * instance of s3 def add_to(s3) s3_template = s3.template @instance_name = s3.name cloud_front_template = template s3.template.deep_merge(cloud_front_template) end private def template template = { "Resources" => { @name => { "Type" => "AWS::CloudFront::Distribution", "Properties" => { "DistributionConfig" => { "S3Origin" => { "DNSName"=> {"Fn::GetAtt" => [@instance_name, "DomainName"]}, }, "Enabled" => "true" } } } } } outputs = { @name => { 'domain_name' => {'Fn::GetAtt' => [@name, 'DomainName']} } } template['Outputs'] = output_template(outputs) return template end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
cloudster-2.19.6 | lib/cloudster/cloud_front.rb |
cloudster-2.19.5 | lib/cloudster/cloud_front.rb |
cloudster-2.19.4 | lib/cloudster/cloud_front.rb |
cloudster-2.19.3 | lib/cloudster/cloud_front.rb |