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.



20
21
22
# File 'lib/terrafying/components/endpointservice.rb', line 20

def initialize
  super
end

Instance Attribute Details

#fqdnObject (readonly)

Returns the value of attribute fqdn.



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

def fqdn
  @fqdn
end

#load_balancerObject (readonly)

Returns the value of attribute load_balancer.



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

def load_balancer
  @load_balancer
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#service_nameObject (readonly)

Returns the value of attribute service_name.



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

def service_name
  @service_name
end

#zoneObject (readonly)

Returns the value of attribute zone.



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

def zone
  @zone
end

Class Method Details

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



12
13
14
# File 'lib/terrafying/components/endpointservice.rb', line 12

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

.find(service_name) ⇒ Object



16
17
18
# File 'lib/terrafying/components/endpointservice.rb', line 16

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

Instance Method Details

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



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
53
54
55
# File 'lib/terrafying/components/endpointservice.rb', line 28

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

  if ! load_balancer or 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



57
58
59
60
# File 'lib/terrafying/components/endpointservice.rb', line 57

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



24
25
26
# File 'lib/terrafying/components/endpointservice.rb', line 24

def find(service_name)
  raise 'unimplemented'
end