ufo 4.5.11 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/README.md +2 -0
- data/docs/_docs/conventions.md +1 -1
- data/docs/_docs/extras/codebuild-iam-role.md +2 -2
- data/docs/_docs/extras/dockerfile-erb.md +2 -2
- data/docs/_docs/extras/ecs-network-mode.md +2 -2
- data/docs/_docs/extras/load-balancer.md +2 -2
- data/docs/_docs/extras/minimal-deploy-iam.md +2 -2
- data/docs/_docs/extras/notification-arns.md +21 -0
- data/docs/_docs/extras/redirection-support.md +2 -2
- data/docs/_docs/extras/route53-support.md +2 -2
- data/docs/_docs/extras/security-groups.md +2 -2
- data/docs/_docs/extras/ssl-support.md +2 -2
- data/docs/_docs/faq.md +2 -2
- data/docs/_docs/helpers.md +7 -5
- data/docs/_docs/iam-roles.md +111 -0
- data/docs/_docs/install.md +1 -1
- data/docs/_docs/more/auto-completion.md +2 -2
- data/docs/_docs/more/automated-cleanup.md +2 -2
- data/docs/_docs/more/customize-cloudformation.md +2 -2
- data/docs/_docs/more/migrations.md +2 -2
- data/docs/_docs/more/run-in-pieces.md +2 -2
- data/docs/_docs/more/single-task.md +2 -2
- data/docs/_docs/more/stuck-cloudformation.md +2 -2
- data/docs/_docs/more/why-cloudformation.md +2 -2
- data/docs/_docs/next-steps.md +2 -2
- data/docs/_docs/quick-start-ec2.md +2 -1
- data/docs/_docs/secrets.md +112 -0
- data/docs/_docs/settings.md +1 -1
- data/docs/_docs/settings/aws_profile.md +1 -1
- data/docs/_docs/settings/cfn.md +1 -1
- data/docs/_docs/settings/cluster.md +8 -14
- data/docs/_docs/settings/network.md +1 -1
- data/docs/_docs/ssl_errors.md +1 -2
- data/docs/_docs/structure.md +1 -1
- data/docs/_docs/tutorial-ufo-docker-build.md +1 -1
- data/docs/_docs/tutorial-ufo-init.md +1 -1
- data/docs/_docs/tutorial-ufo-ship.md +1 -1
- data/docs/_docs/tutorial-ufo-ships.md +1 -1
- data/docs/_docs/tutorial-ufo-tasks-build.md +1 -1
- data/docs/_docs/tutorial.md +1 -1
- data/docs/_docs/ufo-current.md +2 -2
- data/docs/_docs/ufo-env-extra.md +2 -2
- data/docs/_docs/ufo-env.md +2 -2
- data/docs/_docs/ufo-logs.md +50 -0
- data/docs/_docs/ufo-task-params.md +2 -2
- data/docs/_docs/upgrading.md +2 -2
- data/docs/_docs/upgrading/upgrade4.5.md +2 -2
- data/docs/_docs/upgrading/upgrade4.md +2 -2
- data/docs/_docs/variables.md +1 -1
- data/docs/_includes/subnav.html +4 -0
- data/docs/_reference/ufo-deploy.md +1 -2
- data/docs/_reference/ufo-init.md +1 -1
- data/docs/_reference/ufo-logs.md +40 -0
- data/docs/_reference/ufo-rollback.md +2 -0
- data/docs/_reference/ufo-ship.md +1 -2
- data/docs/_reference/ufo-ships.md +1 -2
- data/docs/_reference/ufo-tasks-build.md +1 -2
- data/docs/articles.md +2 -2
- data/docs/docs.md +1 -1
- data/docs/quick-start.md +2 -1
- data/docs/reference.md +1 -0
- data/lib/template/.secrets +3 -0
- data/lib/template/.ufo/settings.yml.tt +1 -0
- data/lib/template/.ufo/settings/cfn/default.yml.tt +27 -27
- data/lib/template/.ufo/settings/network/default.yml.tt +9 -0
- data/lib/template/.ufo/templates/fargate.json.erb +3 -0
- data/lib/template/.ufo/templates/main.json.erb +3 -0
- data/lib/template/.ufo/variables/base.rb.tt +1 -0
- data/lib/ufo.rb +2 -1
- data/lib/ufo/autoloader.rb +9 -0
- data/lib/ufo/cli.rb +12 -1
- data/lib/ufo/command.rb +7 -0
- data/lib/ufo/core.rb +1 -9
- data/lib/ufo/docker/cleaner.rb +1 -1
- data/lib/ufo/dsl.rb +6 -1
- data/lib/ufo/dsl/helper.rb +21 -27
- data/lib/ufo/dsl/helper/vars.rb +98 -0
- data/lib/ufo/dsl/outputter.rb +12 -9
- data/lib/ufo/help/init.md +1 -1
- data/lib/ufo/help/logs.md +10 -0
- data/lib/ufo/log_group.rb +1 -0
- data/lib/ufo/logs.rb +56 -0
- data/lib/ufo/role/builder.rb +66 -0
- data/lib/ufo/role/dsl.rb +21 -0
- data/lib/ufo/role/registry.rb +24 -0
- data/lib/ufo/rollback.rb +2 -1
- data/lib/ufo/setting/profile.rb +11 -7
- data/lib/ufo/setting/security_groups.rb +22 -0
- data/lib/ufo/settings.rb +20 -0
- data/lib/ufo/stack.rb +24 -24
- data/lib/ufo/stack/builder.rb +26 -0
- data/lib/ufo/stack/builder/base.rb +54 -0
- data/lib/ufo/stack/builder/conditions.rb +23 -0
- data/lib/ufo/stack/builder/outputs.rb +24 -0
- data/lib/ufo/stack/builder/parameters.rb +45 -0
- data/lib/ufo/stack/builder/resources.rb +20 -0
- data/lib/ufo/stack/builder/resources/base.rb +4 -0
- data/lib/ufo/stack/builder/resources/dns.rb +17 -0
- data/lib/ufo/stack/builder/resources/ecs.rb +63 -0
- data/lib/ufo/stack/builder/resources/elb.rb +45 -0
- data/lib/ufo/stack/builder/resources/listener.rb +42 -0
- data/lib/ufo/stack/builder/resources/listener_ssl.rb +16 -0
- data/lib/ufo/stack/builder/resources/roles/base.rb +22 -0
- data/lib/ufo/stack/builder/resources/roles/execution_role.rb +4 -0
- data/lib/ufo/stack/builder/resources/roles/task_role.rb +4 -0
- data/lib/ufo/stack/builder/resources/security_group/base.rb +4 -0
- data/lib/ufo/stack/builder/resources/security_group/ecs.rb +44 -0
- data/lib/ufo/stack/builder/resources/security_group/ecs_rule.rb +25 -0
- data/lib/ufo/stack/builder/resources/security_group/elb.rb +57 -0
- data/lib/ufo/stack/builder/resources/target_group.rb +39 -0
- data/lib/ufo/stack/builder/resources/task_definition.rb +24 -0
- data/lib/ufo/stack/builder/resources/task_definition/reconstructor.rb +49 -0
- data/lib/ufo/stack/context.rb +41 -48
- data/lib/ufo/stack/custom_properties.rb +59 -0
- data/lib/ufo/stack/helper.rb +2 -5
- data/lib/ufo/stack/template_body.rb +13 -0
- data/lib/ufo/task.rb +2 -7
- data/lib/ufo/tasks.rb +1 -1
- data/lib/ufo/tasks/builder.rb +0 -1
- data/lib/ufo/tasks/register.rb +11 -8
- data/lib/ufo/template_scope.rb +1 -66
- data/lib/ufo/utils/squeezer.rb +24 -0
- data/lib/ufo/version.rb +1 -1
- data/spec/fixtures/iam_roles/task_role.rb +17 -0
- data/spec/fixtures/mocks/logs/awslogs.json +70 -0
- data/spec/fixtures/mocks/logs/no-awslogs.json +70 -0
- data/spec/lib/logs_spec.rb +55 -0
- data/spec/lib/role/builder_spec.rb +67 -0
- data/spec/lib/role/dsl_spec.rb +12 -0
- data/ufo.gemspec +2 -0
- metadata +82 -5
- data/lib/cfn/stack.yml +0 -283
@@ -0,0 +1,45 @@
|
|
1
|
+
class Ufo::Stack::Builder::Resources
|
2
|
+
class Elb < Base
|
3
|
+
def build
|
4
|
+
{
|
5
|
+
Type: "AWS::ElasticLoadBalancingV2::LoadBalancer",
|
6
|
+
Condition: "CreateElbIsTrue",
|
7
|
+
Properties: properties,
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
def properties
|
12
|
+
props = {
|
13
|
+
Type: @elb_type,
|
14
|
+
Tags: [
|
15
|
+
{Key: "Name", Value: @stack_name}
|
16
|
+
],
|
17
|
+
Subnets: {Ref: "ElbSubnets"},
|
18
|
+
Scheme: "internet-facing"
|
19
|
+
}
|
20
|
+
|
21
|
+
props[:SecurityGroups] = security_groups(:elb) if @elb_type == "application"
|
22
|
+
subnets(props)
|
23
|
+
|
24
|
+
props
|
25
|
+
end
|
26
|
+
|
27
|
+
def subnets(props)
|
28
|
+
mappings = @elb_type == "network" && @subnet_mappings && !@subnet_mappings.empty?
|
29
|
+
if mappings
|
30
|
+
props[:SubnetMappings] = subnet_mappings
|
31
|
+
else
|
32
|
+
props[:Subnets] = {Ref: "ElbSubnets"}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def subnet_mappings
|
37
|
+
@subnet_mappings.map do |allocation_id, subnet_id|
|
38
|
+
{
|
39
|
+
AllocationId: allocation_id,
|
40
|
+
SubnetId: subnet_id,
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Ufo::Stack::Builder::Resources
|
2
|
+
class Listener < Base
|
3
|
+
def build
|
4
|
+
{
|
5
|
+
Type: "AWS::ElasticLoadBalancingV2::Listener",
|
6
|
+
Condition: "CreateElbIsTrue",
|
7
|
+
Properties: properties,
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
def properties
|
12
|
+
props = {
|
13
|
+
DefaultActions: [
|
14
|
+
{
|
15
|
+
Type: "forward",
|
16
|
+
TargetGroupArn: {
|
17
|
+
"Fn::If": [
|
18
|
+
"ElbTargetGroupIsBlank",
|
19
|
+
{Ref: "TargetGroup"},
|
20
|
+
{Ref: "ElbTargetGroup"}
|
21
|
+
]
|
22
|
+
}
|
23
|
+
}
|
24
|
+
],
|
25
|
+
LoadBalancerArn: {Ref: "Elb"},
|
26
|
+
Protocol: protocol,
|
27
|
+
}
|
28
|
+
|
29
|
+
props[:Port] = port if port
|
30
|
+
|
31
|
+
props
|
32
|
+
end
|
33
|
+
|
34
|
+
def protocol
|
35
|
+
@default_listener_protocol
|
36
|
+
end
|
37
|
+
|
38
|
+
def port
|
39
|
+
80
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Ufo::Stack::Builder::Resources::Roles
|
2
|
+
class Base < Ufo::Stack::Builder::Base
|
3
|
+
def build
|
4
|
+
return unless self.class.build? # important because it runs DSL#evaluate
|
5
|
+
Ufo::Role::Builder.new(self.class.role_type).build
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def role_type
|
11
|
+
self.name.to_s.split("::").last.underscore
|
12
|
+
end
|
13
|
+
|
14
|
+
def build?
|
15
|
+
path = "#{Ufo.root}/.ufo/iam_roles/#{role_type}.rb"
|
16
|
+
return unless File.exist?(path)
|
17
|
+
Ufo::Role::DSL.new(path).evaluate # runs the role.rb and registers items
|
18
|
+
Ufo::Role::Builder.new(role_type).build?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Ufo::Stack::Builder::Resources::SecurityGroup
|
2
|
+
class Ecs < Base
|
3
|
+
def build
|
4
|
+
return unless managed_security_groups_enabled?
|
5
|
+
|
6
|
+
{
|
7
|
+
Type: "AWS::EC2::SecurityGroup",
|
8
|
+
Properties: properties
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
def properties
|
13
|
+
props = {
|
14
|
+
GroupDescription: "Allow http to client host",
|
15
|
+
VpcId: {Ref: "Vpc"},
|
16
|
+
SecurityGroupEgress: [
|
17
|
+
{
|
18
|
+
IpProtocol: "-1",
|
19
|
+
CidrIp: "0.0.0.0/0",
|
20
|
+
Description: "outbound traffic"
|
21
|
+
}
|
22
|
+
],
|
23
|
+
Tags: [
|
24
|
+
{
|
25
|
+
Key: "Name",
|
26
|
+
Value: @stack_name,
|
27
|
+
}
|
28
|
+
]
|
29
|
+
}
|
30
|
+
|
31
|
+
if @elb_type == "network"
|
32
|
+
props[:SecurityGroupIngress] = {
|
33
|
+
IpProtocol: "tcp",
|
34
|
+
FromPort: @container[:port],
|
35
|
+
ToPort: @container[:port],
|
36
|
+
CidrIp: "0.0.0.0/0",
|
37
|
+
Description: "docker ephemeral port range for network elb",
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
props
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Ufo::Stack::Builder::Resources::SecurityGroup
|
2
|
+
class EcsRule < Base
|
3
|
+
def build
|
4
|
+
return unless managed_security_groups_enabled?
|
5
|
+
return unless @elb_type == "application"
|
6
|
+
|
7
|
+
{
|
8
|
+
Type: "AWS::EC2::SecurityGroupIngress",
|
9
|
+
Condition: "CreateElbIsTrue",
|
10
|
+
Properties: {
|
11
|
+
IpProtocol: "tcp",
|
12
|
+
FromPort: "0",
|
13
|
+
ToPort: "65535",
|
14
|
+
SourceSecurityGroupId: {
|
15
|
+
"Fn::GetAtt": "ElbSecurityGroup.GroupId"
|
16
|
+
},
|
17
|
+
GroupId: {
|
18
|
+
"Fn::GetAtt": "EcsSecurityGroup.GroupId"
|
19
|
+
},
|
20
|
+
Description: "application elb access to ecs"
|
21
|
+
}
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Ufo::Stack::Builder::Resources::SecurityGroup
|
2
|
+
class Elb < Base
|
3
|
+
def build
|
4
|
+
return unless managed_security_groups_enabled?
|
5
|
+
return unless @elb_type == "application"
|
6
|
+
|
7
|
+
{
|
8
|
+
Type: "AWS::EC2::SecurityGroup",
|
9
|
+
Condition: "CreateElbIsTrue",
|
10
|
+
Properties: properties
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
def properties
|
15
|
+
port = cfn.dig(:Listener, :Port) || cfn.dig(:listener, :port) # backwards compatiblity
|
16
|
+
|
17
|
+
props = {
|
18
|
+
GroupDescription: "Allow http to client host",
|
19
|
+
VpcId: {Ref: "Vpc"},
|
20
|
+
SecurityGroupIngress: [
|
21
|
+
{
|
22
|
+
IpProtocol: "tcp",
|
23
|
+
FromPort: port,
|
24
|
+
ToPort: port,
|
25
|
+
CidrIp: "0.0.0.0/0"
|
26
|
+
}
|
27
|
+
],
|
28
|
+
SecurityGroupEgress: [
|
29
|
+
{
|
30
|
+
IpProtocol: "tcp",
|
31
|
+
FromPort: "0",
|
32
|
+
ToPort: "65535",
|
33
|
+
CidrIp: "0.0.0.0/0"
|
34
|
+
}
|
35
|
+
],
|
36
|
+
Tags: [
|
37
|
+
{
|
38
|
+
Key: "Name",
|
39
|
+
Value: "#{@stack_name}-elb"
|
40
|
+
}
|
41
|
+
]
|
42
|
+
}
|
43
|
+
|
44
|
+
if @create_listener_ssl
|
45
|
+
ssl_port = cfn.dig(:ListenerSsl, :Port) || cfn.dig(:listener_ssl, :port) # backwards compatiblity
|
46
|
+
props[:SecurityGroupIngress] << {
|
47
|
+
IpProtocol: "tcp",
|
48
|
+
FromPort: ssl_port,
|
49
|
+
ToPort: ssl_port,
|
50
|
+
CidrIp: "0.0.0.0/0"
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
props
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Ufo::Stack::Builder::Resources
|
2
|
+
class TargetGroup < Base
|
3
|
+
def build
|
4
|
+
{
|
5
|
+
Type: "AWS::ElasticLoadBalancingV2::TargetGroup",
|
6
|
+
Condition: "CreateTargetGroupIsTrue",
|
7
|
+
Properties: properties,
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
def properties
|
12
|
+
props = {
|
13
|
+
VpcId: {Ref: "Vpc"},
|
14
|
+
Tags: [
|
15
|
+
{
|
16
|
+
Key: "Name",
|
17
|
+
Value: @stack_name,
|
18
|
+
}
|
19
|
+
],
|
20
|
+
Protocol: @default_target_group_protocol,
|
21
|
+
Port: 80,
|
22
|
+
HealthCheckIntervalSeconds: 10,
|
23
|
+
HealthyThresholdCount: 2,
|
24
|
+
UnhealthyThresholdCount: 2,
|
25
|
+
TargetGroupAttributes: [
|
26
|
+
{
|
27
|
+
Key: "deregistration_delay.timeout_seconds",
|
28
|
+
Value: 10
|
29
|
+
}
|
30
|
+
]
|
31
|
+
}
|
32
|
+
|
33
|
+
props[:TargetType] = "ip" if @container[:network_mode] == "awsvpc"
|
34
|
+
props[:HealthCheckPort] = @container[:port] if @elb_type == "network" && @network_mode == "awsvpc"
|
35
|
+
|
36
|
+
props
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Ufo::Stack::Builder::Resources
|
2
|
+
class TaskDefinition < Base
|
3
|
+
def build
|
4
|
+
return if @rollback_definition_arn
|
5
|
+
|
6
|
+
{
|
7
|
+
Type: "AWS::ECS::TaskDefinition",
|
8
|
+
Properties: properties,
|
9
|
+
DeletionPolicy: "Retain",
|
10
|
+
UpdateReplacePolicy: "Retain",
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
def properties
|
15
|
+
props = Reconstructor.new(@task_definition).reconstruct
|
16
|
+
|
17
|
+
# Decorate with iam roles if needed
|
18
|
+
props[:TaskRoleArn] = {"Fn::GetAtt": "TaskRole.Arn"} if Roles::TaskRole.build?
|
19
|
+
props[:ExecutionRoleArn] = {"Fn::GetAtt": "ExecutionRole.Arn"} if Roles::ExecutionRole.build?
|
20
|
+
|
21
|
+
props
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class Ufo::Stack::Builder::Resources::TaskDefinition
|
2
|
+
class Reconstructor
|
3
|
+
include Ufo::AwsService
|
4
|
+
|
5
|
+
def initialize(task_definition, rollback=false)
|
6
|
+
@task_definition, @rollback = task_definition, rollback
|
7
|
+
end
|
8
|
+
|
9
|
+
def reconstruct
|
10
|
+
camelize(data)
|
11
|
+
end
|
12
|
+
|
13
|
+
def data
|
14
|
+
if @rollback
|
15
|
+
resp = ecs.describe_task_definition(task_definition: @task_definition)
|
16
|
+
resp.task_definition.to_h
|
17
|
+
else
|
18
|
+
path = "#{Ufo.root}/.ufo/output/#{@task_definition}.json"
|
19
|
+
JSON.load(IO.read(path))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# non-destructive
|
24
|
+
def camelize(value, parent_keys=[])
|
25
|
+
case value
|
26
|
+
when Array
|
27
|
+
value.map { |v| camelize(v, parent_keys) }
|
28
|
+
when Hash
|
29
|
+
initializer = value.map do |k, v|
|
30
|
+
new_key = camelize_key(k, parent_keys)
|
31
|
+
[new_key, camelize(v, parent_keys+[new_key])]
|
32
|
+
end
|
33
|
+
Hash[initializer]
|
34
|
+
else
|
35
|
+
value # do not camelize values
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def camelize_key(k, parent_keys=[])
|
40
|
+
k = k.to_s
|
41
|
+
special = %w[Options] & parent_keys.map(&:to_s)
|
42
|
+
if special.empty?
|
43
|
+
k.camelize
|
44
|
+
else
|
45
|
+
k # pass through untouch
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/ufo/stack/context.rb
CHANGED
@@ -2,13 +2,15 @@ class Ufo::Stack
|
|
2
2
|
class Context
|
3
3
|
extend Memoist
|
4
4
|
include Helper
|
5
|
+
include Ufo::Settings
|
5
6
|
|
7
|
+
attr_reader :stack_name
|
6
8
|
def initialize(options)
|
7
9
|
@options = options
|
8
10
|
@task_definition = options[:task_definition]
|
9
11
|
@service = options[:service]
|
10
12
|
# no need to adjust @cluster or @stack_name because it was adjusted in Stack#initialize
|
11
|
-
@cluster = options[:cluster]
|
13
|
+
@cluster = options[:cluster].dup # Thor options are frozen, we thaw it because CustomProperties#substitute_variables does a sub!
|
12
14
|
@stack_name = options[:stack_name]
|
13
15
|
|
14
16
|
@stack = options[:stack]
|
@@ -20,36 +22,44 @@ class Ufo::Stack
|
|
20
22
|
# Add additional variable to scope for CloudFormation template.
|
21
23
|
# Dirties the scope but needed.
|
22
24
|
vars = {
|
25
|
+
service: @service,
|
23
26
|
cluster: @cluster,
|
24
27
|
stack_name: @stack_name, # used in custom_properties
|
25
28
|
container: container,
|
29
|
+
# to reconstruct TaskDefinition in the CloudFormation template
|
30
|
+
task_definition: @task_definition,
|
31
|
+
rollback_definition_arn: @options[:rollback_definition_arn],
|
26
32
|
# elb options remember that their 'state'
|
27
33
|
create_elb: create_elb?, # helps set Ecs DependsOn
|
28
34
|
elb_type: elb_type,
|
29
35
|
subnet_mappings: subnet_mappings,
|
30
|
-
create_route53: create_elb? &&
|
36
|
+
create_route53: create_elb? && has_dns_name?,
|
31
37
|
default_target_group_protocol: default_target_group_protocol,
|
32
38
|
default_listener_protocol: default_listener_protocol,
|
33
39
|
default_listener_ssl_protocol: default_listener_ssl_protocol,
|
34
40
|
create_listener_ssl: create_listener_ssl?,
|
35
41
|
}
|
36
|
-
|
37
|
-
# pp vars
|
42
|
+
|
38
43
|
scope.assign_instance_variables(vars)
|
39
44
|
scope
|
40
45
|
end
|
41
46
|
memoize :scope
|
42
47
|
|
48
|
+
def has_dns_name?
|
49
|
+
cfn.dig(:Dns, :Name) || cfn.dig(:dns, :name) # backwards compatiblity
|
50
|
+
end
|
51
|
+
|
43
52
|
def default_target_group_protocol
|
44
53
|
return 'TCP' if elb_type == 'network'
|
45
54
|
'HTTP'
|
46
55
|
end
|
47
56
|
|
48
57
|
def default_listener_protocol
|
58
|
+
port = cfn.dig(:Listener, :Port) || cfn.dig(:listener, :port) # backwards compatiblity
|
49
59
|
if elb_type == 'network'
|
50
|
-
|
60
|
+
port == 443 ? 'TLS' : 'TCP'
|
51
61
|
else
|
52
|
-
|
62
|
+
port == 443 ? 'HTTPS' : 'HTTP'
|
53
63
|
end
|
54
64
|
end
|
55
65
|
|
@@ -59,32 +69,8 @@ class Ufo::Stack
|
|
59
69
|
|
60
70
|
# if the configuration is set to anything then enable it
|
61
71
|
def create_listener_ssl?
|
62
|
-
cfn
|
63
|
-
end
|
64
|
-
|
65
|
-
def container
|
66
|
-
resp = ecs.describe_task_definition(task_definition: @task_definition)
|
67
|
-
task_definition = resp.task_definition
|
68
|
-
|
69
|
-
container_def = task_definition["container_definitions"].first
|
70
|
-
requires_compatibilities = task_definition["requires_compatibilities"]
|
71
|
-
fargate = requires_compatibilities && requires_compatibilities == ["FARGATE"]
|
72
|
-
network_mode = task_definition["network_mode"]
|
73
|
-
|
74
|
-
mappings = container_def["port_mappings"] || []
|
75
|
-
unless mappings.empty?
|
76
|
-
port = mappings.first["container_port"]
|
77
|
-
end
|
78
|
-
|
79
|
-
result = {
|
80
|
-
name: container_def["name"],
|
81
|
-
fargate: fargate,
|
82
|
-
network_mode: network_mode, # awsvpc, bridge, etc
|
83
|
-
}
|
84
|
-
result[:port] = port if port
|
85
|
-
result
|
72
|
+
cfn.dig(:ListenerSsl, :Port) || cfn.dig(:listener_ssl, :port) # backwards compatiblity
|
86
73
|
end
|
87
|
-
memoize :container
|
88
74
|
|
89
75
|
def create_elb?
|
90
76
|
create_elb, _ = elb_options
|
@@ -135,6 +121,29 @@ class Ufo::Stack
|
|
135
121
|
[create_elb, elb_target_group]
|
136
122
|
end
|
137
123
|
|
124
|
+
def container
|
125
|
+
task_definition = Builder::Resources::TaskDefinition::Reconstructor.new(@task_definition, @options[:rollback]).reconstruct
|
126
|
+
|
127
|
+
container_def = task_definition["ContainerDefinitions"].first
|
128
|
+
requires_compatibilities = task_definition["RequiresCompatibilities"]
|
129
|
+
fargate = requires_compatibilities && requires_compatibilities == ["FARGATE"]
|
130
|
+
network_mode = task_definition["NetworkMode"]
|
131
|
+
|
132
|
+
mappings = container_def["PortMappings"] || []
|
133
|
+
unless mappings.empty?
|
134
|
+
port = mappings.first["ContainerPort"]
|
135
|
+
end
|
136
|
+
|
137
|
+
result = {
|
138
|
+
name: container_def["Name"],
|
139
|
+
fargate: fargate,
|
140
|
+
network_mode: network_mode, # awsvpc, bridge, etc
|
141
|
+
}
|
142
|
+
result[:port] = port if port
|
143
|
+
result
|
144
|
+
end
|
145
|
+
memoize :container
|
146
|
+
|
138
147
|
def get_parameter_value(stack, key)
|
139
148
|
param = stack.parameters.find do |p|
|
140
149
|
p.parameter_key == key
|
@@ -188,10 +197,8 @@ class Ufo::Stack
|
|
188
197
|
|
189
198
|
def build_subnet_mappings!(allocations)
|
190
199
|
unless allocations.size == network[:elb_subnets].size
|
191
|
-
# puts "caller:".color(:cyan)
|
192
|
-
# puts caller
|
193
200
|
puts "ERROR: The allocation_ids must match in length to the subnets.".color(:red)
|
194
|
-
puts "Please double check that .ufo/settings/network/#{settings
|
201
|
+
puts "Please double check that .ufo/settings/network/#{settings.network_profile} has the same number of subnets as the eip allocation ids are you specifying."
|
195
202
|
subnets = network[:elb_subnets]
|
196
203
|
puts "Conigured subnets: #{subnets.inspect}"
|
197
204
|
puts "Specified allocation ids: #{allocations.inspect}"
|
@@ -242,19 +249,5 @@ class Ufo::Stack
|
|
242
249
|
end
|
243
250
|
memoize :elb_type
|
244
251
|
|
245
|
-
def network
|
246
|
-
Ufo::Setting::Profile.new(:network, settings[:network_profile]).data
|
247
|
-
end
|
248
|
-
memoize :network
|
249
|
-
|
250
|
-
def cfn
|
251
|
-
Ufo::Setting::Profile.new(:cfn, settings[:cfn_profile]).data
|
252
|
-
end
|
253
|
-
memoize :cfn
|
254
|
-
|
255
|
-
def settings
|
256
|
-
Ufo.settings
|
257
|
-
end
|
258
|
-
|
259
252
|
end
|
260
253
|
end
|