Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Virtual Private Cloud/ User Guide (Kuala Lumpur Region)/ VPC Peering Connection/ Creating a VPC Peering Connection with a VPC in Another Account

Creating a VPC Peering Connection with a VPC in Another Account

Updated on 2024-04-11 GMT+08:00

Scenarios

If two VPCs from the same region cannot communicate with each other, you can use a VPC peering connection. This section describes how to create a VPC peering connection between two VPCs in different accounts.

This following describes how to create a VPC peering connection between VPC-A in account A and VPC-B in account B to enable communications between ECS-A01 and RDS-B01.

Procedure:

Step 1: Create a VPC Peering Connection

Step 2: Peer Account Accepts the VPC Peering Connection Request

Step 3: Add Routes for the VPC Peering Connection

Step 4: Verify Network Connectivity

Figure 1 Networking diagram of a VPC peering connection between VPCs in different accounts

Notes and Constraints

  • Only one VPC peering connection can be created between two VPCs at the same time.
  • A VPC peering connection can only connect VPCs in the same region.
  • If the local and peer VPCs have overlapping CIDR blocks, the VPC peering connection may not take effect.
  • For a VPC peering connection between VPCs in different accounts:
    • If account A initiates a request to create a VPC peering connection with a VPC in account B, the VPC peering connection takes effect only after account B accepts the request.
    • To ensure network security, do not accept VPC peering connections from unknown accounts.

Prerequisites

You have two VPCs in the same region, but they are from different accounts. If you want to create one, see Creating a VPC.

Step 1: Create a VPC Peering Connection

  1. Log in to the management console.
  1. Click in the upper left corner and choose Network > Virtual Private Cloud.

    The Virtual Private Cloud page is displayed.

  2. In the navigation pane on the left, choose Virtual Private Cloud > VPC Peering Connections.

    The VPC peering connection list is displayed.

  3. In the upper right corner of the page, click Create VPC Peering Connection.

    The Create VPC Peering Connection dialog box is displayed.

  4. Configure the parameters as prompted.

    For details, see Table 1.

    Table 1 Parameters for creating a VPC peering connection

    Parameter

    Description

    Example Value

    VPC Peering Connection Name

    Mandatory

    Enter a name for the VPC peering connection.

    The name can contain a maximum of 64 characters, including letters, digits, hyphens (-), and underscores (_).

    peering-AB

    Local VPC

    Mandatory

    VPC at one end of the VPC peering connection. You can select one from the drop-down list.

    VPC-A

    Local VPC CIDR Block

    CIDR block of the selected local VPC

    172.16.0.0/16

    Account

    Mandatory

    • Options: My account and Another account
    • Select Another account.

    Another account

    Peer Project ID

    This parameter is mandatory because Account is set to Another account.

    The project ID of the region that the peer VPC resides. For details about how to obtain the project ID, see Obtaining the Peer Project ID of a VPC Peering Connection.

    Project ID of VPC-B in region A:

    067cf8aecf3XXX08322f13b

    Peer VPC ID

    This parameter is mandatory because Account is set to Another account.

    ID of the VPC at the other end of the VPC peering connection. For details about how to obtain the ID, see Obtaining a VPC ID.

    VPC-B ID:

    17cd7278-XXX-530c952dcf35

    Description

    Optional

    Enter the description of the VPC peering connection in the text box as required. The description can contain a maximum of 255 characters and cannot contain angle brackets (< or >).

    peering-AB connects VPC-A and VPC-B.

  5. Click OK.
    • If the message "Invalid VPC ID and project ID." is displayed, check whether the project ID and VPC ID are correct.
      • Peer Project ID: The value must be the project ID of the region where the peer VPC resides.
      • The local and peer VPCs must be in the same region.
    • If the status of the created VPC peering connection is Awaiting acceptance, go to Step 2: Peer Account Accepts the VPC Peering Connection Request.

Step 2: Peer Account Accepts the VPC Peering Connection Request

After you create a VPC peering connection with a VPC in another account, you need to contact the peer account to accept the VPC peering connection request. In this example, account A notifies account B to accept the request. Account B needs to:

  1. Log in to the management console.
  2. Click in the upper left corner and choose Network > Virtual Private Cloud.

    The Virtual Private Cloud page is displayed.

  3. In the navigation pane on the left, choose Virtual Private Cloud > VPC Peering Connections.

    The VPC peering connection list is displayed.

  4. In the upper part of the VPC peering connection list, locate the VPC peering connection request to be accepted.
  5. Locate the row that contains the target VPC peering connection and click Accept Request in the Operation column.

    After the status of the VPC peering connection changes to Accepted, the VPC peering connection is created.

  6. Go to Step 3: Add Routes for the VPC Peering Connection.

Step 3: Add Routes for the VPC Peering Connection

To enable communications between VPCs connected by a VPC peering connection, you need to add forward and return routes to the route tables of the VPCs. For details, see VPC Peering Connection Usage Examples.

Both accounts need to add a route to the route table of their VPC. In this example, account A adds a route to the route table of VPC-A, and account B adds a route to the route table of VPC-B.

  1. Add routes to the route table of the local VPC:
    1. In the VPC peering connection list of the local account, click the name of the target VPC peering connection.

      The Basic Information tab of the VPC peering connection is displayed.

    2. On the Local Routes tab of the VPC peering connection, click the Route Tables hyperlink.

      The Summary tab of the default route table for the local VPC is displayed.

    3. Click Add Route.

      Table 2 describes the route parameters.

      Table 2 Parameter description

      Parameter

      Description

      Example Value

      Destination

      The peer VPC CIDR block, subnet CIDR block, or ECS IP address. For details, see VPC Peering Connection Usage Examples.

      VPC-B CIDR block: 172.17.0.0/16

      Next Hop Type

      The next hop type. Select VPC peering connection.

      VPC peering connection

      Next Hop

      The next hop address. Select the name of the current VPC peering connection.

      peering-AB

      Description

      Supplementary information about the route. This parameter is optional.

      The route description can contain a maximum of 255 characters and cannot contain angle brackets (< or >).

      -

    4. Click OK.

      You can view the route in the route list.

  2. Add routes to the route table of the peer VPC:
    1. In the VPC peering connection list of the peer account, click the name of the target VPC peering connection.

      The Basic Information tab of the VPC peering connection is displayed.

    2. On the Local Routes tab of the VPC peering connection, click the Route Tables hyperlink.

      The Summary tab of the default route table for the peer VPC is displayed.

    3. Click Add Route.

      Table 3 describes the route parameters.

      Table 3 Parameter description

      Parameter

      Description

      Example Value

      Destination

      The local VPC CIDR block, subnet CIDR block, or ECS IP address. For details, see VPC Peering Connection Usage Examples.

      VPC-A CIDR block: 172.16.0.0/16

      Next Hop Type

      The next hop type. Select VPC peering connection.

      VPC peering connection

      Next Hop

      The next hop address. Select the name of the current VPC peering connection.

      peering-AB

      Description

      Supplementary information about the route. This parameter is optional.

      The route description can contain a maximum of 255 characters and cannot contain angle brackets (< or >).

      -

    4. Click OK.

      You can view the route in the route list.

Step 4: Verify Network Connectivity

After you add routes for the VPC peering connection, verify the communication between the local and peer VPCs.
  1. Log in to ECS-A01 in the local VPC.
  2. Check whether ECS-A01 can communicate with RDS-B01.

    ping IP address of RDS-B01

    Example command:

    ping 172.17.0.21

    If information similar to the following is displayed, ECS-A01 and RDS-B01 can communicate with each other, and the VPC peering connection between VPC-A and VPC-B is successfully created.
    [root@ecs-A02 ~]# ping 172.17.0.21
    PING 172.17.0.21 (172.17.0.21) 56(84) bytes of data.
    64 bytes from 172.17.0.21: icmp_seq=1 ttl=64 time=0.849 ms
    64 bytes from 172.17.0.21: icmp_seq=2 ttl=64 time=0.455 ms
    64 bytes from 172.17.0.21: icmp_seq=3 ttl=64 time=0.385 ms
    64 bytes from 172.17.0.21: icmp_seq=4 ttl=64 time=0.372 ms
    ...
    --- 172.17.0.21 ping statistics ---
    NOTICE:

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback