Module: Convection::DSL::Template::Resource

Included in:
Convection::DSL::Template, EC2VPC, Model::Template::Resource, Model::Template::ResourceCollection
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_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

Container for DSL interfaces

Defined Under Namespace

Modules: EC2InternetGateway, EC2NetworkACL, EC2RouteTable, EC2SecurityGroup, EC2Subnet, EC2VPC, IAMRole, IAMUser, KmsKey

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.attach_resource(name, klass) ⇒ Object

Wrap private define_method



19
20
21
22
23
24
25
26
27
# File 'lib/convection/model/template.rb', line 19

def attach_resource(name, klass)
  resource_dsl_methods[name.to_s] = klass
  define_method(name) do |rname, &block|
    resource = klass.new(rname, self)
    resource.instance_exec(&block) if block

    resources[rname] = resource
  end
end

.attach_resource_collection(name, klass) ⇒ Object



29
30
31
32
33
34
# File 'lib/convection/model/template.rb', line 29

def attach_resource_collection(name, klass)
  resource_collection_dsl_methods[name.to_s] = klass
  define_method(name) do |rname, &block|
    resource_collections[rname] = klass.new(rname, self, &block)
  end
end

.resource_collection_dsl_methodsObject



40
41
42
# File 'lib/convection/model/template.rb', line 40

def resource_collection_dsl_methods
  @resource_collection_dsl_methods ||= {}
end

.resource_dsl_methodsObject



36
37
38
# File 'lib/convection/model/template.rb', line 36

def resource_dsl_methods
  @resource_dsl_methods ||= {}
end

Instance Method Details

#_terraform_module_dir_to_flag(dir) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/convection/model/template.rb', line 45

def _terraform_module_dir_to_flag(dir)
  return 'root' if dir.empty?

  parts = dir.split('/')
  parts[0] = 'module' if parts[0] == 'modules'
  parts.join('.')
end

#_terraform_module_flag_to_dir(flag) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/convection/model/template.rb', line 53

def _terraform_module_flag_to_dir(flag)
  return '' if flag == 'root'

  parts = flag.split('.')
  parts[0] = 'modules'
  parts.join('/')
end