In AWS, can an EC2 instance be in more than one VPC at the same time?
I think the answer is no, but I want to make sure that I'm not missing anything. Is it possible for an EC2 instance to have IP addresses in more than one VPC at the same time?
I tried creating 2 VPCs, and then two network interfaces, one in each VPC, but it seems it's not possible to attach them to the same EC2 instance because it's not possible to attach them to an instance that's not on that VPC, is this correct?
For example, I create vpc1 and eni1 (network interface) in vpc1. Then I create vpc2 and eni2 in vpc2. Then I create ec21 (an EC2 instance) and put it in vpc1 with eni1 as its network interface. When I open eni2 and I select attach, I can't select ec21, it says:
No running or stopped instances in us-esat-1f in vpc2.
No, that is not possible
Network interfaces can only be attached to instances in the same VPC as the interface.
Amazon VPC FAQs
Your ec2 instance is bound to the VPC of its primary network interface. If you want cross VPC connection you need to setup VPC peering or VPN.
A ec2 instance can have multiple network interfaces in multiple subnets but they must all be in the same VPC.