Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #216 from rapid7/add-s3-website
Browse files Browse the repository at this point in the history
Add S3 Website Configuration and properties
  • Loading branch information
erran-r7 authored Nov 2, 2016
2 parents a2b9ba3 + 9e7bc18 commit b26428e
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ attic

*.swp
*.swo
*.gem
7 changes: 7 additions & 0 deletions lib/convection/model/template/resource/aws_s3_bucket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class S3Bucket < Resource
property :notification_configuration, 'NotificationConfiguration'
property :replication_configuration, 'ReplicationConfiguration'
property :versioning_configuration, 'VersioningConfiguration'
property :website_configuration, 'WebsiteConfiguration'

def cors_configuration(&block)
config = ResourceProperty::S3CorsConfiguration.new(self)
Expand All @@ -43,6 +44,12 @@ def replication_configuration(&block)
properties['ReplicationConfiguration'].set(config)
end

def website_configuration(&block)
config = ResourceProperty::S3WebsiteConfiguration.new(self)
config.instance_exec(&block) if block
properties['WebsiteConfiguration'].set(config)
end

def render(*args)
super.tap do |resource|
render_tags(resource)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class CloudFrontDefaultCacheBehavior < ResourceProperty
property :compress, 'Compress'
property :default_ttl, 'DefaultTTL'
property :forwarded_values, 'ForwardedValues'
property :max_ttl, 'MaxTTL'
property :min_ttl, 'MinTTL'
property :smooth_streaming, 'SmoothStreaming'
property :target_origin, 'TargetOriginId'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require_relative '../resource_property'

module Convection
module Model
class Template
class ResourceProperty
# Represents an {http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-websiteconfiguration.html
# Amazon S3 Website Configuration}
class S3WebsiteConfiguration < ResourceProperty
property :error_document, 'ErrorDocument'
property :index_document, 'IndexDocument'
property :redirect_all_reqs_to, 'RedirectAllRequestsTo'
property :routing_rules, 'RoutingRules', :type => :list

def redirect_all_requests_to(&block)
redirect_to = ResourceProperty::S3WebsiteConfigurationRedirectAllRequestsTo.new(self)
redirect_to.instance_exec(&block) if block
properties['RedirectAllRequestsTo'].set(redirect_to)
end

def routing_rule(&block)
routing_rule = ResourceProperty::S3WebsiteConfigurationRoutingRule.new(self)
routing_rule.instance_exec(&block) if block
routing_rules << routing_rule
end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require_relative '../resource_property'

module Convection
module Model
class Template
class ResourceProperty
# Represents an {http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-websiteconfiguration-redirectallrequeststo.html
# Amazon S3 Website Configuration Redirect All Requests To}
class S3WebsiteConfigurationRedirectAllRequestsTo < ResourceProperty
property :host_name, 'HostName'
property :protocol, 'Protocol'
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require_relative '../resource_property'

module Convection
module Model
class Template
class ResourceProperty
# Represents an {http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-websiteconfiguration-routingrules.html
# Amazon S3 Website Configuration Routing Rule}
class S3WebsiteConfigurationRoutingRule < ResourceProperty
property :redirect_rul, 'RedirectRule'
property :routing_rule_cond, 'RoutingRuleCondition'

def redirect_rule(&block)
redr = ResourceProperty::S3WebsiteConfigurationRoutingRuleRedirectRule.new(self)
redr.instance_exec(&block) if block
properties['RedirectRule'].set(redr)
end

def routing_rule_condition(&block)
cond = ResourceProperty::S3WebsiteConfigurationRoutingRuleRoutingRuleCondition.new(self)
cond.instance_exec(&block) if block
properties['RoutingRuleCondition'].set(cond)
end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require_relative '../resource_property'

module Convection
module Model
class Template
class ResourceProperty
# Represents an {http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-websiteconfiguration-routingrules-redirectrule.html
# Amazon S3 Website Configuration Routing Rule Redirect Rule}
class S3WebsiteConfigurationRoutingRuleRedirectRule < ResourceProperty
property :host_name, 'HostName'
property :http_redirect_code, 'HttpRedirectCode'
property :protocol, 'Protocol'
property :replace_key_prefix_with, 'ReplaceKeyPrefixWith'
property :replace_key_with, 'ReplaceKeyWith'
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require_relative '../resource_property'

module Convection
module Model
class Template
class ResourceProperty
# Represents an {http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-websiteconfiguration-routingrules-routingrulecondition.html
# Amazon S3 Website Configuration Routing Rule Routing Rule Condition}
class S3WebsiteConfigurationRoutingRule < ResourceProperty
property :http_error_code_returned_equals, 'HttpErrorCodeReturnedEquals'
property :key_prefix_equals, 'KeyPrefixEquals'
end
end
end
end
end

0 comments on commit b26428e

Please sign in to comment.