How do I deregister old IP from NLB and update it with the new one using lambda function?

Viewed 92

I have an EMR cluster running on AWS and the target group of my NLB points to the IP of the master node of the EMR cluster, when this cluster terminates and is created again I want the target group to point to the new IP of the cluster using a lambda function.

How should I go about it? I will use AWS eventbridge to trigger lambda function every five minutes, thanks in advance for your help!

1 Answers

Your lambda function has to use deregister_targets and deregister_targets to add and remove targets from your target group.

It also needs permissions to do so in its execution role.

Related