|
32 | 32 | {{ if .Domain }} "{{.Domain}}" {{ else }} { "Fn::Join": [ ".", [ "{{$.App}}-{{.Name}}", { "Fn::ImportValue": { "Fn::Sub": "${Rack}:{{ router .Name $.Manifest }}Host" } } ] ] } {{ end }} |
33 | 33 | ] } |
34 | 34 | }, |
| 35 | + {{ if .InternalAndExternal }} |
| 36 | + "EndpointExternal": { |
| 37 | + "Value": { "Fn::If": [ "InternalDomains", |
| 38 | + { "Fn::Join": [ ".", [ "{{$.App}}-{{.Name}}", { "Fn::ImportValue": { "Fn::Sub": "${Rack}:RouterHost" } } ] ] }, |
| 39 | + {{ if .Domain }} "{{.Domain}}" {{ else }} { "Fn::Join": [ ".", [ "{{$.App}}-{{.Name}}", { "Fn::ImportValue": { "Fn::Sub": "${Rack}:RouterHost" } } ] ] } {{ end }} |
| 40 | + ] } |
| 41 | + }, |
| 42 | + "TargetGroupExternal": { |
| 43 | + "Value": { "Ref": "BalancerTargetGroupExternal" } |
| 44 | + }, |
| 45 | + {{ end }} |
35 | 46 | "TargetGroup": { |
36 | 47 | "Value": { "Ref": "BalancerTargetGroup{{ if .Internal }}Internal{{ end }}" } |
37 | 48 | }, |
|
319 | 330 | "VpcId": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:Vpc" } } |
320 | 331 | } |
321 | 332 | }, |
| 333 | + |
322 | 334 | "BalancerListenerRule80": { |
323 | 335 | "Type": "AWS::ElasticLoadBalancingV2::ListenerRule", |
324 | 336 | {{ if .Domain }} |
|
349 | 361 | "Priority": "{{ priority $.App .Name "default" -1 }}" |
350 | 362 | } |
351 | 363 | }, |
| 364 | + {{ if .InternalAndExternal }} |
| 365 | + "BalancerTargetGroupExternal": { |
| 366 | + "Type": "AWS::ElasticLoadBalancingV2::TargetGroup", |
| 367 | + "Properties": { |
| 368 | + "HealthCheckIntervalSeconds": "{{.Health.Interval}}", |
| 369 | + "HealthCheckTimeoutSeconds": "{{.Health.Timeout}}", |
| 370 | + "HealthyThresholdCount": "2", |
| 371 | + "UnhealthyThresholdCount": "2", |
| 372 | + "HealthCheckPath": "{{.Health.Path}}", |
| 373 | + "Matcher": { |
| 374 | + {{ if or (eq .Port.Scheme "grpc") (eq .Port.Scheme "secure-grpc") }} |
| 375 | + "GrpcCode": { "Ref": "LoadBalancerGrpcSuccessCodes" } |
| 376 | + {{ else }} |
| 377 | + "HttpCode": { "Ref": "LoadBalancerSuccessCodes" } |
| 378 | + {{ end }} |
| 379 | + }, |
| 380 | + "Port": "{{.Port.Port}}", |
| 381 | + {{ if eq .Port.Scheme "grpc" }} |
| 382 | + "Protocol": "HTTP", |
| 383 | + "ProtocolVersion": "GRPC", |
| 384 | + {{ else if eq .Port.Scheme "secure-grpc" }} |
| 385 | + "Protocol": "HTTPS", |
| 386 | + "ProtocolVersion": "GRPC", |
| 387 | + {{ else }} |
| 388 | + "Protocol": "{{ upcase .Port.Scheme }}", |
| 389 | + {{ end }} |
| 390 | + "TargetGroupAttributes": [ |
| 391 | + { "Key": "deregistration_delay.timeout_seconds", "Value": "{{.Drain}}" }, |
| 392 | + { "Key": "load_balancing.algorithm.type", "Value": { "Ref": "LoadBalancerAlgorithm" } }, |
| 393 | + { "Key": "slow_start.duration_seconds", "Value": { "Ref": "SlowStartDuration" } }, |
| 394 | + { "Key": "stickiness.enabled", "Value": "{{.Sticky}}" } |
| 395 | + ], |
| 396 | + "Tags": [ |
| 397 | + { "Key": "App", "Value": "{{$.App}}" }, |
| 398 | + { "Key": "Service", "Value": "{{.Name}}" } |
| 399 | + ], |
| 400 | + "TargetType": { "Fn::If": [ "IsolateServices", "ip", "instance" ] }, |
| 401 | + "VpcId": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:Vpc" } } |
| 402 | + } |
| 403 | + }, |
| 404 | + "BalancerListenerRule80External": { |
| 405 | + "Type": "AWS::ElasticLoadBalancingV2::ListenerRule", |
| 406 | + {{ if .Domain }} |
| 407 | + "Condition": "InternalDomainsAndRouteHttp", |
| 408 | + {{ else }} |
| 409 | + "Condition": "RouteHttp", |
| 410 | + {{ end }} |
| 411 | + "Properties": { |
| 412 | + "Actions": [ { "Type": "forward", "TargetGroupArn": { "Ref": "BalancerTargetGroupExternal" } } ], |
| 413 | + "Conditions": [ { "Field": "host-header", "Values": [ { "Fn::Join": [ ".", [ "{{$.App}}-{{.Name}}", { "Fn::ImportValue": { "Fn::Sub": "${Rack}:RouterHost" } } ] ] } ] } ], |
| 414 | + "ListenerArn": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:RouterListener80" } }, |
| 415 | + "Priority": "{{ priority $.App .Name "default-external" -1 }}" |
| 416 | + } |
| 417 | + }, |
| 418 | + "BalancerListenerRule443External": { |
| 419 | + "Type": "AWS::ElasticLoadBalancingV2::ListenerRule", |
| 420 | + {{ if .Domain }} |
| 421 | + "Condition": "InternalDomains", |
| 422 | + {{ end }} |
| 423 | + "Properties": { |
| 424 | + "Actions": [ { "Type": "forward", "TargetGroupArn": { "Ref": "BalancerTargetGroupExternal" } } ], |
| 425 | + "Conditions": [ { "Field": "host-header", "Values": [ |
| 426 | + { "Fn::Join": [ ".", [ "{{$.App}}-{{.Name}}", { "Fn::ImportValue": { "Fn::Sub": "${Rack}:RouterHost" } } ] ] } {{- if $.WildcardDomain }}, |
| 427 | + { "Fn::Join": [".", [ "*", "{{$.App}}-{{.Name}}", { "Fn::ImportValue": { "Fn::Sub": "${Rack}:RouterHost" } } ] ] } |
| 428 | + {{ end }} |
| 429 | + ] } ], |
| 430 | + "ListenerArn": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:RouterListener443" } }, |
| 431 | + "Priority": "{{ priority $.App .Name "default-external" -1 }}" |
| 432 | + } |
| 433 | + }, |
| 434 | + {{ end }} |
352 | 435 | {{ if $.WildcardDomain }} |
353 | 436 | "WildCardCertificate": { |
354 | 437 | "Type": "AWS::CertificateManager::Certificate", |
|
380 | 463 | "ListenerArn" : { "Fn::ImportValue": { "Fn::Sub": "${Rack}:{{ router .Name $.Manifest }}Listener443" } } |
381 | 464 | } |
382 | 465 | }, |
| 466 | + {{ if .InternalAndExternal }} |
| 467 | + "WildCardCertificateExternal": { |
| 468 | + "Type": "AWS::CertificateManager::Certificate", |
| 469 | + {{ if .Domain }} |
| 470 | + "Condition": "InternalDomains", |
| 471 | + {{ end }} |
| 472 | + "Properties": { |
| 473 | + "DomainName": { "Fn::Join": [ ".", [ "*", { "Fn::ImportValue": { "Fn::Sub": "${Rack}:RouterHost" } } ] ] }, |
| 474 | + "DomainValidationOptions": [ |
| 475 | + { |
| 476 | + "DomainName": { "Fn::Join": [ ".", [ "*", { "Fn::ImportValue": { "Fn::Sub": "${Rack}:RouterHost" } } ] ] }, |
| 477 | + "ValidationDomain": "convox.site" |
| 478 | + }, |
| 479 | + { |
| 480 | + "DomainName": { "Fn::Join": [ ".", [ "*", "{{$.App}}-{{.Name}}", { "Fn::ImportValue": { "Fn::Sub": "${Rack}:RouterHost" } } ] ] }, |
| 481 | + "ValidationDomain": "convox.site" |
| 482 | + } |
| 483 | + ], |
| 484 | + "SubjectAlternativeNames": [ { "Fn::Join": [ ".", [ "*", "{{$.App}}-{{.Name}}", { "Fn::ImportValue": { "Fn::Sub": "${Rack}:RouterHost" } } ] ] } ] |
| 485 | + } |
| 486 | + }, |
| 487 | + "AddListenerCertificatesExternal": { |
| 488 | + "Type" : "AWS::ElasticLoadBalancingV2::ListenerCertificate", |
| 489 | + {{ if .Domain }} |
| 490 | + "Condition": "InternalDomains", |
| 491 | + {{ end }} |
| 492 | + "Properties" : { |
| 493 | + "Certificates" : [ { "CertificateArn" : { "Ref": "WildCardCertificate" } } ], |
| 494 | + "ListenerArn" : { "Fn::ImportValue": { "Fn::Sub": "${Rack}:RouterListener443" } } |
| 495 | + } |
| 496 | + }, |
| 497 | + {{ end }} |
383 | 498 | {{ end }} |
384 | 499 | "RecordSetInternalDomain": { |
385 | 500 | "Type": "AWS::Route53::RecordSet", |
|
420 | 535 | "ListenerArn": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:{{ router .Name $.Manifest }}Listener443" } } |
421 | 536 | } |
422 | 537 | }, |
| 538 | + {{ if .InternalAndExternal }} |
| 539 | + "BalancerListenerCertificateExternal": { |
| 540 | + "Type": "AWS::ElasticLoadBalancingV2::ListenerCertificate", |
| 541 | + "Properties": { |
| 542 | + "Certificates": [ { "CertificateArn": { "Ref": "Certificate" } } ], |
| 543 | + "ListenerArn": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:RouterListener443" } } |
| 544 | + } |
| 545 | + }, |
| 546 | + {{ end }} |
423 | 547 | {{ range $i, $domain := .Domains }} |
424 | 548 | "BalancerListenerRule80Domain{{$i}}": { |
425 | 549 | "Type": "AWS::ElasticLoadBalancingV2::ListenerRule", |
|
446 | 570 | "Priority": "{{ priority $.App $.Service.Name $domain $i }}" |
447 | 571 | } |
448 | 572 | }, |
| 573 | + {{ if .InternalAndExternal }} |
| 574 | + "BalancerListenerRule80Domain{{$i}}External": { |
| 575 | + "Type": "AWS::ElasticLoadBalancingV2::ListenerRule", |
| 576 | + "Condition": "RouteHttp", |
| 577 | + {{ if gt $i 0 }} |
| 578 | + "DependsOn": "BalancerListenerRule80Domain{{ dec $i }}External", |
| 579 | + {{ end }} |
| 580 | + "Properties": { |
| 581 | + "Actions": [ { "Type": "forward", "TargetGroupArn": { "Ref": "BalancerTargetGroupExternal" } } ], |
| 582 | + "Conditions": [ { "Field": "host-header", "Values": [ "{{$domain}}" ] } ], |
| 583 | + "ListenerArn": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:RouterListener80" } }, |
| 584 | + "Priority": "{{ priority $.App $.Service.Name (printf "%s-external" $domain) $i }}" |
| 585 | + } |
| 586 | + }, |
| 587 | + "BalancerListenerRule443Domain{{$i}}External": { |
| 588 | + "Type": "AWS::ElasticLoadBalancingV2::ListenerRule", |
| 589 | + {{ if gt $i 0 }} |
| 590 | + "DependsOn": "BalancerListenerRule443Domain{{ dec $i }}External", |
| 591 | + {{ end }} |
| 592 | + "Properties": { |
| 593 | + "Actions": [ { "Type": "forward", "TargetGroupArn": { "Ref": "BalancerTargetGroupExternal" } } ], |
| 594 | + "Conditions": [ { "Field": "host-header", "Values": [ "{{$domain}}" ] } ], |
| 595 | + "ListenerArn": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:RouterListener443" } }, |
| 596 | + "Priority": "{{ priority $.App $.Service.Name (printf "%s-external" $domain) $i }}" |
| 597 | + } |
| 598 | + }, |
| 599 | + {{ end }} |
449 | 600 | {{ end }} |
450 | 601 | {{ end }} |
451 | 602 | {{ end }} |
|
616 | 767 | ] }, |
617 | 768 | {{ if .Port.Port }} |
618 | 769 | "HealthCheckGracePeriodSeconds": "{{.Health.Grace}}", |
619 | | - "LoadBalancers": [ { "ContainerName": "{{.Name}}", "ContainerPort": "{{.Port.Port}}", "TargetGroupArn": { "Ref": "BalancerTargetGroup{{ if .Internal }}Internal{{ end }}" } } ], |
| 770 | + "LoadBalancers": [ { "ContainerName": "{{.Name}}", "ContainerPort": "{{.Port.Port}}", "TargetGroupArn": { "Ref": "BalancerTargetGroup{{ if .Internal }}Internal{{ end }}" } } {{ if .InternalAndExternal }}, |
| 771 | + { "ContainerName": "{{.Name}}", "ContainerPort": "{{.Port.Port}}", "TargetGroupArn": { "Ref": "BalancerTargetGroupExternal" } } |
| 772 | + {{ end }} |
| 773 | + ], |
620 | 774 | "Role": { "Fn::If": [ "IsolateServices", { "Ref": "AWS::NoValue" }, { "Fn::ImportValue": { "Fn::Sub": "${Rack}:ServiceRole" } } ] }, |
621 | 775 | {{ end }} |
622 | 776 | "TaskDefinition": { "Ref": "Tasks" } |
|
0 commit comments