Class: Terrafying::Components::EndpointService

Inherits:
Terrafying::Context
  • Object
show all
Defined in:
lib/terrafying/components/endpointservice.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEndpointService

Returns a new instance of EndpointService.



18
19
20
# File 'lib/terrafying/components/endpointservice.rb', line 18

def initialize
  super
end

Instance Attribute Details

#fqdnObject (readonly)

Returns the value of attribute fqdn.



8
9
10
# File 'lib/terrafying/components/endpointservice.rb', line 8

def fqdn
  @fqdn
end

#load_balancerObject (readonly)

Returns the value of attribute load_balancer.



8
9
10
# File 'lib/terrafying/components/endpointservice.rb', line 8

def load_balancer
  @load_balancer
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/terrafying/components/endpointservice.rb', line 8

def name
  @name
end

#service_nameObject (readonly)

Returns the value of attribute service_name.



8
9
10
# File 'lib/terrafying/components/endpointservice.rb', line 8

def service_name
  @service_name
end

#zoneObject (readonly)

Returns the value of attribute zone.



8
9
10
# File 'lib/terrafying/components/endpointservice.rb', line 8

def zone
  @zone
end

Class Method Details

.create_for(load_balancer, name, options = {}) ⇒ Object



10
11
12
# File 'lib/terrafying/components/endpointservice.rb', line 10

def self.create_for(load_balancer, name, options = {})
  EndpointService.new.create_for(load_balancer, name, options)
end

.find(service_name) ⇒ Object



14
15
16
# File 'lib/terrafying/components/endpointservice.rb', line 14

def self.find(service_name)
  EndpointService.new.find(service_name)
end

Instance Method Details

#create_for(load_balancer, name, options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/terrafying/components/endpointservice.rb', line 26

def create_for(load_balancer, name, options = {})
  options = {
    acceptance_required: true,
    allowed_principals: [
      "arn:aws:iam::#{aws.}:root"
    ]
  }.merge(options)

  if !load_balancer || (load_balancer.type != 'network')
    raise 'The load balancer needs to be a network load balancer'
  end

  @name = name
  @load_balancer = load_balancer

  @fqdn = options[:fqdn]
  @zone = options[:zone]

  resource :aws_vpc_endpoint_service, name,
           acceptance_required: options[:acceptance_required],
           allowed_principals: options[:allowed_principals],
           network_load_balancer_arns: [load_balancer.id]

  @service_name = output_of(:aws_vpc_endpoint_service, name, 'service_name')

  self
end

#expose_in(vpc, options = {}) ⇒ Object



54
55
56
57
# File 'lib/terrafying/components/endpointservice.rb', line 54

def expose_in(vpc, options = {})
  name = options.fetch(:name, @name)
  add! Endpoint.create_in(vpc, name, options.merge(service: self))
end

#find(_service_name) ⇒ Object



22
23
24
# File 'lib/terrafying/components/endpointservice.rb', line 22

def find(_service_name)
  raise 'unimplemented'
end