Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

AWS Cross-Region VPC Peering Cloudformation doesn't recognise the VPC in the other region

I have been working on creating a VPC Peering Connection that can peer from eu-west-1 to us-east-1 with the use of a cloudformation. This is the cloudformation as of right now:

AWSTemplateFormatVersion: 2010-09-09
Description: This templates creates a VPC Peering connection. (Requester Account)

Parameters:
  PeerName:
    Description: Name of the VPC Peer
    MaxLength: 255
    Type: String
  PeerVPCID:
    AllowedPattern: '^vpc-[0-9a-f]{17}$'
    ConstraintDescription: Must have a prefix of "vpc-". Followed by 17 characters (numbers, letters "a-f")
    Description: ID of the VPC with which you are creating the VPC peering connection
    Type: AWS::EC2::VPC::Id
  VPCID:
    Description: ID of the VPC
    Type: AWS::EC2::VPC::Id
  PeerRegion:
    Description: Region of the VPC Accepter (not required)
    Type: String

Resources:
  VPCPeeringConnection:
    Type: AWS::EC2::VPCPeeringConnection
    Properties:
      VpcId: !Ref VPCID
      PeerVpcId: !Ref PeerVPCID
      PeerOwnerId: !Ref "AWS::AccountId"
      PeerRegion: !Ref PeerRegion
      Tags:
        - Key: Name
          Value: !Ref PeerName

Outputs:
  VPCPeeringConnectionId:
    Description: VPC Peering Connection ID
    Value: !Ref VPCPeeringConnection

These are the values for the parameters:

PeerName: Connector
PeerVPCID: vpc-1234567
VPCID: vpc-7654321
PeerRegion: us-east-1

I understand that I need an accepter that approves the connection in us-east-1, but the current cloudformation outputs that it doesn’t recognise the VPCID to be valid (the one that is in the other region to the AWS account I’m using).

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

When, I create the VPC Peering Connection in the GUI it throws no errors, I just have to accept the connection and update the route tables, which all work fine… is there something I should be doing with the current cloudformation?

Thanks for any help!

>Solution :

To solve that change:

 Type: AWS::EC2::VPC::Id

into

 Type: String

for the remote VPC, i.e. the VPC from a region other then where you deploy your stack.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading