Module: Enscalator::Plugins::VPCPeeringConnection

Included in:
Templates::VPCPeering
Defined in:
lib/enscalator/plugins/vpc_peering_connection.rb

Overview

VPC Peering Connection Plugin

Instance Method Summary collapse

Instance Method Details

#parameter_vpc_id(name, description, default_value = nil) ⇒ Object

Template parameter for VPC ID

Parameters:

  • name (String)

    parameter name

  • description (String)

    parameter description



9
10
11
12
13
14
15
16
17
18
# File 'lib/enscalator/plugins/vpc_peering_connection.rb', line 9

def parameter_vpc_id(name, description, default_value = nil)
  options = {
    Description: description,
    Type: 'String',
    AllowedPattern: 'vpc-[a-zA-Z0-9]*',
    ConstraintDescription: 'must be valid VPC id (vpc-*).'
  }
  options[:Default] = default_value if default_value && !default_value.nil?
  parameter name, options
end

#vpc_peering_init(conn_name, tags: []) ⇒ Object

Create new vpc peering connection

Parameters:

  • conn_name (String)

    connection name

  • tags (Array<String>) (defaults to: [])

    list of tags



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/enscalator/plugins/vpc_peering_connection.rb', line 24

def vpc_peering_init(conn_name, tags: [])
  options = {}
  options[:Properties] = {
    VpcId: ref("#{conn_name}VpcId"),
    PeerVpcId: ref("#{conn_name}PeerVpcId")
  }

  # Set plugin tags
  options[:Properties][:Tags] = tags if tags && !tags.empty?

  resource conn_name,
           {
             Type: 'AWS::EC2::VPCPeeringConnection'
           }.merge(options)

  output conn_name,
         Description: 'VPC Peering connection name',
         Value: ref(conn_name)

  # return resource name
  conn_name
end