AWS Lambda Function Update Security Group Rules

0

I need AWS Lambda Function which triggers on AWS ECS Event ECS Task Rolling Update, takes the public IP's from the task and update the associated security group on the ALB with the newly created Ips. I have 2 services with 1 task definition inside. Is there any Lambda which i can use in Python or any language?

  • You're looking for code reference on how to do that with AWS Lambda?

  • Yeah, exactly

Vasko
asked 6 months ago256 views
2 Answers
0

You can detect an ECS Task State (New or existing) using the "aws.ecs@ECSTaskStateChange" event on Amazon EventBridge when creating a Rule: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-lifecycle.html https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs_cwe_events.html

Then you can configure the EventBridge Rule to invoke the Lambda to get the IP from the Event data and Implement the desired changes in your ALB Security Groups.

AWS
vtjean
answered 6 months ago
  • I'm doing that, but i'm struggiling with the Lambda function. Would you like to provide me with an example of the Lambda function?

0

Quick question, Why do you need to do this? Perhaps look at fixing the reason that you do this?

Initially I’m thinking you may want to setup and internal ALB with split horizon DNS which may solve the issue your facing and I’ve fixed several times.

profile picture
EXPERT
answered 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions