diff --git a/lib/convection/model/template/resource/aws_s3_bucket.rb b/lib/convection/model/template/resource/aws_s3_bucket.rb index a214fd3..5818319 100644 --- a/lib/convection/model/template/resource/aws_s3_bucket.rb +++ b/lib/convection/model/template/resource/aws_s3_bucket.rb @@ -19,6 +19,12 @@ class S3Bucket < Resource property :notification_configuration, 'NotificationConfiguration' property :versioning_configuration, 'VersioningConfiguration' + def cors_configuration(&block) + config = ResourceProperty::S3CorsConfiguration.new(self) + config.instance_exec(&block) if block + properties['CorsConfiguration'].set(config) + end + def cors_configurationm(*args) warn 'DEPRECATED: "cors_configurationm" is deprecated. Please use "cors_configuration" instead. https://github.com/rapid7/convection/pull/135' cors_configuration(*args) diff --git a/lib/convection/model/template/resource_property/aws_s3_cors_configuration.rb b/lib/convection/model/template/resource_property/aws_s3_cors_configuration.rb new file mode 100644 index 0000000..f0841b3 --- /dev/null +++ b/lib/convection/model/template/resource_property/aws_s3_cors_configuration.rb @@ -0,0 +1,21 @@ +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-bucket-cors.html + # Amazon S3 Cors Configuration} + class S3CorsConfiguration < ResourceProperty + property :cors_rules, 'CorsRules', :type => :list + + def cors_rule(&block) + cors_rule = ResourceProperty::S3CorsConfigurationRule.new(self) + cors_rule.instance_exec(&block) if block + cors_rules << cors_rule + end + end + end + end + end +end diff --git a/lib/convection/model/template/resource_property/aws_s3_cors_configuration_rule.rb b/lib/convection/model/template/resource_property/aws_s3_cors_configuration_rule.rb new file mode 100644 index 0000000..c0d57f2 --- /dev/null +++ b/lib/convection/model/template/resource_property/aws_s3_cors_configuration_rule.rb @@ -0,0 +1,20 @@ +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-bucket-cors-corsrule.html + # Amazon S3 Cors Configuration Rule} + class S3CorsConfigurationRule < ResourceProperty + property :allowed_headers, 'AllowedHeaders', :type => :list + property :allowed_methods, 'AllowedMethods', :type => :list + property :allowed_origins, 'AllowedOrigins', :type => :list + property :exposed_headers, 'ExposedHeaders', :type => :list + property :id, 'Id' + property :max_age, 'MaxAge' + end + end + end + end +end