Reputation: 2294
I have a EC2 Instance which only have Private IP and I have installed the Apache Kafka on same Instance running on say 10.0.4.44:9092
.
Now, I have created the AWS Lambda Function which read the document from given Bucket and sent the Document body to Apache Kafka running on EC2 Instance.
Now, AWS Lambda is unable to access the EC2 Instance Service.
How Can I grant access to Lambda for accessing Apache kafka Service on EC2?
Upvotes: 4
Views: 3622
Reputation: 201058
You need to add the Lambda function to the VPC the EC2 server is running in. Here's the announcement blog post of Lambda VPC support with a walk through for setting it up. Here's the official documentation.
A Lambda function in a VPC will not get a public IP address. This means it won't be able to access anything that is outside the VPC. Since you also need to access S3 you will need to setup an S3 VPC Endpoint so that your function will still have S3 access.
If your function needs access to other things outside the VPC then you will have to add it to a private subnet of the VPC with a NAT Gateway attached.
Upvotes: 7