class Terrafying::Components::EndpointService

Attributes

fqdn[R]
load_balancer[R]
name[R]
service_name[R]
zone[R]

Public Class Methods

create_for(load_balancer, name, options = {}) click to toggle source
# 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) click to toggle source
# File lib/terrafying/components/endpointservice.rb, line 14
def self.find(service_name)
  EndpointService.new.find(service_name)
end
new() click to toggle source
Calls superclass method
# File lib/terrafying/components/endpointservice.rb, line 18
def initialize
  super
end

Public Instance Methods

create_for(load_balancer, name, options = {}) click to toggle source
# 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.account_id}: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 = {}) click to toggle source
# 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) click to toggle source
# File lib/terrafying/components/endpointservice.rb, line 22
def find(_service_name)
  raise 'unimplemented'
end