Class: Ufo::Cfn::Stack::Vars
- Inherits:
-
Base
show all
- Defined in:
- lib/ufo/cfn/stack/vars.rb
Instance Attribute Summary collapse
#task_definition
Instance Method Summary
collapse
#build, #deploy, #info, #ps
#names
#acm, #applicationautoscaling, #aws_options, #cloudformation, #cloudwatchlogs, #ec2, #ecr, #ecs, #elb, #find_stack, #ssm_client, #stack_resources, #status, #task_definition_arns, #waf_client
#initialize
#sure?
#pretty_home, #pretty_path, #pretty_time
#logger
Constructor Details
This class inherits a constructor from Ufo::CLI::Base
Instance Attribute Details
#stack_name ⇒ Object
Returns the value of attribute stack_name.
3
4
5
|
# File 'lib/ufo/cfn/stack/vars.rb', line 3
def stack_name
@stack_name
end
|
Instance Method Details
#container ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/ufo/cfn/stack/vars.rb', line 75
def container
task_definition = Builder::Resources::TaskDefinition::Reconstructor.new(@task_definition, @options[:rollback]).reconstruct
container_def = task_definition["ContainerDefinitions"].first
requires_compatibilities = task_definition["RequiresCompatibilities"]
fargate = requires_compatibilities && requires_compatibilities == ["FARGATE"]
network_mode = task_definition["NetworkMode"]
mappings = container_def["PortMappings"] || []
unless mappings.empty?
port = mappings.first["ContainerPort"]
end
result = {
name: container_def["Name"],
fargate: fargate,
network_mode: network_mode, }
result[:port] = port if port
result
end
|
#create_elb? ⇒ Boolean
66
67
68
69
70
71
72
73
|
# File 'lib/ufo/cfn/stack/vars.rb', line 66
def create_elb?
elb = Ufo.config.elb
if elb.enabled.to_s == "auto"
container[:name] == "web" else
elb.enabled end
end
|
#create_listener_ssl? ⇒ Boolean
if the configuration is set to anything then enable it
61
62
63
64
|
# File 'lib/ufo/cfn/stack/vars.rb', line 61
def create_listener_ssl?
elb = Ufo.config.elb
elb.ssl.enabled && elb.ssl.certificates
end
|
#default_listener_protocol ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'lib/ufo/cfn/stack/vars.rb', line 43
def default_listener_protocol
port = Ufo.config.elb.port
if elb_type == 'network'
port == 443 ? 'TLS' : 'TCP'
else
port == 443 ? 'HTTPS' : 'HTTP'
end
end
|
#default_listener_ssl_protocol ⇒ Object
52
53
54
|
# File 'lib/ufo/cfn/stack/vars.rb', line 52
def default_listener_ssl_protocol
elb_type == 'network' ? 'TLS' : 'HTTPS'
end
|
#default_target_group_protocol ⇒ Object
56
57
58
|
# File 'lib/ufo/cfn/stack/vars.rb', line 56
def default_target_group_protocol
elb_type == 'network' ? 'TCP' : 'HTTP'
end
|
39
40
41
|
# File 'lib/ufo/cfn/stack/vars.rb', line 39
def dns_configured?
!!Ufo.config.dns.domain || !!Ufo.config.dns.name
end
|
#elb_type ⇒ Object
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/ufo/cfn/stack/vars.rb', line 105
def elb_type
elb_type = Ufo.config.elb.type
return elb_type if elb_type
subnet_mappings = Ufo.config.elb.subnet_mappings
if subnet_mappings.empty?
"application" else
"network"
end
end
|
#get_parameter_value(stack, key) ⇒ Object
98
99
100
101
102
103
|
# File 'lib/ufo/cfn/stack/vars.rb', line 98
def get_parameter_value(stack, key)
param = stack.parameters.find do |p|
p.parameter_key == key
end
param.parameter_value if param
end
|
#new_stack ⇒ Object
24
25
26
|
# File 'lib/ufo/cfn/stack/vars.rb', line 24
def new_stack
!stack
end
|
#rollback_task_definition ⇒ Object
34
35
36
37
|
# File 'lib/ufo/cfn/stack/vars.rb', line 34
def rollback_task_definition
return unless @options[:rollback]
@options[:rollback_task_definition]
end
|
#stack ⇒ Object
Find stack in vars to ensure both ufo build and ufo ship can tell if stack has already been built
29
30
31
|
# File 'lib/ufo/cfn/stack/vars.rb', line 29
def stack
find_stack(@stack_name)
end
|
#values ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/ufo/cfn/stack/vars.rb', line 5
def values
{
cluster: @cluster,
container: container,
create_elb: create_elb?, create_listener_ssl: create_listener_ssl?,
create_route53: create_elb? && dns_configured?,
default_listener_protocol: default_listener_protocol,
default_listener_ssl_protocol: default_listener_ssl_protocol,
default_target_group_protocol: default_target_group_protocol,
elb_type: elb_type,
new_stack: new_stack,
rollback_task_definition: rollback_task_definition,
stack_name: @stack_name, task_definition: @task_definition, }
end
|