In VPC, EC2 works, lambda fails on call to iot:describe-endpoint

0

I have an EC2 instance and a lambda. They have the same:

  • region
  • VPC
  • subnets
  • security groups
  • inbound rules
  • outbound rules
  • iot permissions

On EC2:

$ aws iot describe-endpoint --endpoint-type iot:Data-ATS

returns my accounts endpoint address.

I want to run the equivalent on a lambda:

const client = new IoTClient({});
const response = await client.send(
            new DescribeEndpointCommand({ endpointType: "iot:Data-ATS" })
        );

client does not return (and the lambda times out).

If I move the lambda out of the VPC, client returns a response and it is correct.

I cannot see why describe-endpoint works on EC2 in a VPC, but not on lambda in the same VPC (with the same apparent subnet, security group, and permissions).

ben
질문됨 9달 전288회 조회
2개 답변
0
수락된 답변

Hello.

Is there a route to the NAT Gateway in the route table for the subnet that Lambda is using?
Even if Lambda is tied to a public subnet, the ENI is not set to a public IP address, so API execution, etc. will fail.
So you need to set up a NAT Gateway, VPC endpoints, etc. to avoid this.
https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html#vpc-internet

profile picture
전문가
답변함 9달 전
  • the ENI is not set to a public IP address

    I had forgotten about that. Thank you very much.

0

Lambda functions that you attach to a VPC do not have internet access like Lambda functions which you do not attach. If your function is attached to a VPC, it must be attached to private subnets and you also need an IoT core VPC endpoint or a NAT Gateway and a route in the private subnets to the NAT Gateway.

You should only attach the function to the VPC if you actually need to access resources within the VPC.

profile pictureAWS
전문가
Uri
답변함 9달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠