gpt4 book ai didi

AWS VPC Peering with private instances of other VPC under auto scaling group(AWS VPC与弹性伸缩组下其他VPC的内网实例对等)

转载 作者:bug小助手 更新时间:2023-10-26 21:16:06 25 4
gpt4 key购买 nike



I have successfully created a VPC peering connection between two private instances if I know their private IP addresses. However, I want to achieve a VPC peering for private instances under the auto-scaling group. Please have a look at the following diagram to understand the infrastructure layout.

如果我知道两个内网实例的内网IP地址,我已经成功创建了两个内网实例之间的私有网络对等连接。不过,我想实现弹性伸缩组下的内网实例的私有网络对等。请看下图以了解基础设施布局。


enter image description here


One of my applications is deployed over a private instance, in VPC B which needs a connection to another application deployed in private instances of VPC A. All the instances are highly scalable due to the Load Balancer and Scaling group.

我的一个应用部署在私有网络B中的私有实例上,需要连接到私有网络A的私有实例中部署的另一个应用。由于有负载均衡和伸缩组,所有实例都具有高度的可扩展性。


One way to achieve this connection is a NAT gateway installed in the public subnet of VPC B to request out to the Internet and received by VPC A and routed towards the load balancer. This is a long round trip, and it has more cost. So I want to achieve it by other means like VPC peering but How can I determine the private IP for instances under VPC A at run time?

实现此连接的一种方法是在私有网络B的公用子网中安装NAT网关,以请求出站到Internet,由私有网络A接收并路由到负载均衡器。这是一个很长的往返旅程,而且成本更高。所以我想通过私有网络对等等其他方式来实现,但是如何在运行时确定私有网络A下的实例的内网IP?


Or can we use VPC peering to do a connection towards the Loadbalancer of VPC A which can route to any private instance?

或者我们可以使用私有网络对等连接到私有网络A的负载均衡,从而可以路由到任何内网实例?


Any help is greatly appreciated.

如有任何帮助,我们不胜感激。


Edit:

编辑:


Current Configuration:
Here is how currently traffic discovers VPC A.

当前配置:以下是当前流量发现VPC A的方式。


When I call https://www.domainForVPCAPrivateInstance.com/api/healthCheck
from any private instance under VPC B, Here is the route It take.

当我从私有网络B下的任意内网实例调用https://www.domainForVPCAPrivateInstance.com/api/healthCheck时,它的路径如下所示。


VPC-B: private ec2 -> NAT gateway => internet -> DNS translation -> VPC A: Elastic load blanacer -> to any private instance in VPC A

私有网络-B:内网EC2->NAT网关=>互联网->域名转换->私有网络A:弹性负载分配器->到私有网络A中的任意内网实例


See Here traffic went through the internet. But VPC peering allows us to communicate between two VPC privately. But for that I have to know the private IP of any instance in VPC A. e.g.

看这里,流量是通过互联网的。但VPC对等允许我们在两个VPC之间进行私下通信。但要做到这一点,我必须知道VPC A中任何实例的内网IP。


https://private-ip-of-ec2-under-vpc-A/api/healthCheck

Https://private-ip-of-ec2-under-vpc-A/api/healthCheck


Right? But I can't determine. IP of instances when they are under load balancer and auto scaling group. They are highly scalable. So which solution allows to communicate between two VPCs' private instances privately when they are under auto scaling?

对吗?但我不能确定。负载均衡和弹性伸缩组下的实例IP。它们具有高度的可扩展性。那么,在弹性伸缩下,哪种方案可以实现两个私有网络内网实例之间的私密通信?


更多回答

A VPC peering connection is a networking connection between two VPCs that enables you to route traffic between them using private IPv4 addresses or IPv6 addresses. (From https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html). You can see scenarios and configurations on that page.

私有网络对等连接是两个私有网络之间的网络连接,使您可以使用私有IPv4地址或IPv6地址来路由它们之间的流量。(来自https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html).您可以在该页面上查看场景和配置。

@Franxi , Yes I know that its between private ipv4. How can I determine the private Ipv4 address of private instances running under the load balancer and auto scaling group? that was my actual question.

@Frxi,是的,我知道它在私有的IPv4之间。如何确定负载均衡和弹性伸缩组下运行的内网实例的内网IPv4地址?这才是我真正的问题。

Why you have to determine the private IPv4 address of private instances running under the load balancer? Peering between 2 VPCs, so the traffic can be routed to LB or EC2 ... Of course, you need to update the route table.

为什么要确定负载均衡下运行的内网实例的内网IPv4地址?在两个私有网络之间对等,这样流量就可以路由到负载均衡或EC2...当然,您需要更新路由表。

"I want to achieve it" I don't understand what you are trying to achieve. what are you asking to do, specifically?

“我想实现它”我不明白你想要实现什么。你具体要求做什么?

@Mubasher Accessing the instances directly is not a good solution in your case. You already know that. I think you can consider using NAT GW or internal ALB + VPC peering. Maybe you need to compare pricing, scalability, security, operation effort...

@Mubasher直接删除实例在您的情况下不是一个好的解决方案。你已经知道了我认为您可以考虑使用NAT GW或内部ALB + VPC对等。也许您需要比较定价、可扩展性、安全性、运营工作量.

优秀答案推荐

You could use something like AWS Cloud Map.

您可以使用AWS Cloud Map。


Or you could have your code running in VPC B do some sort of lookup using the AWS API, via an AWS SDK, to get the list of instances registered with the load balancer.

或者,您可以让在vPC B中运行的代码通过AWS SDK使用AWS API执行某种查找,以获取向负载均衡器注册的实例列表。


Or you could add an Internal load balancer that points to the same targets, and make your requests to that.

或者,您可以添加指向相同目标的内部负载平衡器,并向其发出请求。


更多回答

Can we use private endpoint? I don't have account to test it.

我们可以使用私有终端吗?我没有账户来测试它。

@FranxiHidro do you mean AWS Private Link? docs.aws.amazon.com/vpc/latest/privatelink/concepts.html Yes you could use that, but it still requires you to create another load balancer.

@FransHidro你是指AWS私有链接吗?Docs.aws.amazon.com/vpc/latest/privatelink/concepts.html是的,您可以使用它,但它仍然需要您创建另一个负载均衡器。

I mean the VPC endpoint, powered by AWS PrivateLink. I know it can work for the internal ALB, but I'm not sure about the internet-facing ALB.

我指的是vPC终端,由AWS PrivateLink提供支持。我知道它可以用于内部的白蛋白,但我不确定面向互联网的白蛋白。

@FranxiHidro You can't use AWS PrivateLink with an ALB at all, you have to have an NLB.

@FransHidro您根本不能将AWS PrivateLink与ALB一起使用,您必须拥有NLB。

@MarkB I will evaluate all three solutions and will check which one works and is more feasible in terms of scalability and cost.

@MarkB我将评估所有三种解决方案,并检查哪一种方案有效,在可扩展性和成本方面更可行。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com