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.
- checksums.yaml +7 -0
- data/.gitignore +51 -0
- data/.rspec +3 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +30 -0
- data/Rakefile +1 -0
- data/cloud_former.gemspec +26 -0
- data/lib/cloud_former/boolean.rb +5 -0
- data/lib/cloud_former/functions/base_64.rb +28 -0
- data/lib/cloud_former/functions/find_in_map.rb +36 -0
- data/lib/cloud_former/functions/function.rb +5 -0
- data/lib/cloud_former/functions/get_att.rb +19 -0
- data/lib/cloud_former/functions/get_azs.rb +14 -0
- data/lib/cloud_former/functions/join.rb +36 -0
- data/lib/cloud_former/has_properties_and_attributes.rb +104 -0
- data/lib/cloud_former/makes_json.rb +64 -0
- data/lib/cloud_former/metadata_resources/cloud_formation/authentication.rb +28 -0
- data/lib/cloud_former/metadata_resources/cloud_formation/authentication_item.rb +29 -0
- data/lib/cloud_former/metadata_resources/cloud_formation/config_set.rb +35 -0
- data/lib/cloud_former/metadata_resources/cloud_formation/config_set_command.rb +27 -0
- data/lib/cloud_former/metadata_resources/cloud_formation/config_set_file.rb +29 -0
- data/lib/cloud_former/metadata_resources/cloud_formation/config_set_group.rb +17 -0
- data/lib/cloud_former/metadata_resources/cloud_formation/config_set_item.rb +70 -0
- data/lib/cloud_former/metadata_resources/cloud_formation/config_set_service.rb +27 -0
- data/lib/cloud_former/metadata_resources/cloud_formation/config_set_user.rb +24 -0
- data/lib/cloud_former/metadata_resources/cloud_formation/init.rb +33 -0
- data/lib/cloud_former/metadata_resources/metadata_resource.rb +15 -0
- data/lib/cloud_former/parameters/commma_delimited_list_parameter.rb +9 -0
- data/lib/cloud_former/parameters/number_parameter.rb +9 -0
- data/lib/cloud_former/parameters/parameter.rb +30 -0
- data/lib/cloud_former/parameters/string_parameter.rb +9 -0
- data/lib/cloud_former/property_or_attribute.rb +49 -0
- data/lib/cloud_former/pseudo_parameters/account_id_parameter.rb +7 -0
- data/lib/cloud_former/pseudo_parameters/no_value_parameter.rb +7 -0
- data/lib/cloud_former/pseudo_parameters/notification_arns_parameter.rb +7 -0
- data/lib/cloud_former/pseudo_parameters/pseudo_parameter.rb +5 -0
- data/lib/cloud_former/pseudo_parameters/region_parameter.rb +7 -0
- data/lib/cloud_former/pseudo_parameters/stack_id_parameter.rb +7 -0
- data/lib/cloud_former/pseudo_parameters/stack_name_parameter.rb +7 -0
- data/lib/cloud_former/resource_properties/auto_scaling/block_device_mapping.rb +11 -0
- data/lib/cloud_former/resource_properties/auto_scaling/ebs_block_device.rb +12 -0
- data/lib/cloud_former/resource_properties/auto_scaling/metrics_collection.rb +9 -0
- data/lib/cloud_former/resource_properties/auto_scaling/notification_configuration.rb +16 -0
- data/lib/cloud_former/resource_properties/auto_scaling/tag.rb +10 -0
- data/lib/cloud_former/resource_properties/cloud_formation/resource_tag.rb +9 -0
- data/lib/cloud_former/resource_properties/cloud_front/cache_behavior.rb +15 -0
- data/lib/cloud_former/resource_properties/cloud_front/custom_error_response.rb +13 -0
- data/lib/cloud_former/resource_properties/cloud_front/custom_origin.rb +10 -0
- data/lib/cloud_former/resource_properties/cloud_front/default_cache_behavior.rb +14 -0
- data/lib/cloud_former/resource_properties/cloud_front/distribution_configuration.rb +27 -0
- data/lib/cloud_former/resource_properties/cloud_front/forwarded_values.rb +9 -0
- data/lib/cloud_former/resource_properties/cloud_front/forwarded_values_cookies.rb +9 -0
- data/lib/cloud_former/resource_properties/cloud_front/geo_restriction.rb +9 -0
- data/lib/cloud_former/resource_properties/cloud_front/logging.rb +10 -0
- data/lib/cloud_former/resource_properties/cloud_front/origin.rb +11 -0
- data/lib/cloud_former/resource_properties/cloud_front/restriction.rb +8 -0
- data/lib/cloud_former/resource_properties/cloud_front/s3_origin.rb +8 -0
- data/lib/cloud_former/resource_properties/cloud_front/viewer_certificate.rb +10 -0
- data/lib/cloud_former/resource_properties/cloud_watch/metric_dimension.rb +9 -0
- data/lib/cloud_former/resource_properties/ec2/security_group_rule.rb +15 -0
- data/lib/cloud_former/resource_properties/elastic_load_balancing/access_logging_policy.rb +11 -0
- data/lib/cloud_former/resource_properties/elastic_load_balancing/app_cookie_stickiness_policy.rb +9 -0
- data/lib/cloud_former/resource_properties/elastic_load_balancing/connection_draining_policy.rb +9 -0
- data/lib/cloud_former/resource_properties/elastic_load_balancing/health_check.rb +12 -0
- data/lib/cloud_former/resource_properties/elastic_load_balancing/lb_cookie_stickiness_policy.rb +9 -0
- data/lib/cloud_former/resource_properties/elastic_load_balancing/listener.rb +13 -0
- data/lib/cloud_former/resource_properties/elastic_load_balancing/policy.rb +12 -0
- data/lib/cloud_former/resource_properties/resource_property.rb +13 -0
- data/lib/cloud_former/resource_properties/s3/cors_configuration.rb +8 -0
- data/lib/cloud_former/resource_properties/s3/cors_rule.rb +13 -0
- data/lib/cloud_former/resource_properties/s3/lifecycle_configuration.rb +8 -0
- data/lib/cloud_former/resource_properties/s3/lifecycle_rule.rb +13 -0
- data/lib/cloud_former/resource_properties/s3/lifecycle_rule_transition.rb +10 -0
- data/lib/cloud_former/resource_properties/s3/logging_configuration.rb +9 -0
- data/lib/cloud_former/resource_properties/s3/notification_configuration.rb +11 -0
- data/lib/cloud_former/resource_properties/s3/notification_topic_configuration.rb +9 -0
- data/lib/cloud_former/resource_properties/s3/versioning_configuration.rb +8 -0
- data/lib/cloud_former/resource_properties/s3/website_configuration.rb +16 -0
- data/lib/cloud_former/resource_properties/s3/website_configuration_redirect_all_requests_to.rb +9 -0
- data/lib/cloud_former/resource_properties/s3/website_configuration_routing_rules.rb +13 -0
- data/lib/cloud_former/resource_properties/s3/website_configuration_routing_rules_redirect_rule.rb +12 -0
- data/lib/cloud_former/resource_properties/s3/website_configuration_routing_rules_routing_rule_condition.rb +9 -0
- data/lib/cloud_former/resource_properties/sns/subscription.rb +9 -0
- data/lib/cloud_former/resources/auto_scaling/auto_scaling_group.rb +31 -0
- data/lib/cloud_former/resources/auto_scaling/launch_configuration.rb +26 -0
- data/lib/cloud_former/resources/cloud_formation/wait_condition.rb +10 -0
- data/lib/cloud_former/resources/cloud_formation/wait_condition_handle.rb +7 -0
- data/lib/cloud_former/resources/cloud_front/distribution.rb +9 -0
- data/lib/cloud_former/resources/cloud_watch/alarm.rb +22 -0
- data/lib/cloud_former/resources/ec2/security_group.rb +21 -0
- data/lib/cloud_former/resources/elastic_load_balancing/load_balancer.rb +35 -0
- data/lib/cloud_former/resources/iam/access_key.rb +10 -0
- data/lib/cloud_former/resources/iam/group.rb +13 -0
- data/lib/cloud_former/resources/iam/policy.rb +12 -0
- data/lib/cloud_former/resources/iam/user.rb +15 -0
- data/lib/cloud_former/resources/resource.rb +31 -0
- data/lib/cloud_former/resources/s3/bucket.rb +29 -0
- data/lib/cloud_former/resources/sns/topic.rb +10 -0
- data/lib/cloud_former/template.rb +42 -0
- data/lib/cloud_former/version.rb +3 -0
- data/lib/cloud_former.rb +134 -0
- data/spec/metadata_spec.rb +152 -0
- data/spec/parameter_spec.rb +46 -0
- data/spec/resources/auto_scaling/auto_scaling_group_spec.rb +33 -0
- data/spec/resources/auto_scaling/launch_configuration_spec.rb +11 -0
- data/spec/resources/auto_scaling/notification_configuration_spec.rb +20 -0
- data/spec/resources/iam/access_key_spec.rb +43 -0
- data/spec/resources/iam/user_spec.rb +141 -0
- data/spec/spec_helper.rb +81 -0
- data/spec/template_spec.rb +53 -0
- data/spec/type_enforcement.rb +8 -0
- metadata +223 -0
data/lib/cloud_former.rb
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
require 'cloud_former/version'
|
|
2
|
+
require 'cloud_former/has_properties_and_attributes'
|
|
3
|
+
require 'cloud_former/makes_json'
|
|
4
|
+
|
|
5
|
+
module CloudFormer
|
|
6
|
+
|
|
7
|
+
autoload :Boolean, 'cloud_former/boolean'
|
|
8
|
+
autoload :Parameter, 'cloud_former/parameters/parameter'
|
|
9
|
+
autoload :CommaDelimitedListParameter, 'cloud_former/parameters/comma_delimited_list_parameter'
|
|
10
|
+
autoload :NumberParameter, 'cloud_former/parameters/number_parameter'
|
|
11
|
+
autoload :StringParameter, 'cloud_former/parameters/string_parameter'
|
|
12
|
+
|
|
13
|
+
autoload :PseudoParameter, 'cloud_former/pseudo_parameters/pseudo_parameter'
|
|
14
|
+
autoload :AccountIdParameter, 'cloud_former/pseudo_parameters/account_id_parameter'
|
|
15
|
+
autoload :NotificationARNsParameter, 'cloud_former/pseudo_parameters/notification_arns_parameter'
|
|
16
|
+
autoload :NoValueParameter, 'cloud_former/pseudo_parameters/no_value_parameter'
|
|
17
|
+
autoload :RegionParameter, 'cloud_former/pseudo_parameters/region_parameter'
|
|
18
|
+
autoload :StackIdParameter, 'cloud_former/pseudo_parameters/stack_id_parameter'
|
|
19
|
+
autoload :StackNameParameter, 'cloud_former/pseudo_parameters/stack_name_parameter'
|
|
20
|
+
|
|
21
|
+
autoload :Function, 'cloud_former/functions/function'
|
|
22
|
+
autoload :MetadataResource, 'cloud_former/metadata_resources/metadata_resource'
|
|
23
|
+
autoload :Resource, 'cloud_former/resources/resource'
|
|
24
|
+
autoload :ResourceProperty, 'cloud_former/resource_properties/resource_property'
|
|
25
|
+
|
|
26
|
+
module AutoScaling
|
|
27
|
+
autoload :AutoScalingGroup, 'cloud_former/resources/auto_scaling/auto_scaling_group'
|
|
28
|
+
autoload :BlockDeviceMapping, 'cloud_former/resource_properties/auto_scaling/block_device_mapping'
|
|
29
|
+
autoload :EbsBlockDevice, 'cloud_former/resource_properties/auto_scaling/ebs_block_device'
|
|
30
|
+
autoload :LaunchConfiguration, 'cloud_former/resources/auto_scaling/launch_configuration'
|
|
31
|
+
autoload :MetricsCollection, 'cloud_former/resource_properties/auto_scaling/metrics_collection'
|
|
32
|
+
autoload :NotificationConfiguration, 'cloud_former/resource_properties/auto_scaling/notification_configuration'
|
|
33
|
+
autoload :Tag, 'cloud_former/resource_properties/auto_scaling/tag'
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
module CloudFormation
|
|
37
|
+
autoload :Authentication, 'cloud_former/metadata_resources/cloud_formation/authentication'
|
|
38
|
+
autoload :AuthenticationItem, 'cloud_former/metadata_resources/cloud_formation/authentication_item'
|
|
39
|
+
autoload :Init, 'cloud_former/metadata_resources/cloud_formation/init'
|
|
40
|
+
autoload :ResourceTag, 'cloud_former/resource_properties/cloud_formation/resource_tag'
|
|
41
|
+
autoload :WaitConditionHandle, 'cloud_former/resources/cloud_formation/wait_condition_handle'
|
|
42
|
+
autoload :WaitCondition, 'cloud_former/resources/cloud_formation/wait_condition'
|
|
43
|
+
|
|
44
|
+
autoload :ConfigSet, 'cloud_former/metadata_resources/cloud_formation/config_set'
|
|
45
|
+
autoload :ConfigSetItem, 'cloud_former/metadata_resources/cloud_formation/config_set_item'
|
|
46
|
+
autoload :ConfigSetCommand, 'cloud_former/metadata_resources/cloud_formation/config_set_command'
|
|
47
|
+
autoload :ConfigSetFile, 'cloud_former/metadata_resources/cloud_formation/config_set_file'
|
|
48
|
+
autoload :ConfigSetGroup, 'cloud_former/metadata_resources/cloud_formation/config_set_group'
|
|
49
|
+
autoload :ConfigSetPackage, 'cloud_former/metadata_resources/cloud_formation/config_set_package'
|
|
50
|
+
autoload :ConfigSetService, 'cloud_former/metadata_resources/cloud_formation/config_set_service'
|
|
51
|
+
autoload :ConfigSetSource, 'cloud_former/metadata_resources/cloud_formation/config_set_source'
|
|
52
|
+
autoload :ConfigSetUser, 'cloud_former/metadata_resources/cloud_formation/config_set_user'
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
module CloudFront
|
|
56
|
+
autoload :CacheBehavior, 'cloud_former/resource_properties/cloud_front/cache_behavior'
|
|
57
|
+
autoload :CustomErrorResponse, 'cloud_former/resource_properties/cloud_front/custom_error_response'
|
|
58
|
+
autoload :CustomOrigin, 'cloud_former/resource_properties/cloud_front/custom_origin'
|
|
59
|
+
autoload :DefaultCacheBehavior, 'cloud_former/resource_properties/cloud_front/default_cache_behavior'
|
|
60
|
+
autoload :Distribution, 'cloud_former/resources/cloud_front/distribution'
|
|
61
|
+
autoload :DistributionConfiguration, 'cloud_former/resource_properties/cloud_front/distribution_configuration'
|
|
62
|
+
autoload :ForwardedValues, 'cloud_former/resource_properties/cloud_front/forwarded_values'
|
|
63
|
+
autoload :ForwardedValuesCookies, 'cloud_former/resource_properties/cloud_front/forwarded_values_cookies'
|
|
64
|
+
autoload :GeoRestriction, 'cloud_former/resource_properties/cloud_front/geo_restriction'
|
|
65
|
+
autoload :Logging, 'cloud_former/resource_properties/cloud_front/logging'
|
|
66
|
+
autoload :Origin, 'cloud_former/resource_properties/cloud_front/origin'
|
|
67
|
+
autoload :Restriction, 'cloud_former/resource_properties/cloud_front/restriction'
|
|
68
|
+
autoload :S3Origin, 'cloud_former/resource_properties/cloud_front/s3_origin'
|
|
69
|
+
autoload :ViewerCertificate, 'cloud_former/resource_properties/cloud_front/viewer_certificate'
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
module CloudWatch
|
|
73
|
+
autoload :Alarm, 'cloud_former/resources/cloud_watch/alarm'
|
|
74
|
+
autoload :MetricDimension, 'cloud_former/resource_properties/cloud_watch/metric_dimension'
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
module EC2
|
|
78
|
+
autoload :SecurityGroup, 'cloud_former/resources/ec2/security_group'
|
|
79
|
+
autoload :SecurityGroupRule, 'cloud_former/resource_properties/ec2/security_group_rule'
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
module ElasticLoadBalancing
|
|
83
|
+
autoload :AccessLoggingPolicy, 'cloud_former/resource_properties/elastic_load_balancing/access_logging_policy'
|
|
84
|
+
autoload :AppCookieStickinessPolicy, 'cloud_former/resource_properties/elastic_load_balancing/app_cookie_stickiness_policy'
|
|
85
|
+
autoload :ConnectionDrainingPolicy, 'cloud_former/resource_properties/elastic_load_balancing/connection_draining_policy'
|
|
86
|
+
autoload :HealthCheck, 'cloud_former/resource_properties/elastic_load_balancing/health_check'
|
|
87
|
+
autoload :LbCookieStickinessPolicy, 'cloud_former/resource_properties/elastic_load_balancing/lb_cookie_stickiness_policy'
|
|
88
|
+
autoload :Listener, 'cloud_former/resource_properties/elastic_load_balancing/listener'
|
|
89
|
+
autoload :LoadBalancer, 'cloud_former/resources/elastic_load_balancing/load_balancer'
|
|
90
|
+
autoload :Policy, 'cloud_former/resource_properties/elastic_load_balancing/policy'
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
module Functions
|
|
94
|
+
autoload :Base64, 'cloud_former/functions/base_64'
|
|
95
|
+
autoload :GetAtt, 'cloud_former/functions/get_att'
|
|
96
|
+
autoload :GetAZs, 'cloud_former/functions/get_azs'
|
|
97
|
+
autoload :FindInMap, 'cloud_former/functions/find_in_map'
|
|
98
|
+
autoload :Join, 'cloud_former/functions/join'
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
module IAM
|
|
102
|
+
autoload :AccessKey, 'cloud_former/resources/iam/access_key'
|
|
103
|
+
autoload :Group, 'cloud_former/resources/iam/group'
|
|
104
|
+
autoload :Policy, 'cloud_former/resources/iam/policy'
|
|
105
|
+
autoload :User, 'cloud_former/resources/iam/user'
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
module S3
|
|
109
|
+
autoload :Bucket, 'cloud_former/resources/s3/bucket'
|
|
110
|
+
autoload :CorsConfiguration, 'cloud_former/resource_properties/s3/cors_configuration'
|
|
111
|
+
autoload :CorsRule, 'cloud_former/resource_properties/s3/cors_rule'
|
|
112
|
+
autoload :LifecycleConfiguration, 'cloud_former/resource_properties/s3/lifecycle_configuration'
|
|
113
|
+
autoload :LifecycleRule, 'cloud_former/resource_properties/s3/lifecycle_rule'
|
|
114
|
+
autoload :LifecycleRuleTransition, 'cloud_former/resource_properties/s3/lifecycle_rule_transition'
|
|
115
|
+
autoload :LoggingConfiguration, 'cloud_former/resource_properties/s3/logging_configuration'
|
|
116
|
+
autoload :NotificationConfiguration, 'cloud_former/resource_properties/s3/notification_configuration'
|
|
117
|
+
autoload :NotificationTopicConfiguration, 'cloud_former/resource_properties/s3/notification_topic_configuration'
|
|
118
|
+
autoload :VersioningConfiguration, 'cloud_former/resource_properties/s3/versioning_configuration'
|
|
119
|
+
autoload :WebsiteConfiguration, 'cloud_former/resource_properties/s3/website_configuration'
|
|
120
|
+
autoload :WebsiteConfigurationRedirectAllRequestsTo, 'cloud_former/resource_properties/s3/website_configuration_redirect_all_requests_to'
|
|
121
|
+
autoload :WebsiteConfigurationRoutingRules, 'cloud_former/resource_properties/s3/website_configuration_routing_rules'
|
|
122
|
+
autoload :WebsiteConfigurationRoutingRulesRedirectRule, 'cloud_former/resource_properties/s3/website_configuration_routing_rules_redirect_rule'
|
|
123
|
+
autoload :WebsiteConfigurationRoutingRulesRoutingRuleCondition, 'cloud_former/resource_properties/s3/website_configuration_routing_rules_routing_rule_condition'
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
module SNS
|
|
127
|
+
autoload :Subscription, 'cloud_former/resource_properties/sns/subscription'
|
|
128
|
+
autoload :Topic, 'cloud_former/resources/sns/topic'
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
autoload :AllAvailabilityZones, 'cloud_former/all_availability_zones'
|
|
132
|
+
autoload :PropertyOrAttribute, 'cloud_former/property_or_attribute'
|
|
133
|
+
autoload :Template, 'cloud_former/template'
|
|
134
|
+
end
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'stupid metadata' do
|
|
4
|
+
|
|
5
|
+
let(:resource) do
|
|
6
|
+
CloudFormer::AutoScaling::LaunchConfiguration.new('LaunchConfig') do
|
|
7
|
+
key_name 'blahblah'
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'should produce JSON' do
|
|
12
|
+
expect(resource.dump_json).to eq({
|
|
13
|
+
'Type' => 'AWS::AutoScaling::LaunchConfiguration',
|
|
14
|
+
'Properties' => {
|
|
15
|
+
'KeyName' => 'blahblah'
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe 'with some authentication metadata' do
|
|
21
|
+
|
|
22
|
+
let(:authentication_item) do
|
|
23
|
+
CloudFormer::CloudFormation::AuthenticationItem.new do
|
|
24
|
+
access_key_id 12
|
|
25
|
+
password 'ack'
|
|
26
|
+
secret_key 'boom'
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
let(:authentication) do
|
|
31
|
+
item = authentication_item
|
|
32
|
+
CloudFormer::CloudFormation::Authentication.new do
|
|
33
|
+
items [item]
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'should produce json for the item' do
|
|
38
|
+
expect(authentication_item.dump_json).to eq({
|
|
39
|
+
'accessKeyId' => 12,
|
|
40
|
+
'password' => 'ack',
|
|
41
|
+
'secretKey' => 'boom'
|
|
42
|
+
})
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'should let me add the metadata to the resource' do
|
|
46
|
+
resource.add_metadata(authentication)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'should put the metadata in the json' do
|
|
50
|
+
resource.add_metadata(authentication)
|
|
51
|
+
expect(resource.dump_json).to eq({
|
|
52
|
+
'Type' => 'AWS::AutoScaling::LaunchConfiguration',
|
|
53
|
+
'Properties' => {
|
|
54
|
+
'KeyName' => 'blahblah'
|
|
55
|
+
},
|
|
56
|
+
'Metadata' => {
|
|
57
|
+
'AWS::CloudFormation::Authentication' => {
|
|
58
|
+
authentication_item.name => {
|
|
59
|
+
'accessKeyId' => 12,
|
|
60
|
+
'password' => 'ack',
|
|
61
|
+
'secretKey' => 'boom'
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
describe 'with some init metadata' do
|
|
70
|
+
|
|
71
|
+
let(:command) do
|
|
72
|
+
CloudFormer::CloudFormation::ConfigSetCommand.new do
|
|
73
|
+
name 'see what is in tmp'
|
|
74
|
+
command 'ls /tmp'
|
|
75
|
+
cwd '/root'
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
let(:file) do
|
|
80
|
+
CloudFormer::CloudFormation::ConfigSetFile.new do
|
|
81
|
+
name '/tmp/ack'
|
|
82
|
+
source 'hahahahaha'
|
|
83
|
+
mode '000666'
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
let(:config_set_item) do
|
|
88
|
+
cmd = command
|
|
89
|
+
f = file
|
|
90
|
+
CloudFormer::CloudFormation::ConfigSetItem.new do
|
|
91
|
+
name 'first'
|
|
92
|
+
commands [cmd]
|
|
93
|
+
files [f]
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
let(:config_set) do
|
|
98
|
+
item = config_set_item
|
|
99
|
+
CloudFormer::CloudFormation::ConfigSet.new do
|
|
100
|
+
name 'badass'
|
|
101
|
+
items [item]
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
let(:init) do
|
|
106
|
+
set = config_set
|
|
107
|
+
CloudFormer::CloudFormation::Init.new do
|
|
108
|
+
config_sets [set]
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it 'should produce json for the item' do
|
|
113
|
+
expect(init.dump_json).to eq({
|
|
114
|
+
'configSets' => { 'badass' => ['first'] },
|
|
115
|
+
"first" => {
|
|
116
|
+
"commands" => {
|
|
117
|
+
"see what is in tmp" => {"command"=>"ls /tmp", "cwd"=>"/root"}
|
|
118
|
+
},
|
|
119
|
+
"files" => {
|
|
120
|
+
"/tmp/ack"=>{"source"=>"hahahahaha", "mode"=>"000666"}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it 'should put the metadata in the json' do
|
|
127
|
+
resource.add_metadata(init)
|
|
128
|
+
expect(resource.dump_json).to eq({
|
|
129
|
+
'Type' => 'AWS::AutoScaling::LaunchConfiguration',
|
|
130
|
+
'Properties' => {
|
|
131
|
+
'KeyName' => 'blahblah'
|
|
132
|
+
},
|
|
133
|
+
'Metadata' => {
|
|
134
|
+
'AWS::CloudFormation::Init' => {
|
|
135
|
+
"configSets" => {"badass"=>["first"]},
|
|
136
|
+
"first" => {
|
|
137
|
+
"commands" => {
|
|
138
|
+
"see what is in tmp" => {"command"=>"ls /tmp", "cwd"=>"/root"}
|
|
139
|
+
},
|
|
140
|
+
"files" => {
|
|
141
|
+
"/tmp/ack"=>{"source"=>"hahahahaha", "mode"=>"000666"}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe CloudFormer::Parameter do
|
|
4
|
+
|
|
5
|
+
let(:param) { CloudFormer::StringParameter.new('woot') }
|
|
6
|
+
|
|
7
|
+
it 'should be a string' do
|
|
8
|
+
expect(param.type).to eq('String')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'should produce awesome json' do
|
|
12
|
+
expect(param.dump_json).to eq({"Type" => "String"})
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe 'when fully initialized' do
|
|
16
|
+
|
|
17
|
+
let(:param) do
|
|
18
|
+
CloudFormer::NumberParameter.new('booya') do
|
|
19
|
+
default 12
|
|
20
|
+
description 'This is an amazing number'
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'should have taken the type' do
|
|
25
|
+
expect(param.type).to eq('Number')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'should have taken the description' do
|
|
29
|
+
expect(param.description).to eq('This is an amazing number')
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'should have taken the default' do
|
|
33
|
+
expect(param.default).to eq(12)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'should produce awesome json' do
|
|
37
|
+
expect(param.dump_json).to eq({
|
|
38
|
+
"Type" => "Number",
|
|
39
|
+
"Default" => 12,
|
|
40
|
+
"Description" => "This is an amazing number"
|
|
41
|
+
})
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe CloudFormer::AutoScaling::AutoScalingGroup do
|
|
4
|
+
|
|
5
|
+
let(:config) do
|
|
6
|
+
notification_config = CloudFormer::AutoScaling::NotificationConfiguration.new do
|
|
7
|
+
topic_arn 'abc'
|
|
8
|
+
notification_types [
|
|
9
|
+
CloudFormer::AutoScaling::NotificationConfiguration::LAUNCH_ERROR
|
|
10
|
+
]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
CloudFormer::AutoScaling::AutoScalingGroup.new('ASG') do
|
|
14
|
+
cooldown 30
|
|
15
|
+
notification_configuration notification_config
|
|
16
|
+
availability_zones CloudFormer::Functions::GetAZs.new
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'should make some awesome json' do
|
|
21
|
+
expect(config.dump_json).to eq({
|
|
22
|
+
"Type" => "AWS::AutoScaling::AutoScalingGroup",
|
|
23
|
+
"Properties" => {
|
|
24
|
+
"NotificationConfiguration" => {
|
|
25
|
+
"NotificationTypes" => ["autoscaling:EC2_INSTANCE_LAUNCH_ERROR"],
|
|
26
|
+
"TopicARN" => "abc",
|
|
27
|
+
},
|
|
28
|
+
"Cooldown" => 30,
|
|
29
|
+
"AvailabilityZones" => { "Fn::GetAZs" => "" }
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe CloudFormer::AutoScaling::AutoScalingGroup do
|
|
4
|
+
|
|
5
|
+
it 'should work with a boolean attribute' do
|
|
6
|
+
config = CloudFormer::AutoScaling::LaunchConfiguration.new('LC') do
|
|
7
|
+
associate_public_ip_address true
|
|
8
|
+
end
|
|
9
|
+
expect(config.associate_public_ip_address).to eq(true)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe CloudFormer::AutoScaling::NotificationConfiguration do
|
|
4
|
+
|
|
5
|
+
let(:config) do
|
|
6
|
+
CloudFormer::AutoScaling::NotificationConfiguration.new do
|
|
7
|
+
topic_arn 'abc'
|
|
8
|
+
notification_types [
|
|
9
|
+
CloudFormer::AutoScaling::NotificationConfiguration::LAUNCH_ERROR
|
|
10
|
+
]
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'should make some awesome json' do
|
|
15
|
+
expect(config.dump_json).to eq({
|
|
16
|
+
"NotificationTypes" => ["autoscaling:EC2_INSTANCE_LAUNCH_ERROR"],
|
|
17
|
+
"TopicARN" => "abc"
|
|
18
|
+
})
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe CloudFormer::IAM::AccessKey do
|
|
4
|
+
|
|
5
|
+
let(:access_key) do
|
|
6
|
+
CloudFormer::IAM::AccessKey.new('key') do
|
|
7
|
+
serial 1
|
|
8
|
+
status 'Active'
|
|
9
|
+
user_name 'aubrey'
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'should let me get the status' do
|
|
14
|
+
expect(access_key.status).to eq('Active')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'should make some awesome json' do
|
|
18
|
+
expect(access_key.dump_json).to eq({
|
|
19
|
+
'Type' => 'AWS::IAM::AccessKey',
|
|
20
|
+
'Properties' => {
|
|
21
|
+
'Serial' => 1,
|
|
22
|
+
'Status' => 'Active',
|
|
23
|
+
'UserName' => 'aubrey'
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'should be able to use a reference to a parameter' do
|
|
29
|
+
param = CloudFormer::StringParameter.new('ack')
|
|
30
|
+
access_key = CloudFormer::IAM::AccessKey.new('KEY') do
|
|
31
|
+
user_name param
|
|
32
|
+
end
|
|
33
|
+
expect(access_key.dump_json).to eq({
|
|
34
|
+
'Type' => 'AWS::IAM::AccessKey',
|
|
35
|
+
'Properties' => {
|
|
36
|
+
'UserName' => {
|
|
37
|
+
'Ref' => 'ack'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe CloudFormer::IAM::User do
|
|
4
|
+
|
|
5
|
+
describe 'with a basic user' do
|
|
6
|
+
let(:group1) do
|
|
7
|
+
CloudFormer::IAM::Group.new('group1') do
|
|
8
|
+
path 'ack'
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
let(:group2) do
|
|
13
|
+
CloudFormer::IAM::Group.new('group2') do
|
|
14
|
+
path 'acky'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
let(:user) do
|
|
19
|
+
g1 = group1
|
|
20
|
+
g2 = group2
|
|
21
|
+
CloudFormer::IAM::User.new('USER') do
|
|
22
|
+
path 'a/b/c'
|
|
23
|
+
groups [g1, g2]
|
|
24
|
+
login_profile({ 'Password' => 'ack' })
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'should let me get the status' do
|
|
29
|
+
expect(user.path).to eq('a/b/c')
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'should make some awesome json' do
|
|
33
|
+
expect(user.dump_json).to eq({
|
|
34
|
+
'Type' => 'AWS::IAM::User',
|
|
35
|
+
'Properties' => {
|
|
36
|
+
'Path' => 'a/b/c',
|
|
37
|
+
'Groups' => [
|
|
38
|
+
{ 'Ref' => 'group1' },
|
|
39
|
+
{ 'Ref' => 'group2' }
|
|
40
|
+
],
|
|
41
|
+
'LoginProfile' => {
|
|
42
|
+
'Password' => 'ack'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe 'with some policies' do
|
|
50
|
+
|
|
51
|
+
let(:group1) do
|
|
52
|
+
CloudFormer::IAM::Group.new('group1') do
|
|
53
|
+
path 'ack'
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
let(:group2) do
|
|
58
|
+
CloudFormer::IAM::Group.new('group2') do
|
|
59
|
+
path 'acky'
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
let(:policy1) do
|
|
64
|
+
CloudFormer::IAM::Policy.new('POLICY') do
|
|
65
|
+
policy_name 'root'
|
|
66
|
+
policy_document({
|
|
67
|
+
'Statement' => [{
|
|
68
|
+
'Effect' => 'Allow',
|
|
69
|
+
'Action' => 'cloudformation:DescribeStackResource',
|
|
70
|
+
'Resource' => '*'
|
|
71
|
+
}]
|
|
72
|
+
})
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
let(:policy2) do
|
|
77
|
+
CloudFormer::IAM::Policy.new('POLICY') do
|
|
78
|
+
policy_name 'root'
|
|
79
|
+
policy_document({
|
|
80
|
+
'Statement' => [{
|
|
81
|
+
'Effect' => 'DISALLOW',
|
|
82
|
+
'Action' => 'cloudformation:DescribeStackResource',
|
|
83
|
+
'Resource' => '*'
|
|
84
|
+
}]
|
|
85
|
+
})
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
let(:user) do
|
|
90
|
+
p1 = policy1
|
|
91
|
+
p2 = policy2
|
|
92
|
+
g1 = group1
|
|
93
|
+
g2 = group2
|
|
94
|
+
CloudFormer::IAM::User.new('USER') do
|
|
95
|
+
path 'a/b/c'
|
|
96
|
+
groups [g1, g2]
|
|
97
|
+
login_profile({ 'Password' => 'ack' })
|
|
98
|
+
policies [p1, p2]
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it 'should make some awesome json' do
|
|
103
|
+
expect(user.dump_json).to eq({
|
|
104
|
+
'Type' => 'AWS::IAM::User',
|
|
105
|
+
'Properties' => {
|
|
106
|
+
'Path' => 'a/b/c',
|
|
107
|
+
'Groups' => [
|
|
108
|
+
{ 'Ref' => 'group1' },
|
|
109
|
+
{ 'Ref' => 'group2' }
|
|
110
|
+
],
|
|
111
|
+
'LoginProfile' => {
|
|
112
|
+
'Password' => 'ack'
|
|
113
|
+
},
|
|
114
|
+
'Policies' => [
|
|
115
|
+
{
|
|
116
|
+
"PolicyName"=>"root",
|
|
117
|
+
"PolicyDocument"=>{
|
|
118
|
+
"Statement"=>[{
|
|
119
|
+
"Effect"=>"Allow",
|
|
120
|
+
"Action"=>"cloudformation:DescribeStackResource",
|
|
121
|
+
"Resource"=>"*"
|
|
122
|
+
}]
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"PolicyName"=>"root",
|
|
127
|
+
"PolicyDocument"=>{
|
|
128
|
+
"Statement"=>[{
|
|
129
|
+
"Effect"=>"DISALLOW",
|
|
130
|
+
"Action"=>"cloudformation:DescribeStackResource",
|
|
131
|
+
"Resource"=>"*"
|
|
132
|
+
}]
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require 'rspec'
|
|
2
|
+
require 'cloud_former'
|
|
3
|
+
|
|
4
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
|
5
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
|
6
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
|
7
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
|
8
|
+
#
|
|
9
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
|
10
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
|
11
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
|
12
|
+
# individual file that may not need all of that loaded. Instead, make a
|
|
13
|
+
# separate helper file that requires this one and then use it only in the specs
|
|
14
|
+
# that actually need it.
|
|
15
|
+
#
|
|
16
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
|
17
|
+
# users commonly want.
|
|
18
|
+
#
|
|
19
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
20
|
+
RSpec.configure do |config|
|
|
21
|
+
# The settings below are suggested to provide a good initial experience
|
|
22
|
+
# with RSpec, but feel free to customize to your heart's content.
|
|
23
|
+
=begin
|
|
24
|
+
# These two settings work together to allow you to limit a spec run
|
|
25
|
+
# to individual examples or groups you care about by tagging them with
|
|
26
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
|
27
|
+
# get run.
|
|
28
|
+
config.filter_run :focus
|
|
29
|
+
config.run_all_when_everything_filtered = true
|
|
30
|
+
|
|
31
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
|
32
|
+
# file, and it's useful to allow more verbose output when running an
|
|
33
|
+
# individual spec file.
|
|
34
|
+
if config.files_to_run.one?
|
|
35
|
+
# Use the documentation formatter for detailed output,
|
|
36
|
+
# unless a formatter has already been configured
|
|
37
|
+
# (e.g. via a command-line flag).
|
|
38
|
+
config.default_formatter = 'doc'
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Print the 10 slowest examples and example groups at the
|
|
42
|
+
# end of the spec run, to help surface which specs are running
|
|
43
|
+
# particularly slow.
|
|
44
|
+
config.profile_examples = 10
|
|
45
|
+
|
|
46
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
47
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
48
|
+
# the seed, which is printed after each run.
|
|
49
|
+
# --seed 1234
|
|
50
|
+
config.order = :random
|
|
51
|
+
|
|
52
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
|
53
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
|
54
|
+
# test failures related to randomization by passing the same `--seed` value
|
|
55
|
+
# as the one that triggered the failure.
|
|
56
|
+
Kernel.srand config.seed
|
|
57
|
+
|
|
58
|
+
# rspec-expectations config goes here. You can use an alternate
|
|
59
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
|
60
|
+
# assertions if you prefer.
|
|
61
|
+
config.expect_with :rspec do |expectations|
|
|
62
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
|
63
|
+
# For more details, see:
|
|
64
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
|
65
|
+
expectations.syntax = :expect
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
|
69
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
|
70
|
+
config.mock_with :rspec do |mocks|
|
|
71
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
|
72
|
+
# For more details, see:
|
|
73
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
|
74
|
+
mocks.syntax = :expect
|
|
75
|
+
|
|
76
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
|
77
|
+
# a real object. This is generally recommended.
|
|
78
|
+
mocks.verify_partial_doubles = true
|
|
79
|
+
end
|
|
80
|
+
=end
|
|
81
|
+
end
|