Skip to content

[BUG] Rendering ELB no additional target group is present #810

@dromero-cibernetica

Description

@dromero-cibernetica

Describe the bug
Once rendered, the resulting elb cloudformation has only one target group linked with alb but there are two target groups in docker yaml

The clodformation template has the two target groups but only the first one is referenced in alb resource. When deploying throws error indicating one target group is not associated to load balancer

To Reproduce
Steps to reproduce the behavior:

  1. How you installed ECS ComposeX'...' in a docker container
    docker run -u 0:0 -it --env-file /tmp/.awsenv --rm -v /root/.aws:/tmp/.aws -e HOME=/tmp -v /var/usr/dat/deploys/repos/test-deploy-ecs-compose-x:/tmp 666666666666.dkr.ecr.us-east-2.amazonaws.com/composex/compose-x:v1.1.8-py310-amd64-fix807b render --name xtest --format yaml -d cfn.templates.d -f docker-compose.yaml -f aws-compose.yaml
  2. How you are executing it ? : As a CLI tool, as a library, in lambda? CLI
  3. Link / share your Docker compose file (it is merged into one file using "docker compose config")
name: xtest
services:
  backend:
    build:
      context: backend
      dockerfile: Dockerfile
    deploy:
      resources:
        limits:
          cpus: 0.5
          memory: 256MB
        reservations:
          cpus: 0.1
          memory: 128MB
    image: 66666666666.dkr.ecr.us-east-2.amazonaws.com/backend:latest
    ports:
      - name: tcp_80
        protocol: tcp
        published: 80
        target: 80
    x-ecr:
      InterpolateWithDigest: true
    x-network:
      Ingress:
        Myself: true
        Services:
          - Name: frontend
      x-ecs_connect:
        MacroParameters:
          service_ports:
            tcp_80:
              CloudMapServiceName: backend
              DnsName: backend
          x-cloudmap: private-namespace
  frontend:
    build:
      context: frontend
      dockerfile: Dockerfile
    deploy:
      resources:
        limits:
          cpus: 0.5
          memory: 256MB
        reservations:
          cpus: 0.1
          memory: 128MB
    image: 66666666666.dkr.ecr.us-east-2.amazonaws.com/frontend:latest
    ports:
      - name: tcp_80
        protocol: tcp
        published: 80
        target: 80
    x-ecr:
      InterpolateWithDigest: true
    x-network:
      x-cloudmap:
        private-namespace:
          Hostname: frontend
x-acm:
  app:
    MacroParameters:
      DomainNames:
        - xtest.dev.example.xyz
        - www.xtest.dev.example.xyz
        - api.xtest.dev.example.xyz
      HostedZoneId: x-route53::public-domain
x-cloudmap:
  private-namespace:
    ZoneName: testing.cluster.internal
x-elbv2:
  public-alb:
    DnsAliases:
      - Names:
          - xtest.dev.example.xyz
          - www.xtest.dev.example.xyz
          - api.xtest.dev.example.xyz
        Route53Zone: x-route53::public-domain
    Listeners:
      - DefaultActions:
          - Redirect: HTTP_TO_HTTPS
            RedirectConfig:
              StatusCode: HTTP_301
        Port: 80
        Protocol: HTTP
      - Certificates:
          - x-acm: app
        Port: 443
        Protocol: HTTPS
        Targets:
          - Conditions:
              - Field: host-header
                Values:
                  - xtest.dev.example.xyz
                  - www.xtest.dev.example.xyz
            name: frontend:frontend:80
          - Conditions:
              - Field: host-header
                Values:
                  - api.xtest.dev.example.xyz
            name: backend:backend:80
    MacroParameters:
      Ingress:
        ExtSources:
          - Description: Allow Internet access
            IPv4: 0.0.0.0/0
            Name: Anywhere
    Properties:
      Scheme: internet-facing
      Type: application
    Services:
      backend:backend:
        healthcheck:
          HealthCheckEnabled: true
          HealthCheckPath: /
          HealthCheckProtocol: HTTP
        port: 80
        protocol: HTTP
      frontend:frontend:
        healthcheck:
          HealthCheckEnabled: true
          HealthCheckPath: /
          HealthCheckProtocol: HTTP
        port: 80
        protocol: HTTP
x-route53:
  public-domain:
    Lookup: true
    ZoneName: xtest.dev.example.xyz
x-tags:
  - Key: Workload
    Value: xtest-app
  1. See error
.....
      ToPort: 80
    Type: AWS::EC2::SecurityGroupIngress
  Tgtpublicalbbackendbackend80:
    Properties:
      HealthCheckEnabled: true
      HealthCheckIntervalSeconds:
--
      VpcId:
        Ref: VpcId
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
  Tgtpublicalbfrontendfrontend80:
    Properties:
      HealthCheckEnabled: true
      HealthCheckIntervalSeconds:
--
      VpcId:
        Ref: VpcId
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
  publicalb:
    Properties:
      IpAddressType: ipv4
--
            TargetGroups:
              - TargetGroupArn:
                  Ref: Tgtpublicalbbackendbackend80
          Order: 1
          Type: forward
      Conditions:
......

There is no Ref to Tgtpublicalbfrontendfrontend80

Expected behavior
Both target groups must be ref in alb

Logs
If applicable, add logs of errors using from ECS ComposeX

Desktop (please complete the following information):

  • OS: [e.g. Fedora/Windows/Mac] Amazon Linux 2023
  • Python version (3.6,3.7,3.8) 3.10
  • If you were doing things from a branch, which one? main
  • Commit ID ? 9dfa53b
  • Tag/Version? 1.1.8

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions