Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set the AWS peering connection DNS resolution options through CloudFormation?

I have two VPCs:

  • VPC1 which holds our RDS instance.
  • VPC2 which holds our cluster of EC2 instances.

We have successfully setup a VPC peering connection, routes and security groups to allow appropriate communication.

In order to resolve the RDS instance AZ-appropriate local IP address from it's hostname, we need to follow these instructions and set --requester-peering-connection-options AllowDnsResolutionFromRemoteVpc=true.

If I do this manually through the AWS Console or the AWS CLI it all works fine, however I'm creating the cluster of EC2 instances through CloudFormation and the option is missing from the CloudFormation documentation.

The effect of this is that my stack starts up and fails because the services themselves cannot connect to the database.

Am I doing something obvious wrong, or is this just Amazon being incomplete?

Thanks!

like image 451
Dan Hardiker Avatar asked Jul 17 '17 22:07

Dan Hardiker


People also ask

How do you enable DNS hostname resolution for your VPC connection?

DNS servers resolve DNS hostnames to their corresponding IP addresses. To set up DNS in your VPC, ensure that DNS hostnames and DNS resolution are both enabled in your VPC. The VPC network attributes enableDnsHostnames and enableDnsSupport must be set to true .

Do we need IGW to use peering connections?

An instance will not receive any traffic if destination is not within the VPC. So, peered VPC without IGW will not be able to access internet with Peered VPC because when traffic does arrive into VPC which has IGW, source is outside VPC and destination is not local VPC (outside network).

What are the limitations of VPC peering?

You cannot have more than one VPC peering connection between two VPCs at the same time. Any tags that you create for your VPC peering connection are only applied in the account or Region in which you create them. You cannot connect to or query the Amazon DNS server in a peer VPC.


1 Answers

Due to the frequency of updates, there are many times where an AWS feature isn't available in CloudFormation (ALB targeting Lambda used to be) - you end up having to create a custom resource to manage it. It's not too bad, just make sure that your lambda responds with success or failure in all scenarios, including exceptions, otherwise your stack will be 'in progress' for hours.

like image 68
Dan G Avatar answered Sep 19 '22 17:09

Dan G