Class: Ufo::Cfn::Stack::Builder::Resources::ListenerSsl

Inherits:
Listener show all
Defined in:
lib/ufo/cfn/stack/builder/resources/listener_ssl.rb

Direct Known Subclasses

ListenerCertificate

Instance Attribute Summary

Attributes inherited from Base

#vars

Attributes inherited from Ufo::CLI::Base

#task_definition

Instance Method Summary collapse

Methods inherited from Listener

#default_action, #redirect_action

Methods inherited from Base

build, #initialize, #manage_ecs_security_group?, #managed_security_group, #security_groups

Methods included from Ufo::Concerns

#deploy, #info, #ps

Methods included from Ufo::Concerns::Names

#names

Methods included from AwsServices

#acm, #applicationautoscaling, #aws_options, #cfn, #cloudwatchlogs, #ec2, #ecr, #ecs, #elb, #s3, #ssm_client, #waf_client

Methods included from AwsServices::Concerns

#find_stack, #find_stack_resources, #stack_resources, #status, #task_definition_arns

Methods inherited from Ufo::CLI::Base

#initialize

Methods included from Utils::Sure

#sure?

Methods included from Utils::Pretty

#pretty_home, #pretty_path, #pretty_time

Methods included from Utils::Logging

#logger

Constructor Details

This class inherits a constructor from Ufo::Cfn::Stack::Builder::Base

Instance Method Details

#buildObject



3
4
5
6
7
8
9
10
# File 'lib/ufo/cfn/stack/builder/resources/listener_ssl.rb', line 3

def build
  return unless vars[:create_listener_ssl]
  {
    Type: "AWS::ElasticLoadBalancingV2::Listener",
    Condition: "CreateElbIsTrue",
    Properties: properties,
  }
end

#certificatesObject

nil on purpose



35
36
37
38
# File 'lib/ufo/cfn/stack/builder/resources/listener_ssl.rb', line 35

def certificates
  ssl = Ufo.config.elb.ssl
  normalize(ssl.certificates) if ssl.certificates
end

#default_actionsObject

Do not use redirect settings. Only use by normal http listener



30
31
32
# File 'lib/ufo/cfn/stack/builder/resources/listener_ssl.rb', line 30

def default_actions
  [default_action]
end

#normalize(*certs) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/ufo/cfn/stack/builder/resources/listener_ssl.rb', line 40

def normalize(*certs)
  certs = certs.flatten.compact
  certs.map do |cert|
    if cert.is_a?(String)
      {CertificateArn: cert}
    else # Assume correct Hash structure
      cert
    end
  end
end

#portObject



25
26
27
# File 'lib/ufo/cfn/stack/builder/resources/listener_ssl.rb', line 25

def port
  Ufo.config.elb.ssl.port
end

#propertiesObject



12
13
14
15
16
17
18
19
# File 'lib/ufo/cfn/stack/builder/resources/listener_ssl.rb', line 12

def properties
  props = super
  # CloudFormation has weird interface
  # Only one cert allowed at the AWS::ElasticLoadBalancingV2::Listener
  # https://stackoverflow.com/questions/54447250/how-to-set-multiple-certificates-for-awselasticloadbalancingv2listener
  props[:Certificates] = [certificates.first] # first one only
  props
end

#protocolObject



21
22
23
# File 'lib/ufo/cfn/stack/builder/resources/listener_ssl.rb', line 21

def protocol
  vars[:default_listener_ssl_protocol]
end