Module: CloudShaped::CoreMethods
- Included in:
- DSL, Interpolation, SnsMethods
- Defined in:
- lib/cloud_shaped/core_methods.rb
Instance Method Summary collapse
-
#output(value) ⇒ Object
Returns an Output declaration.
-
#parameter(options = {}) ⇒ Object
Returns a CloudFormation Parameter declaration.
-
#ref(resource_name, attribute_name = nil) ⇒ Object
Returns a resource reference.
-
#resource(type, properties = {}, attributes = {}) {|properties, attributes| ... } ⇒ Object
Returns a CloudFormation Resource declaration.
-
#tag(key, value, extra_properties = {}) ⇒ Hash
Returns a Tag.
-
#tags(tag_map, extra_properties = {}) ⇒ Object
Returns a list of Tags.
Instance Method Details
#output(value) ⇒ Object
Returns an Output declaration.
50 51 52 53 54 |
# File 'lib/cloud_shaped/core_methods.rb', line 50 def output(value) { "Value" => value } end |
#parameter(options = {}) ⇒ Object
Returns a CloudFormation Parameter declaration.
36 37 38 39 40 41 |
# File 'lib/cloud_shaped/core_methods.rb', line 36 def parameter( = {}) defaults = { "Type" => "String" } defaults.merge(.camelate_keys) end |
#ref(resource_name, attribute_name = nil) ⇒ Object
Returns a resource reference.
If attribute_name is specified, we use “Fn::GetAtt”; otherwise, we use “Ref”.
90 91 92 93 94 95 96 |
# File 'lib/cloud_shaped/core_methods.rb', line 90 def ref(resource_name, attribute_name = nil) if attribute_name { "Fn::GetAtt" => [resource_name, attribute_name] } else { "Ref" => resource_name } end end |
#resource(type, properties = {}, attributes = {}) {|properties, attributes| ... } ⇒ Object
Returns a CloudFormation Resource declaration.
Properties and additional resource attributes can be passed in the call, or defined using an optional block.
20 21 22 23 24 25 26 27 28 |
# File 'lib/cloud_shaped/core_methods.rb', line 20 def resource(type, properties = {}, attributes = {}) properties = properties.camelate_keys yield properties, attributes if block_given? properties.select! { |k,v| v != nil } attributes.merge( "Type" => type, "Properties" => properties ) end |
#tag(key, value, extra_properties = {}) ⇒ Hash
Returns a Tag.
65 66 67 68 69 70 |
# File 'lib/cloud_shaped/core_methods.rb', line 65 def tag(key, value, extra_properties = {}) { "Key" => key, "Value" => value }.merge(extra_properties) end |
#tags(tag_map, extra_properties = {}) ⇒ Object
Returns a list of Tags.
79 80 81 |
# File 'lib/cloud_shaped/core_methods.rb', line 79 def (tag_map, extra_properties = {}) tag_map.map { |k,v| tag(k,v, extra_properties) } end |