How to programmatically register a lambda listener rule to an ALB?

Question:

Given that ALB Lambda integration is not currently supported by Cloudformation, I am trying to write a simple script to create a target group, register the lambda to the target group and then point a listener rule to that target group.

This works when I do it by the user interface however my attempts to register the lambda target to the target group fail (both in python script and cli):

Below is the python script which does this:

Thank you

Answer:

You will have to create add a lambda function permission to allow the elasticloadbalancing principal to invoke your lambda function.
With CloudFormation you can add the following resource to make it work.

More information on the Lambda Add Permission functionality can be found here: https://docs.aws.amazon.com/lambda/latest/dg/API_AddPermission.html

Leave a Reply