> **Experimental**
>
> `@aws-cdk/aws-ec2-alpha` is an [**experimental**](https://docs.aws.amazon.com/cdk/api/stability.html) (alpha) package: its API may change in any release, without a major version bump.
# VPCPeeringConnectionOptions

Options to define a VPC peering connection.

- Stability: [Experimental](https://docs.aws.amazon.com/cdk/api/stability.html)
- Source: [`lib/route.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/@aws-cdk/aws-ec2-alpha/lib/route.ts#L187)

## Example

TypeScript:

```ts
const stack = new Stack();

const acceptorVpc = new VpcV2(this, 'VpcA', {
  primaryAddressBlock: IpAddresses.ipv4('10.0.0.0/16'),
});

const requestorVpc = new VpcV2(this, 'VpcB', {
  primaryAddressBlock: IpAddresses.ipv4('10.1.0.0/16'),
});

const peeringConnection = requestorVpc.createPeeringConnection('peeringConnection', {
  acceptorVpc: acceptorVpc,
});

const routeTable = new RouteTable(this, 'RouteTable', {
  vpc: requestorVpc,
});

routeTable.addRoute('vpcPeeringRoute', '10.0.0.0/16', { gateway: peeringConnection });
```

Python:

```python
stack = Stack()

acceptor_vpc = VpcV2(self, "VpcA",
    primary_address_block=IpAddresses.ipv4("10.0.0.0/16")
)

requestor_vpc = VpcV2(self, "VpcB",
    primary_address_block=IpAddresses.ipv4("10.1.0.0/16")
)

peering_connection = requestor_vpc.create_peering_connection("peeringConnection",
    acceptor_vpc=acceptor_vpc
)

route_table = RouteTable(self, "RouteTable",
    vpc=requestor_vpc
)

route_table.add_route("vpcPeeringRoute", "10.0.0.0/16", {"gateway": peering_connection})
```

Java:

```java
Stack stack = new Stack();

VpcV2 acceptorVpc = VpcV2.Builder.create(this, "VpcA")
        .primaryAddressBlock(IpAddresses.ipv4("10.0.0.0/16"))
        .build();

VpcV2 requestorVpc = VpcV2.Builder.create(this, "VpcB")
        .primaryAddressBlock(IpAddresses.ipv4("10.1.0.0/16"))
        .build();

VPCPeeringConnection peeringConnection = requestorVpc.createPeeringConnection("peeringConnection", VPCPeeringConnectionOptions.builder()
        .acceptorVpc(acceptorVpc)
        .build());

RouteTable routeTable = RouteTable.Builder.create(this, "RouteTable")
        .vpc(requestorVpc)
        .build();

routeTable.addRoute("vpcPeeringRoute", "10.0.0.0/16", Map.of("gateway", peeringConnection));
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.ec2.Alpha
var stack = new Stack();

var acceptorVpc = new VpcV2(this, "VpcA", new VpcV2Props {
    PrimaryAddressBlock = IpAddresses.Ipv4("10.0.0.0/16")
});

var requestorVpc = new VpcV2(this, "VpcB", new VpcV2Props {
    PrimaryAddressBlock = IpAddresses.Ipv4("10.1.0.0/16")
});

var peeringConnection = requestorVpc.CreatePeeringConnection("peeringConnection", new VPCPeeringConnectionOptions {
    AcceptorVpc = acceptorVpc
});

var routeTable = new RouteTable(this, "RouteTable", new RouteTableProps {
    Vpc = requestorVpc
});

routeTable.AddRoute("vpcPeeringRoute", "10.0.0.0/16", new Dictionary<string, IRouteTarget?> { { "gateway", peeringConnection } });
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awsec2alpha/v2
stack := awscdk.Newstack()

acceptorVpc := awsec2alpha.NewVpcV2(this, jsii.String("VpcA"), &VpcV2Props{
	PrimaryAddressBlock: awsec2alpha.IpAddresses_Ipv4(jsii.String("10.0.0.0/16")),
})

requestorVpc := awsec2alpha.NewVpcV2(this, jsii.String("VpcB"), &VpcV2Props{
	PrimaryAddressBlock: awsec2alpha.IpAddresses_*Ipv4(jsii.String("10.1.0.0/16")),
})

peeringConnection := requestorVpc.CreatePeeringConnection(jsii.String("peeringConnection"), &VPCPeeringConnectionOptions{
	AcceptorVpc: acceptorVpc,
})

routeTable := awsec2alpha.NewRouteTable(this, jsii.String("RouteTable"), &RouteTableProps{
	Vpc: requestorVpc,
})

routeTable.AddRoute(jsii.String("vpcPeeringRoute"), jsii.String("10.0.0.0/16"), map[string]iRouteTarget{
	"gateway": peeringConnection,
})
```

## Properties

- `acceptorVpc`: [IVpcV2](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-ec2-alpha.IVpcV2.html) (required) — The VPC that is accepting the peering connection.

- `peerRoleArn`: string — The role arn created in the acceptor account.

  **Default:** no peerRoleArn needed if not cross account connection

- `vpcPeeringConnectionName`: string — The resource name of the peering connection.

  **Default:** peering connection provisioned without any name
