Module: Convection::DSL::Template

Includes:
Helpers, Resource
Included in:
Model::Template
Defined in:
lib/convection/model/template.rb,
lib/convection/model/template/resource/aws_ec2_vpc.rb,
lib/convection/model/template/resource/aws_kms_key.rb,
lib/convection/model/template/resource/aws_iam_role.rb,
lib/convection/model/template/resource/aws_iam_user.rb,
lib/convection/model/template/resource/aws_ec2_subnet.rb,
lib/convection/model/template/resource/aws_logs_loggroup.rb,
lib/convection/model/template/resource/aws_ec2_network_acl.rb,
lib/convection/model/template/resource/aws_ec2_route_table.rb,
lib/convection/model/template/resource/aws_ec2_security_group.rb,
lib/convection/model/template/resource/aws_ec2_internet_gateway.rb

Overview

Add DSL method to template namespace

Defined Under Namespace

Modules: Resource

Constant Summary collapse

CF_MAX_BYTESIZE =
51_200
CF_MAX_DESCRIPTION_BYTESIZE =
1_024
CF_MAX_MAPPING_ATTRIBUTE_NAME =
255
CF_MAX_MAPPING_ATTRIBUTES =
30
CF_MAX_MAPPING_NAME =
25
CF_MAX_MAPPINGS =
100
CF_MAX_OUTPUT_NAME_CHARACTERS =
255
CF_MAX_OUTPUTS =
60
CF_MAX_PARAMETER_NAME_CHARACTERS =
255
CF_MAX_PARAMETERS =
60
CF_MAX_PARAMETER_VALUE_BYTESIZE =
4_086
CF_MAX_RESOURCE_NAME =
255
CF_MAX_RESOURCES =
200

Instance Method Summary collapse

Methods included from Resource

#_terraform_module_dir_to_flag, #_terraform_module_flag_to_dir, attach_resource, attach_resource_collection, resource_collection_dsl_methods, resource_dsl_methods

Methods included from Helpers

#camel_case, included, method_name, #screaming_snake_case, #snake_case

Methods included from IntrinsicFunctions

#base64, #find_in_map, #fn_and, #fn_equals, #fn_if, #fn_import_value, #fn_not, #fn_or, #fn_ref, #fn_sub, #get_att, #get_azs, included, #join, mixers, #select

Instance Method Details

#condition(name, &block) ⇒ Object



97
98
99
100
101
102
# File 'lib/convection/model/template.rb', line 97

def condition(name, &block)
  c = Model::Template::Condition.new(name, self)

  c.instance_exec(&block) if block
  conditions[name] = c
end

#logs_log_group(name, &block) ⇒ Object



25
26
27
28
29
30
# File 'lib/convection/model/template/resource/aws_logs_loggroup.rb', line 25

def logs_log_group(name, &block)
  r = Model::Template::Resource::LogGroup.new(name, self)

  r.instance_exec(&block) if block
  resources[name] = r
end

#mapping(name, &block) ⇒ Object



90
91
92
93
94
95
# File 'lib/convection/model/template.rb', line 90

def mapping(name, &block)
  m = Model::Template::Mapping.new(name, self)

  m.instance_exec(&block) if block
  mappings[name] = m
end

#metadata(name = nil, value = nil) ⇒ Object

Parameters:

  • name (String) (defaults to: nil)

    the name of the new metadata configuration to set

  • value (Hash) (defaults to: nil)

    an arbritrary JSON object to set as the value of the new metadata configuration



127
128
129
130
131
# File 'lib/convection/model/template.rb', line 127

def (name = nil, value = nil)
  return @metadata unless name

  @metadata[name] = Model::Template::Metadata.new(name, value)
end

#output(name, &block) ⇒ Object



117
118
119
120
121
122
# File 'lib/convection/model/template.rb', line 117

def output(name, &block)
  o = Model::Template::Output.new(name, self)

  o.instance_exec(&block) if block
  outputs[name] = o
end

#parameter(name, &block) ⇒ Object



83
84
85
86
87
88
# File 'lib/convection/model/template.rb', line 83

def parameter(name, &block)
  pa = Model::Template::Parameter.new(name, self)

  pa.instance_exec(&block) if block
  parameters[name] = pa
end

#resource(name, &block) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/convection/model/template.rb', line 104

def resource(name, &block)
  r = Model::Template::Resource.new(name, self)

  r.instance_exec(&block) if block
  predefined_resources = DSL::Template::Resource.resource_dsl_methods.select { |_, resource_class| resource_class.type == r.type }.keys
  if predefined_resources.any?
    dsl_methods = predefined_resources.map { |resource| "##{resource}" }.join(', ')
    warn "WARNING: The resource type #{r.type} is already defined. " \
      "You can use any of the following resource methods instead of manually constructing a resource: #{dsl_methods}"
  end
  resources[name] = r
end