compose-x / ecs_composex

Manage, Configure and Deploy your services and AWS services and applications from your docker-compose definitions
https://docs.compose-x.io
Mozilla Public License 2.0
158 stars 16 forks source link

[BUG] elbv2 with empty DefaultActions crashes on target with Conditions #696

Closed thorfi closed 8 months ago

thorfi commented 8 months ago

elbv2 with empty DefaultActions crashes on target with Conditions

To Reproduce Steps to reproduce the behavior:

  1. How you installed ECS ComposeX (via pip install)

  2. How you are executing it ? (as a cli tool)

  3. Docker compose chunk:

    x-elbv2: # ecscomposex
    application-elb:
    Properties:
      Scheme: internet-facing
      Type: application
      LoadBalancerAttributes:
        idle_timeout.timeout_seconds: "4000"
        routing.http.drop_invalid_header_fields.enabled: "true"
    MacroParameters:
      cross_zone: true
      desync_mitigation_mode: defensive
      Ingress:
        ExtSources:
          - IPv4: "0.0.0.0/0"
            Description: ANY
    DnsAliases:
      - Route53Zone: x-route53::public-zone
        Names:
          - "*.example.com"
          - "example.com"
    Services:
      - name: foo:foo
        port: 3680
    Listeners:
      - Port: 80
        Protocol: HTTP
        Certificates: [ ] # We explicitly don't have any
        DefaultActions:
          - Redirect: HTTP_TO_HTTPS
        Targets: [ ] # We explicitly don't have any
      - Port: 443
        Protocol: HTTPS
        Certificates:
          - CertificateArn: "...."
          - x-acm: public-cert
        DefaultActions: []
        Targets:
          - name: spindle:spindle
            Conditions:
            - Field: host-header
              HostHeaderConfig:
                Values:
                  - "example.com"
                  - "*?.example.com"
                  - "help.example.com"
  4. Crash here:

    ecs_composex/elbv2/elbv2_stack/helpers.py", line 402, in handle_non_default_services
    if isinstance(service_def["access"], str) and service_def["access"] == "/":
                  ~~~~~~~~~~~^^^^^^^^^^
    KeyError: 'access'

Expected behavior This should not crash on the missing access clause work and fall through to returning "I'm a teapot".

Logs N/A.

Desktop:

thorfi commented 8 months ago

FYI I am working on a fork and PR for this already.

JohnPreston commented 8 months ago

Hi @thorfi Thanks for the report and the PR. The error though indicates that you are missing the access key which would be used to create initial conditions. Understandably though, I suppose if you set the Conditions yourself then access shouldn't be required :thinking:

thorfi commented 8 months ago

@JohnPreston Feel free to merge...

Also, is this likely to be released to pip any time soon?

JohnPreston commented 8 months ago

@JohnPreston Feel free to merge...

Also, is this likely to be released to pip any time soon?

Yeah defo. Can create a RC if you'd like so you can test with the install from pip and publish the fix off the back of it

JohnPreston commented 8 months ago

Published 0.23.27-rc2 Got a couple of open bugs to fix before release, unless that's a blocker for you in which case let me know

thorfi commented 8 months ago

No rush, for now I'm just pip installing directly off my fork and that works fine :-)