Skip to content

How to properly set up interface VPC endpoint to enable Lambda function attached to VPC (parent) to call 2nd Lambda function (child) with no VPC?

0

Hello to everyone, i am in need to be able to chain two Lambda functions: the first one (parent function) is attached to a vpc and it needs to call a second function (child function) that is not attached to any vpc; ideally the child function should be called syncronously.

After extensive research, it turns out that all i need to do is create an interface vpc endpoint and then the parent function should be able to call the second function directly as per this Stakoverflow thread:

https://stackoverflow.com/questions/76177398/lambda-invocations-from-a-vpc-dont-go-through-the-vpc-interface-endpoint-for-la

Utilizing the code snippet provided by the accepted answer with the DNS from the interface endpoint i created returned a ValueError type error which states "Invalid Endpoint". This clearly means i set up something wrong when configuring the endpoint. Therefore, i also went on and check anything else that i could have messed up:

  • in the vpc setting the DNS resolution and the DNS hostnames options are enabled;
  • the lambda parent function and the endpoint both live in the same vpc and subnet; the subnet is private;
  • the service IAM role for both lambda functions has the relevant permissions InvokeFunction & GetFunction;
  • the security group for the functions allows both inbound and outbound traffic on all ports within the CIDR block of vpc;
  • the security group for the interface endpoint has the same rules but it also allows for all inbound traffic on port 443 with HTTPS protocol;
  • the Private DNS names option in the endpoint settings is enabled;
  • the Private DNS only inbound resolver endpoint setting is disabled;

My code is:

lambda_client = boto3.client("lambda", region_name="ap-southeast-2", endpoint_url="vpce-123456789-asdfghjk.lambda.ap-southeast-2.vpce.amazonaws.com") lambda_client.invoke(FunctionName="arn:aws:lambda:ap-southeast-2:ACCOUNTID:function:FUNCTION NAME")

At this point i cannot really find any online thread/blog/article that explains in detail how should i configure the endpoint settigs or what i am missing. Any help would be highly appreciated.

Thanks in advance to everyone.

Stefano

asked 2 years ago1.6K views

2 Answers
5
Accepted Answer

Hello.

If the private DNS name of the VPC endpoint is enabled, I think there is no need to set "endpoint_url" when creating a boto3 client.
If you enable the private DNS name of the VPC endpoint, the name resolution of the AWS service endpoint from within the VPC will be the private IP address of the VPC endpoint, so there should be no need to explicitly access it with "endpoint_url".
https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-access-aws-services.html#interface-endpoint-private-dns

If you enable private DNS for your interface VPC endpoint, and your VPC has both DNS hostnames and DNS resolution enabled, we create a hidden, AWS-managed private hosted zone for you. The hosted zone contains a record set for the default DNS name for the service that resolves it to the private IP addresses of the endpoint network interfaces in your VPC. Therefore, if you have existing applications that send requests to the AWS service using a public Regional endpoint, those requests now go through the endpoint network interfaces, without requiring that you make any changes to those applications.

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

EXPERT

reviewed 2 years ago

EXPERT

reviewed 2 years ago

0

Bella Riku!!

It bloody works, mate! Thank you very much, it works like a charm; i just reverted back to my previous code and it just worked.

Have a good weekend!

answered 2 years 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.