Unable to Connect API Gateway to Internal Network Load Balancer in VPC

0

I have set up a network load balancer (NLB) in a VPC, which is associated only with private subnets. This NLB is internal and is not internet-facing. My goal is to connect from the API Gateway to this NLB. I found a workaround where changing the security group to allow all traffic (0.0.0.0/0) enables the connection, but this approach is not secure and not what I am aiming for.

Is there an appropriate method to securely connect the API Gateway to an internal NLB in a VPC? Could using a VPC endpoint be the solution to this problem?

4回答
2
承認された回答

As your using a REST API, then I believe the only option would to be allow the VPC CIDR Range eg, 172.31.0.0/16 in your security group instead of 0.0.0.0/0

UPDATED

You can also DISABLE Enforce inbound rules on PrivateLink traffic via the GUI on the NLB or CLI. This means private link traffic can still connect to the NLB if you dont allow any other traffic!

https://docs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-security-groups.html

Search for Enforce inbound rules on PrivateLink traffic. ^^

profile picture
エキスパート
回答済み 7ヶ月前
profile picture
エキスパート
レビュー済み 6日前
profile picture
エキスパート
レビュー済み 7ヶ月前
profile picture
エキスパート
レビュー済み 7ヶ月前
  • This Method Worked for me Thank you:-

    UPDATED

    You can also DISABLE Enforce inbound rules on PrivateLink traffic via the GUI on the NLB or CLI. This means private link traffic can still connect to the NLB if you dont allow any other traffic!

    https://docs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-security-groups.html

    Search for Enforce inbound rules on PrivateLink traffic. ^^

  • Just to add to the answer. I believe why the CIDR Range didnt work was because of the Target Group "Preserve client IP addresses" if this is disabled then it would have worked. By Default this setting is enabled. You will have to review your use case.

0

But I am Using Rest API

回答済み 7ヶ月前
  • Created new answer which should help

0

If using VPC Link for HTTP APIs then,

When you create your API Gateway VPC Link, you can define which security group to attach to the connection. This creates ENI's in your VPC with the SG attached.

Then, use this Security group ID as the source on your NLB security group. This will allow access from the APi Gateway security group and not a CIDR Range

profile picture
エキスパート
回答済み 7ヶ月前
0

Thank You for your Prompt Response , I tried to give my VPC CIDR Range eg, 172.31.0.0/16 in My security group instead of 0.0.0.0/0 , then still it didnt Worked.! and if i do the second approach is it secure?

回答済み 7ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ