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, #cfn, #cloudwatchlogs, #ec2, #ecr, #ecs, #elb, #s3, #ssm_client, #waf_client
#find_stack, #find_stack_resources, #stack_resources, #status, #task_definition_arns
#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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/ufo/cfn/stack/vars.rb', line 96
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
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/ufo/cfn/stack/vars.rb', line 81
def create_elb?
elb = Ufo.config.elb
if elb.existing.target_group
false
elsif elb.enabled.to_s == "auto"
container[:name] == "web" else
elb.enabled end
end
|
#create_listener? ⇒ Boolean
62
63
64
|
# File 'lib/ufo/cfn/stack/vars.rb', line 62
def create_listener?
Ufo.config.elb.listener.enabled
end
|
#create_listener_ssl? ⇒ Boolean
if the configuration is set to anything then enable it
67
68
69
70
|
# File 'lib/ufo/cfn/stack/vars.rb', line 67
def create_listener_ssl?
elb = Ufo.config.elb
elb.ssl.enabled && elb.ssl.certificates
end
|
#create_route53? ⇒ Boolean
72
73
74
75
76
77
78
79
|
# File 'lib/ufo/cfn/stack/vars.rb', line 72
def create_route53?
return false unless dns_configured?
if create_elb?
true
else
Ufo.config.elb.existing.target_group
end
end
|
#default_listener_protocol ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'lib/ufo/cfn/stack/vars.rb', line 45
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
54
55
56
|
# File 'lib/ufo/cfn/stack/vars.rb', line 54
def default_listener_ssl_protocol
elb_type == 'network' ? 'TLS' : 'HTTPS'
end
|
#default_target_group_protocol ⇒ Object
58
59
60
|
# File 'lib/ufo/cfn/stack/vars.rb', line 58
def default_target_group_protocol
elb_type == 'network' ? 'TCP' : 'HTTP'
end
|
41
42
43
|
# File 'lib/ufo/cfn/stack/vars.rb', line 41
def dns_configured?
!!Ufo.config.dns.domain || !!Ufo.config.dns.name
end
|
#elb_target_group ⇒ Object
92
93
94
|
# File 'lib/ufo/cfn/stack/vars.rb', line 92
def elb_target_group
Ufo.config.elb.existing.target_group
end
|
#elb_type ⇒ Object
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'lib/ufo/cfn/stack/vars.rb', line 126
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
119
120
121
122
123
124
|
# File 'lib/ufo/cfn/stack/vars.rb', line 119
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
26
27
28
|
# File 'lib/ufo/cfn/stack/vars.rb', line 26
def new_stack
!stack
end
|
#rollback_task_definition ⇒ Object
36
37
38
39
|
# File 'lib/ufo/cfn/stack/vars.rb', line 36
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
31
32
33
|
# File 'lib/ufo/cfn/stack/vars.rb', line 31
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
23
24
|
# File 'lib/ufo/cfn/stack/vars.rb', line 5
def values
{
cluster: @cluster,
container: container,
create_elb: create_elb?, create_listener: create_listener?,
create_listener_ssl: create_listener_ssl?,
create_route53: create_route53?,
default_listener_protocol: default_listener_protocol,
default_listener_ssl_protocol: default_listener_ssl_protocol,
default_target_group_protocol: default_target_group_protocol,
elb_target_group: elb_target_group,
elb_type: elb_type,
new_stack: new_stack,
rollback_task_definition: rollback_task_definition,
stack_name: @stack_name, task_definition: @task_definition, }
end
|