Added application load balancer event but getting HTTP 503: Service Unavailable errors

HI folks. I’ve added an alb event in my serverless.yml

        - alb:
          listenerArn: !Ref ALBListenerId
          priority: 1
            path: /path/url
              - POST
        Type: AWS::ElasticLoadBalancingV2::Listener
              Order: 1
              Type: forward
              TargetGroupArn: !ImportValue ALBTargetGroupArn
          LoadBalancerArn: !ImportValue ALBArn
          Port: 80
          Protocol: HTTP

With the ALBTargetGroupArn and ALBArn being exported from a different stack. However when I try hit the alb url with matching path I get a 503 error. This generally means the target groups for the load balancer have no registered targets. What could be the cause of this as I’ve clearly added triggers in my serverless.yml? Also noticed that after I deploy the alb trigger is not visible on the lambda dashboard. If I add manually everything works ok

If you go to the target group under ‘EC2’ in the AWS console, you’ll find you need to manually assign the target lambda in the “Targets” tab.

I’m still looking for an automated way to do this - it appears that CF still doesn’t support this and serverless.yml ‘alb’ isn’t fully baked either.

The best avenue seems to be setting up a custom resource for you stack to use which executes the API calls to register the targets:
aws elbv2 register-targets
–target-group-arn arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-tcp-ip-targets/8518e899d173178f
–targets Id=arn:aws:lambda:us-west-2:123456789012:function:my-function