0

I have a lambda that needs to call ecs.run_task to start an ECS/Fargate task. I'm running in a VPC, so in order to call run_task I have to specify a subnet. Rather than figuring out what subnet to run in, is there a way to get that information from lambda itself?

As in within the lambda I could do, "Get my current subnet, and then use that in my call to ecs.run_task".

Is there a way to get my subnet in a lambda?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Steve
  • 4,457
  • 12
  • 48
  • 89

1 Answers1

0

The API GetFunctionConfiguration is called with the Lambda Function ARN and will provide the VPC config, part of which is the Subnet Id:

https://docs.aws.amazon.com/lambda/latest/dg/API_GetFunctionConfiguration.html

shariqmaws
  • 8,152
  • 1
  • 16
  • 35