cloud_former 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +51 -0
  3. data/.rspec +3 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +21 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +30 -0
  8. data/Rakefile +1 -0
  9. data/cloud_former.gemspec +26 -0
  10. data/lib/cloud_former/boolean.rb +5 -0
  11. data/lib/cloud_former/functions/base_64.rb +28 -0
  12. data/lib/cloud_former/functions/find_in_map.rb +36 -0
  13. data/lib/cloud_former/functions/function.rb +5 -0
  14. data/lib/cloud_former/functions/get_att.rb +19 -0
  15. data/lib/cloud_former/functions/get_azs.rb +14 -0
  16. data/lib/cloud_former/functions/join.rb +36 -0
  17. data/lib/cloud_former/has_properties_and_attributes.rb +104 -0
  18. data/lib/cloud_former/makes_json.rb +64 -0
  19. data/lib/cloud_former/metadata_resources/cloud_formation/authentication.rb +28 -0
  20. data/lib/cloud_former/metadata_resources/cloud_formation/authentication_item.rb +29 -0
  21. data/lib/cloud_former/metadata_resources/cloud_formation/config_set.rb +35 -0
  22. data/lib/cloud_former/metadata_resources/cloud_formation/config_set_command.rb +27 -0
  23. data/lib/cloud_former/metadata_resources/cloud_formation/config_set_file.rb +29 -0
  24. data/lib/cloud_former/metadata_resources/cloud_formation/config_set_group.rb +17 -0
  25. data/lib/cloud_former/metadata_resources/cloud_formation/config_set_item.rb +70 -0
  26. data/lib/cloud_former/metadata_resources/cloud_formation/config_set_service.rb +27 -0
  27. data/lib/cloud_former/metadata_resources/cloud_formation/config_set_user.rb +24 -0
  28. data/lib/cloud_former/metadata_resources/cloud_formation/init.rb +33 -0
  29. data/lib/cloud_former/metadata_resources/metadata_resource.rb +15 -0
  30. data/lib/cloud_former/parameters/commma_delimited_list_parameter.rb +9 -0
  31. data/lib/cloud_former/parameters/number_parameter.rb +9 -0
  32. data/lib/cloud_former/parameters/parameter.rb +30 -0
  33. data/lib/cloud_former/parameters/string_parameter.rb +9 -0
  34. data/lib/cloud_former/property_or_attribute.rb +49 -0
  35. data/lib/cloud_former/pseudo_parameters/account_id_parameter.rb +7 -0
  36. data/lib/cloud_former/pseudo_parameters/no_value_parameter.rb +7 -0
  37. data/lib/cloud_former/pseudo_parameters/notification_arns_parameter.rb +7 -0
  38. data/lib/cloud_former/pseudo_parameters/pseudo_parameter.rb +5 -0
  39. data/lib/cloud_former/pseudo_parameters/region_parameter.rb +7 -0
  40. data/lib/cloud_former/pseudo_parameters/stack_id_parameter.rb +7 -0
  41. data/lib/cloud_former/pseudo_parameters/stack_name_parameter.rb +7 -0
  42. data/lib/cloud_former/resource_properties/auto_scaling/block_device_mapping.rb +11 -0
  43. data/lib/cloud_former/resource_properties/auto_scaling/ebs_block_device.rb +12 -0
  44. data/lib/cloud_former/resource_properties/auto_scaling/metrics_collection.rb +9 -0
  45. data/lib/cloud_former/resource_properties/auto_scaling/notification_configuration.rb +16 -0
  46. data/lib/cloud_former/resource_properties/auto_scaling/tag.rb +10 -0
  47. data/lib/cloud_former/resource_properties/cloud_formation/resource_tag.rb +9 -0
  48. data/lib/cloud_former/resource_properties/cloud_front/cache_behavior.rb +15 -0
  49. data/lib/cloud_former/resource_properties/cloud_front/custom_error_response.rb +13 -0
  50. data/lib/cloud_former/resource_properties/cloud_front/custom_origin.rb +10 -0
  51. data/lib/cloud_former/resource_properties/cloud_front/default_cache_behavior.rb +14 -0
  52. data/lib/cloud_former/resource_properties/cloud_front/distribution_configuration.rb +27 -0
  53. data/lib/cloud_former/resource_properties/cloud_front/forwarded_values.rb +9 -0
  54. data/lib/cloud_former/resource_properties/cloud_front/forwarded_values_cookies.rb +9 -0
  55. data/lib/cloud_former/resource_properties/cloud_front/geo_restriction.rb +9 -0
  56. data/lib/cloud_former/resource_properties/cloud_front/logging.rb +10 -0
  57. data/lib/cloud_former/resource_properties/cloud_front/origin.rb +11 -0
  58. data/lib/cloud_former/resource_properties/cloud_front/restriction.rb +8 -0
  59. data/lib/cloud_former/resource_properties/cloud_front/s3_origin.rb +8 -0
  60. data/lib/cloud_former/resource_properties/cloud_front/viewer_certificate.rb +10 -0
  61. data/lib/cloud_former/resource_properties/cloud_watch/metric_dimension.rb +9 -0
  62. data/lib/cloud_former/resource_properties/ec2/security_group_rule.rb +15 -0
  63. data/lib/cloud_former/resource_properties/elastic_load_balancing/access_logging_policy.rb +11 -0
  64. data/lib/cloud_former/resource_properties/elastic_load_balancing/app_cookie_stickiness_policy.rb +9 -0
  65. data/lib/cloud_former/resource_properties/elastic_load_balancing/connection_draining_policy.rb +9 -0
  66. data/lib/cloud_former/resource_properties/elastic_load_balancing/health_check.rb +12 -0
  67. data/lib/cloud_former/resource_properties/elastic_load_balancing/lb_cookie_stickiness_policy.rb +9 -0
  68. data/lib/cloud_former/resource_properties/elastic_load_balancing/listener.rb +13 -0
  69. data/lib/cloud_former/resource_properties/elastic_load_balancing/policy.rb +12 -0
  70. data/lib/cloud_former/resource_properties/resource_property.rb +13 -0
  71. data/lib/cloud_former/resource_properties/s3/cors_configuration.rb +8 -0
  72. data/lib/cloud_former/resource_properties/s3/cors_rule.rb +13 -0
  73. data/lib/cloud_former/resource_properties/s3/lifecycle_configuration.rb +8 -0
  74. data/lib/cloud_former/resource_properties/s3/lifecycle_rule.rb +13 -0
  75. data/lib/cloud_former/resource_properties/s3/lifecycle_rule_transition.rb +10 -0
  76. data/lib/cloud_former/resource_properties/s3/logging_configuration.rb +9 -0
  77. data/lib/cloud_former/resource_properties/s3/notification_configuration.rb +11 -0
  78. data/lib/cloud_former/resource_properties/s3/notification_topic_configuration.rb +9 -0
  79. data/lib/cloud_former/resource_properties/s3/versioning_configuration.rb +8 -0
  80. data/lib/cloud_former/resource_properties/s3/website_configuration.rb +16 -0
  81. data/lib/cloud_former/resource_properties/s3/website_configuration_redirect_all_requests_to.rb +9 -0
  82. data/lib/cloud_former/resource_properties/s3/website_configuration_routing_rules.rb +13 -0
  83. data/lib/cloud_former/resource_properties/s3/website_configuration_routing_rules_redirect_rule.rb +12 -0
  84. data/lib/cloud_former/resource_properties/s3/website_configuration_routing_rules_routing_rule_condition.rb +9 -0
  85. data/lib/cloud_former/resource_properties/sns/subscription.rb +9 -0
  86. data/lib/cloud_former/resources/auto_scaling/auto_scaling_group.rb +31 -0
  87. data/lib/cloud_former/resources/auto_scaling/launch_configuration.rb +26 -0
  88. data/lib/cloud_former/resources/cloud_formation/wait_condition.rb +10 -0
  89. data/lib/cloud_former/resources/cloud_formation/wait_condition_handle.rb +7 -0
  90. data/lib/cloud_former/resources/cloud_front/distribution.rb +9 -0
  91. data/lib/cloud_former/resources/cloud_watch/alarm.rb +22 -0
  92. data/lib/cloud_former/resources/ec2/security_group.rb +21 -0
  93. data/lib/cloud_former/resources/elastic_load_balancing/load_balancer.rb +35 -0
  94. data/lib/cloud_former/resources/iam/access_key.rb +10 -0
  95. data/lib/cloud_former/resources/iam/group.rb +13 -0
  96. data/lib/cloud_former/resources/iam/policy.rb +12 -0
  97. data/lib/cloud_former/resources/iam/user.rb +15 -0
  98. data/lib/cloud_former/resources/resource.rb +31 -0
  99. data/lib/cloud_former/resources/s3/bucket.rb +29 -0
  100. data/lib/cloud_former/resources/sns/topic.rb +10 -0
  101. data/lib/cloud_former/template.rb +42 -0
  102. data/lib/cloud_former/version.rb +3 -0
  103. data/lib/cloud_former.rb +134 -0
  104. data/spec/metadata_spec.rb +152 -0
  105. data/spec/parameter_spec.rb +46 -0
  106. data/spec/resources/auto_scaling/auto_scaling_group_spec.rb +33 -0
  107. data/spec/resources/auto_scaling/launch_configuration_spec.rb +11 -0
  108. data/spec/resources/auto_scaling/notification_configuration_spec.rb +20 -0
  109. data/spec/resources/iam/access_key_spec.rb +43 -0
  110. data/spec/resources/iam/user_spec.rb +141 -0
  111. data/spec/spec_helper.rb +81 -0
  112. data/spec/template_spec.rb +53 -0
  113. data/spec/type_enforcement.rb +8 -0
  114. metadata +223 -0
@@ -0,0 +1,12 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-elb-health-check.html
2
+ module CloudFormer
3
+ module ElasticLoadBalancing
4
+ class HealthCheck < ResourceProperty
5
+ aws_attribute :healthy_threshold, type: String
6
+ aws_attribute :interval, type: String
7
+ aws_attribute :target, type: String
8
+ aws_attribute :timeout, type: String
9
+ aws_attribute :unhealthy_threshold, type: String
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-elb-LBCookieStickinessPolicy.html
2
+ module CloudFormer
3
+ module ElasticLoadBalancing
4
+ class LbCookieStickinessPolicy < ResourceProperty
5
+ aws_attribute :cookie_expiration_period, type: String
6
+ aws_attribute :policy_name, type: String
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-elb-listener.html
2
+ module CloudFormer
3
+ module ElasticLoadBalancing
4
+ class Listener < ResourceProperty
5
+ aws_attribute :instance_port, type: String
6
+ aws_attribute :instance_protocol, type: String
7
+ aws_attribute :load_balancer_port, type: String
8
+ aws_attribute :policy_names, list: true, type: String
9
+ aws_attribute :protocol, type: String
10
+ aws_attribute :ssl_certificate_id, name: 'SSLCertificateId', type: String
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-elb-policy.html
2
+ module CloudFormer
3
+ module ElasticLoadBalancing
4
+ class Policy < ResourceProperty
5
+ aws_attribute :attributes, list: true, type: String
6
+ aws_attribute :instance_ports, list: true, type: String
7
+ aws_attribute :load_balancer_ports, list: true, type: String
8
+ aws_attribute :policy_name, type: String
9
+ aws_attribute :policy_type, type: String
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ module CloudFormer
2
+ class ResourceProperty
3
+ include HasPropertiesAndAttributes
4
+ include MakesJson
5
+
6
+ def initialize(&block)
7
+ if block_given?
8
+ self.instance_eval(&block)
9
+ end
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-cors.html
2
+ module CloudFormer
3
+ module S3
4
+ class CorsConfiguration < ResourceProperty
5
+ aws_attribute :cors_rules, embed: true, list: true, type: CorsRule
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-cors-corsrule.html
2
+ module CloudFormer
3
+ module S3
4
+ class CorsRule < ResourceProperty
5
+ aws_attribute :allowed_headers, list: true, type: String
6
+ aws_attribute :allowed_methods, list: true, type: String
7
+ aws_attribute :allowed_origins, list: true, type: String
8
+ aws_attribute :exposed_headers, list: true, type: String
9
+ aws_attribute :id, type: String
10
+ aws_attribute :max_age, type: Integer
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-lifecycleconfig.html
2
+ module CloudFormer
3
+ module S3
4
+ class LifecycleConfiguration < ResourceProperty
5
+ aws_attribute :rules, embed: true, list: true, type: LifecycleRule
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-lifecycleconfig-rule.html
2
+ module CloudFormer
3
+ module S3
4
+ class LifecycleRule < ResourceProperty
5
+ aws_attribute :expiration_date, type: String
6
+ aws_attribute :expiration_in_days, type: Integer
7
+ aws_attribute :id, type: String
8
+ aws_attribute :prefix, type: String
9
+ aws_attribute :status, type: String
10
+ aws_attribute :transition, embed: true, type: LifecycleRuleTransition
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-lifecycleconfig-rule-transition.html
2
+ module CloudFormer
3
+ module S3
4
+ class LifecycleRuleTransition < ResourceProperty
5
+ aws_attribute :storage_class, type: String
6
+ aws_attribute :transition_date, type: String
7
+ aws_attribute :transition_in_days, type: Integer
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-loggingconfig.html
2
+ module CloudFormer
3
+ module S3
4
+ class LoggingConfiguration < ResourceProperty
5
+ aws_attribute :destination_bucket_name, type: String
6
+ aws_attribute :log_file_prefix, type: String
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfig.html
2
+ module CloudFormer
3
+ module S3
4
+ class NotificationConfiguration < ResourceProperty
5
+ aws_attribute :topic_configurations,
6
+ embed: true,
7
+ list: true,
8
+ type: NotificationTopicConfiguration
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfig-topicconfig.html
2
+ module CloudFormer
3
+ module S3
4
+ class NotificationTopicConfiguration < ResourceProperty
5
+ aws_attribute :event, type: String
6
+ aws_attribute :topic, type: String
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-versioningconfig.html
2
+ module CloudFormer
3
+ module S3
4
+ class VersioningConfiguration < ResourceProperty
5
+ aws_attribute :status, type: String
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,16 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-websiteconfiguration.html
2
+ module CloudFormer
3
+ module S3
4
+ class WebsiteConfiguration < ResourceProperty
5
+ aws_attribute :error_document, type: String
6
+ aws_attribute :index_document, type: String
7
+ aws_attribute :redirect_all_requests_to,
8
+ embed: true,
9
+ type: WebsiteConfigurationRedirectAllRequestsTo
10
+ aws_attribute :routing_rules,
11
+ embed: true,
12
+ list: true,
13
+ type: WebsiteConfigurationRoutingRules
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-websiteconfiguration-redirectallrequeststo.html
2
+ module CloudFormer
3
+ module S3
4
+ class WebsiteConfigurationRedirectAllRequestsTo < ResourceProperty
5
+ aws_attribute :host_name, type: String
6
+ aws_attribute :protocol, type: String
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-websiteconfiguration-routingrules.html
2
+ module CloudFormer
3
+ module S3
4
+ class WebsiteConfigurationRoutingRules < ResourceProperty
5
+ aws_attribute :redirect_rule,
6
+ embed: true,
7
+ type: WebsiteConfigurationRoutingRulesRedirectRule
8
+ aws_attribute :routing_rule_condition,
9
+ embed: true,
10
+ type: WebsiteConfigurationRoutingRulesRoutingRuleCondition
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-websiteconfiguration-routingrules-redirectrule.html
2
+ module CloudFormer
3
+ module S3
4
+ class WebsiteConfigurationRoutingRulesRedirectRule < ResourceProperty
5
+ aws_attribute :host_name, type: String
6
+ aws_attribute :http_redirect_code, type: String
7
+ aws_attribute :protocol, type: String
8
+ aws_attribute :replace_key_prefix_with, type: String
9
+ aws_attribute :replace_key_with, type: String
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-websiteconfiguration-routingrules-routingrulecondition.html
2
+ module CloudFormer
3
+ module S3
4
+ class WebsiteConfigurationRoutingRulesRoutingRuleCondition < ResourceProperty
5
+ aws_attribute :http_error_code_returned_equals, type: String
6
+ aws_attribute :key_prefix_equals, type: String
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-subscription.html
2
+ module CloudFormer
3
+ module SNS
4
+ class Subscription < ResourceProperty
5
+ aws_attribute :endpoint, type: String
6
+ aws_attribute :protocol, type: String
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,31 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-group.html
2
+ module CloudFormer
3
+ module AutoScaling
4
+ class AutoScalingGroup < Resource
5
+
6
+ aws_property :availability_zones, required: true, list: true, type: String
7
+ aws_property :cooldown, type: String
8
+ aws_property :desired_capacity, type: String
9
+ aws_property :health_check_grace_period, type: Integer
10
+ aws_property :health_check_type, type: String
11
+ aws_property :instance_id, type: String
12
+ aws_property :launch_configuration_name, type: String
13
+ aws_property :load_balancer_names, list: true, type: String
14
+ aws_property :max_size, required: true, type: String
15
+ aws_property :metrics_collection,
16
+ list: true,
17
+ type: AutoScaling::MetricsCollection
18
+ aws_property :min_size, required: true, type: String
19
+ aws_property :notification_configuration,
20
+ embed: true,
21
+ type: AutoScaling::NotificationConfiguration
22
+ aws_property :placement_group, type: String
23
+ aws_property :tags, list: true, type: AutoScaling::Tag
24
+ aws_property :termination_policies, list: true, type: String
25
+ aws_property :vpc_zone_identifier,
26
+ name: 'VPCZoneIdentifier',
27
+ list: true,
28
+ type: String
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,26 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-launchconfig.html
2
+ module CloudFormer
3
+ module AutoScaling
4
+ class LaunchConfiguration < Resource
5
+ aws_property :associate_public_ip_address, type: Boolean
6
+ aws_property :block_device_mappings,
7
+ embed: true,
8
+ list: true,
9
+ type: BlockDeviceMapping
10
+ aws_property :ebs_optimized, type: Boolean
11
+ aws_property :iam_instance_profile, type: String
12
+ aws_property :image_id, type: String
13
+ aws_property :instance_id, type: String
14
+ aws_property :instance_monitoring, type: Boolean
15
+ aws_property :instance_type, type: String
16
+ aws_property :kernel_id, type: String
17
+ aws_property :key_name, type: String
18
+ aws_property :ram_disk_id, type: String
19
+ aws_property :security_groups,
20
+ list: true,
21
+ type: EC2::SecurityGroup
22
+ aws_property :spot_price, type: String
23
+ aws_property :user_data, type: String
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,10 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-waitcondition.html
2
+ module CloudFormer
3
+ module CloudFormation
4
+ class WaitCondition < Resource
5
+ aws_property :count, type: String
6
+ aws_property :handle, required: true, type: String
7
+ aws_property :timeout, required: true, type: String
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-waitconditionhandle.html
2
+ module CloudFormer
3
+ module CloudFormation
4
+ class WaitConditionHandle < Resource
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module CloudFormer
2
+ module CloudFront
3
+ class Distribution < Resource
4
+ aws_property :distribution_config,
5
+ embed: true,
6
+ type: DistributionConfiguration
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,22 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html
2
+ module CloudFormer
3
+ module CloudWatch
4
+ class Alarm < Resource
5
+ aws_property :actions_enabled, type: Boolean
6
+ aws_property :alarm_actions, list: true, type: String
7
+ aws_property :alarm_description, type: String
8
+ aws_property :alarm_name, type: String
9
+ aws_property :comparison_operator, type: String
10
+ aws_property :dimensions, embed: true, list: true, type: MetricDimension
11
+ aws_property :evaluation_periods, type: String
12
+ aws_property :insufficient_data_actions, list: true, type: String
13
+ aws_property :metric_name, type: String
14
+ aws_property :namespace, type: String
15
+ aws_property :ok_actions, name: 'OKActions', list: true, type: String
16
+ aws_property :period, type: String
17
+ aws_property :statistic, type: String
18
+ aws_property :threshold, type: String
19
+ aws_property :unit, type: String
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group.html
2
+ module CloudFormer
3
+ module EC2
4
+ class SecurityGroup < Resource
5
+ aws_property :group_description, type: String
6
+ aws_property :security_group_egress,
7
+ embed: true,
8
+ list: true,
9
+ type: SecurityGroupRule
10
+ aws_property :security_group_ingress,
11
+ embed: true,
12
+ list: true,
13
+ type: SecurityGroupRule
14
+ aws_property :tags,
15
+ embed: true,
16
+ list: true,
17
+ type: CloudFormation::ResourceTag
18
+ aws_property :vpc_id, type: String
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,35 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-elb.html
2
+ module CloudFormer
3
+ module ElasticLoadBalancing
4
+ class LoadBalancer < Resource
5
+ aws_property :access_logging_policy,
6
+ embed: true,
7
+ type: AccessLoggingPolicy
8
+ aws_property :app_cookie_stickiness_policy,
9
+ embed: true,
10
+ list: true,
11
+ type: AppCookieStickinessPolicy
12
+ aws_property :availability_zones, list: true, type: String
13
+ aws_property :connection_draining_policy,
14
+ embed: true,
15
+ type: ConnectionDrainingPolicy
16
+ aws_property :cross_zone, type: Boolean
17
+ aws_property :health_check, embed: true, type: HealthCheck
18
+ aws_property :instances, list: true, type: String
19
+ aws_property :lb_cookie_stickiness_policy,
20
+ embed: true,
21
+ name: 'LBCookieStickinessPolicy',
22
+ list: true,
23
+ type: LbCookieStickinessPolicy
24
+ aws_property :load_balancer_name, type: String
25
+ aws_property :listeners, embed: true, list: true, type: Listener
26
+ aws_property :policies,
27
+ embed: true,
28
+ list: true,
29
+ type: Policy
30
+ aws_property :scheme, type: String
31
+ aws_property :security_groups, list: true, type: EC2::SecurityGroup
32
+ aws_property :subnets, list: true, type: String
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,10 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-accesskey.html
2
+ module CloudFormer
3
+ module IAM
4
+ class AccessKey < Resource
5
+ aws_property :serial, type: Integer
6
+ aws_property :status, required: true, type: String
7
+ aws_property :user_name, required: true, type: String
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-user.html
2
+ module CloudFormer
3
+ module IAM
4
+ class Group < Resource
5
+ aws_property :path, type: String
6
+ aws_property :policies,
7
+ embed: true,
8
+ skip_properties: true,
9
+ list: true,
10
+ type: Policy
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-policy.html
2
+ module CloudFormer
3
+ module IAM
4
+ class Policy < Resource
5
+ aws_property :groups, required: true, list: true, type: String
6
+ aws_property :policy_document, required: true, type: Hash
7
+ aws_property :policy_name, required: true, type: String
8
+ aws_property :roles, list: true, type: String
9
+ aws_property :users, required: true, list: true, type: String
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-user.html
2
+ module CloudFormer
3
+ module IAM
4
+ class User < Resource
5
+ aws_property :path, type: String
6
+ aws_property :groups, list: true, type: Group
7
+ aws_property :login_profile, type: Hash
8
+ aws_property :policies,
9
+ embed: true,
10
+ skip_properties: true,
11
+ list: true,
12
+ type: Policy
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,31 @@
1
+ module CloudFormer
2
+ class Resource
3
+
4
+ include HasPropertiesAndAttributes
5
+ include MakesJson
6
+
7
+ json_attribute :aws_type, name: 'Type'
8
+
9
+ attr_reader :name
10
+ attr_reader :aws_type
11
+ attr_reader :metadata_items
12
+
13
+ aws_attribute :depends_on
14
+
15
+ def initialize(name, &block)
16
+ @name = name
17
+ if name.nil? || name.empty?
18
+ raise ArgumentError.new("Attempting to create a resource of type #{self.class.name} with no name")
19
+ end
20
+ @metadata_items = []
21
+ @aws_type = self.class.name.sub('CloudFormer', 'AWS')
22
+ if block_given?
23
+ self.instance_eval(&block)
24
+ end
25
+ end
26
+
27
+ def add_metadata(metadata)
28
+ @metadata_items << metadata
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket.html
2
+ module CloudFormer
3
+ module S3
4
+ class Bucket < Resource
5
+ aws_property :access_control, type: String
6
+ aws_property :bucket_name, type: String
7
+ aws_property :cors_configuration, embed: true, type: CorsConfiguration
8
+ aws_property :lifecycle_configuration,
9
+ embed: true,
10
+ type: LifecycleConfiguration
11
+ aws_property :logging_configuration,
12
+ embed: true,
13
+ type: LoggingConfiguration
14
+ aws_property :notification_configuration,
15
+ embed: true,
16
+ type: NotificationConfiguration
17
+ aws_property :tags,
18
+ embed: true,
19
+ list: true,
20
+ type: CloudFormation::ResourceTag
21
+ aws_property :versioning_configuration,
22
+ embed: true,
23
+ type: VersioningConfiguration
24
+ aws_property :website_configuration,
25
+ embed: true,
26
+ type: WebsiteConfiguration
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,10 @@
1
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-topic.html
2
+ module CloudFormer
3
+ module SNS
4
+ class Topic < Resource
5
+ aws_property :display_name, type: String
6
+ aws_property :subscription, embed: true, list: true, type: Subscription
7
+ aws_property :topic_name, type: String
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,42 @@
1
+ module CloudFormer
2
+ class Template
3
+
4
+ def initialize
5
+ @resources = []
6
+ @parameters = []
7
+ @mappings = []
8
+ @outputs = []
9
+ end
10
+
11
+ def add_parameter(parameter)
12
+ @parameters << parameter
13
+ end
14
+
15
+ def add_resource(resource)
16
+ @resources << resource
17
+ end
18
+
19
+ def dump_json
20
+ res = { 'AWSTemplateFormatVersion' => '2010-09-09' }
21
+
22
+ if @parameters.any?
23
+ parameter_res = {}
24
+ @parameters.each do |param|
25
+ parameter_res[param.name] = param.dump_json
26
+ end
27
+ res['Parameters'] = parameter_res
28
+ end
29
+
30
+ if @resources.any?
31
+ resource_res = {}
32
+ @resources.each do |resource|
33
+ resource_res[resource.name] = resource.dump_json
34
+ end
35
+ res['Resources'] = resource_res
36
+ end
37
+
38
+
39
+ res
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,3 @@
1
+ module CloudFormer
2
+ VERSION = '0.1.0'
3
+ end