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
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 5d8743bff53e116042cdff3b772edec29cacbf44
|
|
4
|
+
data.tar.gz: a453eb16e7bb802f4bdb9889b4910b93fc3f76f9
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 3c37c9232b02be8d1faa4ed9a2545268162b925a00b5149d476b51cbee8a152a2ddaaa86b1d423fc189b394dbf334a94402a677e3480b16b5b3952dd8bf329b9
|
|
7
|
+
data.tar.gz: 6d3d55b353aba25cfb28c741c0aee571b510b2d8ec0cd60b2c7309d797331a15ed512b6c9d7cf211c473518f40f84494ed8a3618e13ab26a2c9f1754a1b953fd
|
data/.gitignore
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
|
|
4
|
+
.bundle
|
|
5
|
+
.config
|
|
6
|
+
.yardoc
|
|
7
|
+
Gemfile.lock
|
|
8
|
+
InstalledFiles
|
|
9
|
+
_yardoc
|
|
10
|
+
coverage
|
|
11
|
+
doc/
|
|
12
|
+
lib/bundler/man
|
|
13
|
+
pkg
|
|
14
|
+
rdoc
|
|
15
|
+
spec/reports
|
|
16
|
+
test/tmp
|
|
17
|
+
test/version_tmp
|
|
18
|
+
tmp
|
|
19
|
+
|
|
20
|
+
/.config
|
|
21
|
+
/coverage/
|
|
22
|
+
/InstalledFiles
|
|
23
|
+
/pkg/
|
|
24
|
+
/spec/reports/
|
|
25
|
+
/test/tmp/
|
|
26
|
+
/test/version_tmp/
|
|
27
|
+
/tmp/
|
|
28
|
+
|
|
29
|
+
## Specific to RubyMotion:
|
|
30
|
+
.dat*
|
|
31
|
+
.repl_history
|
|
32
|
+
build/
|
|
33
|
+
|
|
34
|
+
## Documentation cache and generated files:
|
|
35
|
+
/.yardoc/
|
|
36
|
+
/_yardoc/
|
|
37
|
+
/doc/
|
|
38
|
+
/rdoc/
|
|
39
|
+
|
|
40
|
+
## Environment normalisation:
|
|
41
|
+
/.bundle/
|
|
42
|
+
/lib/bundler/man/
|
|
43
|
+
|
|
44
|
+
# for a library or gem, you might want to ignore these files since the code is
|
|
45
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
46
|
+
# Gemfile.lock
|
|
47
|
+
# .ruby-version
|
|
48
|
+
# .ruby-gemset
|
|
49
|
+
|
|
50
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
51
|
+
.rvmrc
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 Custora
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2014 Aubrey Holland
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
cloud_former
|
|
2
|
+
============
|
|
3
|
+
|
|
4
|
+
A Ruby DSL for creating CloudFormation templates
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
Add this line to your application's Gemfile:
|
|
9
|
+
|
|
10
|
+
gem 'cloud_former'
|
|
11
|
+
|
|
12
|
+
And then execute:
|
|
13
|
+
|
|
14
|
+
$ bundle
|
|
15
|
+
|
|
16
|
+
Or install it yourself as:
|
|
17
|
+
|
|
18
|
+
$ gem install cloud_former
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
TODO: Write usage instructions here
|
|
23
|
+
|
|
24
|
+
## Contributing
|
|
25
|
+
|
|
26
|
+
1. Fork it ( http://github.com/<my-github-username>/cloud_former/fork )
|
|
27
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
28
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
29
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
30
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'cloud_former/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'cloud_former'
|
|
8
|
+
spec.version = CloudFormer::VERSION
|
|
9
|
+
spec.authors = ["Aubrey Holland"]
|
|
10
|
+
spec.email = ["aubreyholland@gmail.com"]
|
|
11
|
+
spec.summary = %q{A Ruby DSL for creating CloudFormation templates}
|
|
12
|
+
spec.description = %q{Write a longer description.}
|
|
13
|
+
spec.homepage = 'http://github.com/custora/cloud_former'
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_dependency 'activesupport', '~> 4.1'
|
|
22
|
+
|
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
|
24
|
+
spec.add_development_dependency "rake", '~> 10.3'
|
|
25
|
+
spec.add_development_dependency "rspec", '~> 3.0'
|
|
26
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module CloudFormer
|
|
2
|
+
module Functions
|
|
3
|
+
class Base64 < Function
|
|
4
|
+
|
|
5
|
+
def initialize(data)
|
|
6
|
+
@data = data
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def dump_json
|
|
10
|
+
{ 'Fn::Base64' => transform_data(@data) }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def acts_as_string?
|
|
14
|
+
true
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def transform_data(data)
|
|
20
|
+
if data.is_a?(Function)
|
|
21
|
+
data.dump_json
|
|
22
|
+
else
|
|
23
|
+
data
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module CloudFormer
|
|
2
|
+
module Functions
|
|
3
|
+
class FindInMap < Function
|
|
4
|
+
|
|
5
|
+
def initialize(map_name, top_level_key, second_level_key)
|
|
6
|
+
@map_name = map_name
|
|
7
|
+
@top_level_key = top_level_key
|
|
8
|
+
@second_level_key = second_level_key
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def dump_json
|
|
12
|
+
{
|
|
13
|
+
'Fn::FindInMap' => [
|
|
14
|
+
@map_name,
|
|
15
|
+
transform_key(@top_level_key),
|
|
16
|
+
transform_key(@second_level_key)
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def transform_key(key)
|
|
24
|
+
if key.is_a?(Parameter) || key.is_a?(PseudoParameter)
|
|
25
|
+
{ 'Ref' => key.name }
|
|
26
|
+
elsif key.is_a?(Function)
|
|
27
|
+
key.dump_json
|
|
28
|
+
elsif key.is_a?(Resource)
|
|
29
|
+
{ 'Ref' => key.name }
|
|
30
|
+
else
|
|
31
|
+
key
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module CloudFormer
|
|
2
|
+
module Functions
|
|
3
|
+
class GetAtt < Function
|
|
4
|
+
|
|
5
|
+
def initialize(resource, attribute)
|
|
6
|
+
@resource = resource
|
|
7
|
+
@attribute = attribute
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def acts_as_string?
|
|
11
|
+
true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def dump_json
|
|
15
|
+
{ 'Fn::GetAtt' => [@resource.name, @attribute] }
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module CloudFormer
|
|
2
|
+
module Functions
|
|
3
|
+
class Join < Function
|
|
4
|
+
|
|
5
|
+
def initialize(join_string, pieces)
|
|
6
|
+
@join_string = join_string
|
|
7
|
+
@pieces = pieces
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def acts_as_string?
|
|
11
|
+
true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def dump_json
|
|
15
|
+
mapped_pieces = @pieces.map do |piece|
|
|
16
|
+
if piece.is_a?(Parameter) || piece.is_a?(PseudoParameter)
|
|
17
|
+
{ 'Ref' => piece.name }
|
|
18
|
+
elsif piece.is_a?(Function)
|
|
19
|
+
piece.dump_json
|
|
20
|
+
elsif piece.is_a?(Resource)
|
|
21
|
+
{ 'Ref' => piece.name }
|
|
22
|
+
else
|
|
23
|
+
piece
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
{
|
|
28
|
+
'Fn::Join' => [
|
|
29
|
+
@join_string,
|
|
30
|
+
mapped_pieces
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
module CloudFormer
|
|
2
|
+
module HasPropertiesAndAttributes
|
|
3
|
+
|
|
4
|
+
def self.included(base)
|
|
5
|
+
base.extend ClassMethods
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
module ClassMethods
|
|
9
|
+
|
|
10
|
+
def aws_property(name, options={})
|
|
11
|
+
@aws_properties ||= []
|
|
12
|
+
@aws_properties << PropertyOrAttribute.new(name, options)
|
|
13
|
+
make_aws_accessor(name, options)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def aws_attribute(name, options={})
|
|
17
|
+
@aws_attributes ||= []
|
|
18
|
+
@aws_attributes << PropertyOrAttribute.new(name, options)
|
|
19
|
+
make_aws_accessor(name, options)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def check_type_of_aws_value(val, options)
|
|
23
|
+
if !val.is_a?(options[:type])
|
|
24
|
+
failed = true
|
|
25
|
+
if options[:type] == String
|
|
26
|
+
if val.is_a?(Fixnum)
|
|
27
|
+
failed = false
|
|
28
|
+
elsif val.respond_to?(:acts_as_string?) && val.acts_as_string?
|
|
29
|
+
failed = false
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
if val.is_a?(Parameter) || val.is_a?(Resource)
|
|
34
|
+
failed = false
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
if options[:type] == Boolean && val == true || val == false
|
|
38
|
+
failed = false
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
if failed
|
|
42
|
+
raise ArgumentError.new(
|
|
43
|
+
"A #{options[:type].name} is required for #{name} in #{self.name}, but a #{val.class.name} was given."
|
|
44
|
+
)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def make_aws_accessor(name, options)
|
|
50
|
+
define_method(name) do |val=nil|
|
|
51
|
+
if val
|
|
52
|
+
if options[:list] && !val.respond_to?(:each)
|
|
53
|
+
unless val.respond_to?(:acts_as_list?) && val.acts_as_list?
|
|
54
|
+
raise ArgumentError.new(
|
|
55
|
+
"A list is required for #{name} in #{self.class.name}, but a #{val.class.name} was given."
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
if options[:list]
|
|
61
|
+
unless val.respond_to?(:acts_as_list?) && val.acts_as_list?
|
|
62
|
+
val.each do |item|
|
|
63
|
+
self.class.check_type_of_aws_value(item, options)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
else
|
|
67
|
+
self.class.check_type_of_aws_value(val, options)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
instance_variable_set("@#{name}", val)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
if instance_variable_defined?("@#{name}")
|
|
74
|
+
instance_variable_get("@#{name}")
|
|
75
|
+
else
|
|
76
|
+
nil
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def aws_properties
|
|
82
|
+
answer = []
|
|
83
|
+
if defined?(@aws_properties)
|
|
84
|
+
answer = @aws_properties
|
|
85
|
+
end
|
|
86
|
+
if superclass && superclass.respond_to?(:aws_properties)
|
|
87
|
+
answer += superclass.aws_properties
|
|
88
|
+
end
|
|
89
|
+
answer
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def aws_attributes
|
|
93
|
+
answer = []
|
|
94
|
+
if defined?(@aws_attributes)
|
|
95
|
+
answer = @aws_attributes
|
|
96
|
+
end
|
|
97
|
+
if superclass && superclass.respond_to?(:aws_attributes)
|
|
98
|
+
answer += superclass.aws_attributes
|
|
99
|
+
end
|
|
100
|
+
answer
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require 'active_support'
|
|
2
|
+
require 'active_support/inflector/inflections'
|
|
3
|
+
require 'active_support/core_ext/object/try.rb'
|
|
4
|
+
|
|
5
|
+
module CloudFormer
|
|
6
|
+
module MakesJson
|
|
7
|
+
|
|
8
|
+
def self.included(base)
|
|
9
|
+
base.extend ClassMethods
|
|
10
|
+
base.class_variable_set('@@json_attributes', [])
|
|
11
|
+
base.class_variable_set('@@embed_properties', false)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def dump_json
|
|
15
|
+
res = {}
|
|
16
|
+
self.class.class_variable_get('@@json_attributes').each do |att|
|
|
17
|
+
use_name = att[:options][:name] || ActiveSupport::Inflector.camelize(att[:name])
|
|
18
|
+
res[use_name] = self.send(att[:name])
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
properties = {}
|
|
22
|
+
|
|
23
|
+
self.class.aws_properties.try(:each) do |property|
|
|
24
|
+
val = property.as_json_for(self)
|
|
25
|
+
if val
|
|
26
|
+
use_name = property.options[:name]
|
|
27
|
+
use_name ||= ActiveSupport::Inflector.camelize(property.name)
|
|
28
|
+
properties[use_name] = val
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
self.class.aws_attributes.try(:each) do |attribute|
|
|
33
|
+
val = attribute.as_json_for(self)
|
|
34
|
+
if val
|
|
35
|
+
use_name = attribute.options[:name]
|
|
36
|
+
use_name ||= ActiveSupport::Inflector.camelize(attribute.name)
|
|
37
|
+
res[use_name] = val
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
if properties.any?
|
|
42
|
+
res['Properties'] = properties
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
if respond_to?('metadata_items') && metadata_items.any?
|
|
46
|
+
metadata = {}
|
|
47
|
+
metadata_items.each do |meta|
|
|
48
|
+
metadata[meta.aws_type] = meta.dump_json
|
|
49
|
+
end
|
|
50
|
+
res['Metadata'] = metadata
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
res
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
module ClassMethods
|
|
57
|
+
|
|
58
|
+
def json_attribute(name, options={})
|
|
59
|
+
class_variable_get('@@json_attributes') << { name: name, options: options }
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-authentication.html
|
|
2
|
+
module CloudFormer
|
|
3
|
+
|
|
4
|
+
module CloudFormation
|
|
5
|
+
class Authentication < MetadataResource
|
|
6
|
+
|
|
7
|
+
def initialize
|
|
8
|
+
super
|
|
9
|
+
@aws_type = 'AWS::CloudFormation::Authentication'
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def items(values=nil)
|
|
13
|
+
if values
|
|
14
|
+
@authentication_items = values
|
|
15
|
+
end
|
|
16
|
+
@authentication_items
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def dump_json
|
|
20
|
+
res = {}
|
|
21
|
+
(@authentication_items || []).each do |item|
|
|
22
|
+
res[item.name] = item.dump_json
|
|
23
|
+
end
|
|
24
|
+
res
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-authentication.html
|
|
2
|
+
module CloudFormer
|
|
3
|
+
module CloudFormation
|
|
4
|
+
class AuthenticationItem < MetadataResource
|
|
5
|
+
|
|
6
|
+
attr_reader :name
|
|
7
|
+
|
|
8
|
+
aws_attribute :access_key_id, name: 'accessKeyId', type: String
|
|
9
|
+
aws_attribute :buckets, name: 'buckets', list: true, type: String
|
|
10
|
+
aws_attribute :password, name: 'password', type: String
|
|
11
|
+
aws_attribute :secret_key, name: 'secretKey', type: String
|
|
12
|
+
aws_attribute :type, name: 'type', type: String
|
|
13
|
+
aws_attribute :uris, name: 'uris', list: true, type: String
|
|
14
|
+
aws_attribute :username, name: 'username', type: String
|
|
15
|
+
aws_attribute :role_name, name: 'roleName', type: String
|
|
16
|
+
|
|
17
|
+
def initialize
|
|
18
|
+
super
|
|
19
|
+
@aws_type = 'AWS::CloudFormation::AuthenticationItem'
|
|
20
|
+
@name = "AuthenticationItem#{self.class.next_id}"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.next_id
|
|
24
|
+
@@current_id ||= 1
|
|
25
|
+
@@current_id += 1
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html#aws-resource-init-commands
|
|
2
|
+
module CloudFormer
|
|
3
|
+
|
|
4
|
+
module CloudFormation
|
|
5
|
+
class ConfigSet < MetadataResource
|
|
6
|
+
|
|
7
|
+
def initialize
|
|
8
|
+
super
|
|
9
|
+
@aws_type = 'AWS::CloudFormation::ConfigSet'
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def items(val=nil)
|
|
13
|
+
if val
|
|
14
|
+
@items = val
|
|
15
|
+
end
|
|
16
|
+
@items
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def name(val=nil)
|
|
20
|
+
if val
|
|
21
|
+
@name = val
|
|
22
|
+
end
|
|
23
|
+
@name
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def dump_json
|
|
27
|
+
res = {}
|
|
28
|
+
(@items || []).each do |item|
|
|
29
|
+
res[item.name] = item.dump_json
|
|
30
|
+
end
|
|
31
|
+
res
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html#aws-resource-init-commands
|
|
2
|
+
module CloudFormer
|
|
3
|
+
|
|
4
|
+
module CloudFormation
|
|
5
|
+
class ConfigSetCommand < MetadataResource
|
|
6
|
+
|
|
7
|
+
aws_attribute :command, name: 'command', type: String
|
|
8
|
+
aws_attribute :env, name: 'env', type: String
|
|
9
|
+
aws_attribute :cwd, name: 'cwd', type: String
|
|
10
|
+
aws_attribute :test, name: 'test', type: String
|
|
11
|
+
aws_attribute :ignore_errors, name: 'ignoreErrors', type: Boolean
|
|
12
|
+
aws_attribute :wait_after_completion, name: 'waitAfterCompletion', type: Integer
|
|
13
|
+
|
|
14
|
+
def initialize
|
|
15
|
+
super
|
|
16
|
+
@aws_type = 'AWS::CloudFormation::ConfigSetCommand'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def name(val=nil)
|
|
20
|
+
if val
|
|
21
|
+
@name = val
|
|
22
|
+
end
|
|
23
|
+
@name
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html#aws-resource-init-commands
|
|
2
|
+
module CloudFormer
|
|
3
|
+
|
|
4
|
+
module CloudFormation
|
|
5
|
+
class ConfigSetFile < MetadataResource
|
|
6
|
+
|
|
7
|
+
aws_attribute :content, name: 'content', type: String
|
|
8
|
+
aws_attribute :source, name: 'source', type: String
|
|
9
|
+
aws_attribute :encoding, name: 'encoding', type: String
|
|
10
|
+
aws_attribute :group, name: 'group', type: String
|
|
11
|
+
aws_attribute :owner, name: 'owner', type: String
|
|
12
|
+
aws_attribute :mode, name: 'mode', type: String
|
|
13
|
+
aws_attribute :authentication, name: 'authentication', type: Authentication
|
|
14
|
+
aws_attribute :context, name: 'context', type: String
|
|
15
|
+
|
|
16
|
+
def initialize
|
|
17
|
+
super
|
|
18
|
+
@aws_type = 'AWS::CloudFormation::ConfigSetFile'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def name(val=nil)
|
|
22
|
+
if val
|
|
23
|
+
@name = val
|
|
24
|
+
end
|
|
25
|
+
@name
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html#aws-resource-init-commands
|
|
2
|
+
module CloudFormer
|
|
3
|
+
|
|
4
|
+
module CloudFormation
|
|
5
|
+
class ConfigSetGroup < MetadataResource
|
|
6
|
+
|
|
7
|
+
attr_accessor :name
|
|
8
|
+
|
|
9
|
+
aws_attribute :gid, name: 'gid', type: Hash
|
|
10
|
+
|
|
11
|
+
def initialize
|
|
12
|
+
super
|
|
13
|
+
@aws_type = 'AWS::CloudFormation::ConfigSetGroup'
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|