AcceptVpcPeeringConnectionCommand

Accept a VPC peering connection request. To accept a request, the VPC peering connection must be in the pending-acceptance state, and you must be the owner of the peer VPC. Use DescribeVpcPeeringConnections to view your outstanding VPC peering connection requests.

For an inter-Region VPC peering connection request, you must accept the VPC peering connection in the Region of the accepter VPC.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { EC2Client, AcceptVpcPeeringConnectionCommand } from "@aws-sdk/client-ec2"; // ES Modules import
// const { EC2Client, AcceptVpcPeeringConnectionCommand } = require("@aws-sdk/client-ec2"); // CommonJS import
const client = new EC2Client(config);
const input = { // AcceptVpcPeeringConnectionRequest
  DryRun: true || false,
  VpcPeeringConnectionId: "STRING_VALUE", // required
};
const command = new AcceptVpcPeeringConnectionCommand(input);
const response = await client.send(command);
// { // AcceptVpcPeeringConnectionResult
//   VpcPeeringConnection: { // VpcPeeringConnection
//     AccepterVpcInfo: { // VpcPeeringConnectionVpcInfo
//       CidrBlock: "STRING_VALUE",
//       Ipv6CidrBlockSet: [ // Ipv6CidrBlockSet
//         { // Ipv6CidrBlock
//           Ipv6CidrBlock: "STRING_VALUE",
//         },
//       ],
//       CidrBlockSet: [ // CidrBlockSet
//         { // CidrBlock
//           CidrBlock: "STRING_VALUE",
//         },
//       ],
//       OwnerId: "STRING_VALUE",
//       PeeringOptions: { // VpcPeeringConnectionOptionsDescription
//         AllowDnsResolutionFromRemoteVpc: true || false,
//         AllowEgressFromLocalClassicLinkToRemoteVpc: true || false,
//         AllowEgressFromLocalVpcToRemoteClassicLink: true || false,
//       },
//       VpcId: "STRING_VALUE",
//       Region: "STRING_VALUE",
//     },
//     ExpirationTime: new Date("TIMESTAMP"),
//     RequesterVpcInfo: {
//       CidrBlock: "STRING_VALUE",
//       Ipv6CidrBlockSet: [
//         {
//           Ipv6CidrBlock: "STRING_VALUE",
//         },
//       ],
//       CidrBlockSet: [
//         {
//           CidrBlock: "STRING_VALUE",
//         },
//       ],
//       OwnerId: "STRING_VALUE",
//       PeeringOptions: {
//         AllowDnsResolutionFromRemoteVpc: true || false,
//         AllowEgressFromLocalClassicLinkToRemoteVpc: true || false,
//         AllowEgressFromLocalVpcToRemoteClassicLink: true || false,
//       },
//       VpcId: "STRING_VALUE",
//       Region: "STRING_VALUE",
//     },
//     Status: { // VpcPeeringConnectionStateReason
//       Code: "initiating-request" || "pending-acceptance" || "active" || "deleted" || "rejected" || "failed" || "expired" || "provisioning" || "deleting",
//       Message: "STRING_VALUE",
//     },
//     Tags: [ // TagList
//       { // Tag
//         Key: "STRING_VALUE",
//         Value: "STRING_VALUE",
//       },
//     ],
//     VpcPeeringConnectionId: "STRING_VALUE",
//   },
// };

AcceptVpcPeeringConnectionCommand Input

Parameter
Type
Description
VpcPeeringConnectionId
Required
string | undefined

The ID of the VPC peering connection. You must specify this parameter in the request.

DryRun
boolean | undefined

Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

AcceptVpcPeeringConnectionCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
VpcPeeringConnection
VpcPeeringConnection | undefined

Information about the VPC peering connection.

Throws

Name
Fault
Details
EC2ServiceException
Base exception class for all service exceptions from EC2 service.