Method: Enscalator::Plugins::NATGateway#allocate_new_eip

Defined in:
lib/enscalator/plugins/nat_gateway.rb

#allocate_new_eip(name, depends_on: []) ⇒ Hash

Allocate new elastic IP in given VPC template

Parameters:

  • name (String)

    eip resource name

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

    list of resource names this resource depends on

Returns:

  • (Hash)

    result of Fn::GetAtt function



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/enscalator/plugins/nat_gateway.rb', line 10

def allocate_new_eip(name, depends_on: [])
  fail('Dependency on the VPC-gateway attachment must be provided') if depends_on.empty?
  eip_resource_name = name
  resource eip_resource_name,
           DependsOn: depends_on,
           Type: 'AWS::EC2::EIP',
           Properties: {
             Domain: 'vpc'
           }

  output eip_resource_name,
         Description: 'Elastic IP address for NAT Gateway',
         Value: ref(eip_resource_name)

  get_att(eip_resource_name, 'AllocationId')
end