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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/ufo/cfn/stack/vars.rb', line 91
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
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/ufo/cfn/stack/vars.rb', line 76
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_ssl? ⇒ Boolean
if the configuration is set to anything then enable it
62
63
64
65
|
# File 'lib/ufo/cfn/stack/vars.rb', line 62
def create_listener_ssl?
elb = Ufo.config.elb
elb.ssl.enabled && elb.ssl.certificates
end
|
#create_route53? ⇒ Boolean
67
68
69
70
71
72
73
74
|
# File 'lib/ufo/cfn/stack/vars.rb', line 67
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
44
45
46
47
48
49
50
51
|
# File 'lib/ufo/cfn/stack/vars.rb', line 44
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
53
54
55
|
# File 'lib/ufo/cfn/stack/vars.rb', line 53
def default_listener_ssl_protocol
elb_type == 'network' ? 'TLS' : 'HTTPS'
end
|
#default_target_group_protocol ⇒ Object
57
58
59
|
# File 'lib/ufo/cfn/stack/vars.rb', line 57
def default_target_group_protocol
elb_type == 'network' ? 'TCP' : 'HTTP'
end
|
40
41
42
|
# File 'lib/ufo/cfn/stack/vars.rb', line 40
def dns_configured?
!!Ufo.config.dns.domain || !!Ufo.config.dns.name
end
|
#elb_target_group ⇒ Object
87
88
89
|
# File 'lib/ufo/cfn/stack/vars.rb', line 87
def elb_target_group
Ufo.config.elb.existing.target_group
end
|
#elb_type ⇒ Object
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/ufo/cfn/stack/vars.rb', line 121
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
114
115
116
117
118
119
|
# File 'lib/ufo/cfn/stack/vars.rb', line 114
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
25
26
27
|
# File 'lib/ufo/cfn/stack/vars.rb', line 25
def new_stack
!stack
end
|
#rollback_task_definition ⇒ Object
35
36
37
38
|
# File 'lib/ufo/cfn/stack/vars.rb', line 35
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
30
31
32
|
# File 'lib/ufo/cfn/stack/vars.rb', line 30
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
|
# 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_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
|