Skip to content

Connecting a Lightsail Instance to a VPC on a Different Account, but Same Organization and Same Region

0

I will start by mentioning that I am fairly new to AWS, so excuse my inexperience.

Here is the issue: My company has a server running on Lightsail that we want to connect to a VPC I have created. From what I can tell, Lightsail can only be peered to the default VPC of the account that owns it. This is, quite frankly, a pain in the butt.

What is the best way for me to get a connection from my VPC to the lightsail we currently have running? I moved everything I built into my default VPC. Is there a way to grant shared ownership of the lightsail instance so I can peer it? Do I have to use multiple peering connections between vpcs? Is there a way to grant ownership of my VPC to the user that owns the lightsail instance so they can peer it? Is there a different approach to the solution that I am missing, maybe involving gateways? I am really struggling to find a way to get this to work. Thank you in advance.

2 Answers
1

Hello.

Lightsail's VPC peering can only use the default VPC.
https://docs.aws.amazon.com/lightsail/latest/userguide/lightsail-how-to-set-up-vpc-peering-with-aws-resources.html

The VPC running Lightsail is managed by AWS, so the Transit Gateway settings answered by AWS re:Post Agent cannot be used.
Also, with VPC peering, you cannot communicate with a VPC that does not have a peering connection with your VPC, so in the case of Lightsail, you can only communicate with the default VPC.
https://docs.aws.amazon.com/vpc/latest/peering/vpc-peering-basics.html#vpc-peering-basics-multiple

Therefore, if you want to allow connections from Lightsail to multiple VPCs, I think it is a good idea to configure PrivateLink.
First, set up VPC peering with your default VPC and Lightsail VPC.
Then configure NLB.
When configuring NLB, set the private IP address of your Lightsail instance as the target.
After setting up NLB, create a VPC endpoint service and create a VPC endpoint for each VPC to communicate from PrivateLink to Lightsail.
a
https://docs.aws.amazon.com/vpc/latest/privatelink/create-endpoint-service.html

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

-1

I understand your frustration with connecting a Lightsail instance to a VPC in a different account, even within the same organization. You're correct that Lightsail instances can only be peered with the default VPC in the same AWS account and region. This limitation can indeed be challenging when working across accounts.

Given your situation, here are a few potential approaches you could consider:

  1. VPC Peering Chain: Since Lightsail can only peer with the default VPC, you could set up a chain of VPC peering connections. First, peer the Lightsail VPC with the default VPC in its account. Then, set up a cross-account VPC peering between the default VPC in the Lightsail account and your custom VPC in your account. This would create an indirect connection between Lightsail and your custom VPC. However, keep in mind that VPC peering is not transitive, so you'd need to carefully configure routing tables.

  2. Transit Gateway: Instead of using VPC peering, you could set up an AWS Transit Gateway. This service acts as a central hub for routing traffic between multiple VPCs and on-premises networks. You can attach both the Lightsail VPC (via its peering with the default VPC) and your custom VPC to the Transit Gateway, enabling communication between them.

  3. Migrate Lightsail Resources: If feasible, you could consider migrating the resources from Lightsail to EC2 instances within your custom VPC. This would give you more flexibility in networking configurations, albeit at the cost of losing some of Lightsail's simplicity.

  4. API Gateway and VPC Link: For specific use cases, you might be able to use Amazon API Gateway with VPC Link to expose certain services from your VPC to the Lightsail instance without direct network connectivity.

Unfortunately, there isn't a straightforward way to grant shared ownership of a Lightsail instance across accounts or to directly peer a Lightsail VPC with a non-default VPC in another account. The limitations around Lightsail's VPC peering are built into the service's design.

Given your needs for cross-account connectivity, you might want to evaluate if Lightsail is the best fit for your use case in the long term. EC2 instances in a standard VPC might offer more flexibility for your networking requirements, especially when working across multiple accounts within an organization.

Remember to carefully consider security implications and ensure proper IAM permissions are in place when implementing any cross-account solution. If you're still unsure, it might be worth consulting with AWS Support or a cloud architect to design the best solution for your specific needs.
Sources
Community | Connecting Lightsail to AWS Services
VPC peering connections - Amazon Virtual Private Cloud
Connect VPCs using VPC peering - Amazon Virtual Private Cloud
Connect Lightsail resources to AWS services using VPC peering - Amazon Lightsail

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.