Package com.pulumi.aws.ec2
Class VpcPeeringConnection
- java.lang.Object
-
- com.pulumi.resources.Resource
-
- com.pulumi.resources.CustomResource
-
- com.pulumi.aws.ec2.VpcPeeringConnection
-
public class VpcPeeringConnection extends com.pulumi.resources.CustomResourceProvides a resource to manage a VPC peering connection. > **Note:** Modifying the VPC Peering Connection options requires peering to be active. An automatic activation can be done using the `autoAccept` attribute. Alternatively, the VPC Peering Connection has to be made active manually using other means. See notes below for more information. > **NOTE on VPC Peering Connections and VPC Peering Connection Options:** This provider provides both a standalone VPC Peering Connection Options and a VPC Peering Connection resource with `accepter` and `requester` attributes. Do not manage options for the same VPC peering connection in both a VPC Peering Connection resource and a VPC Peering Connection Options resource. Doing so will cause a conflict of options and will overwrite the options. Using a VPC Peering Connection Options resource decouples management of the connection options from management of the VPC Peering Connection and allows options to be set correctly in cross-account scenarios. > **Note:** For cross-account (requester's AWS account differs from the accepter's AWS account) or inter-region VPC Peering Connections use the `aws.ec2.VpcPeeringConnection` resource to manage the requester's side of the connection and use the `aws.ec2.VpcPeeringConnectionAccepter` resource to manage the accepter's side of the connection. > **Note:** Creating multiple `aws.ec2.VpcPeeringConnection` resources with the same `peerVpcId` and `vpcId` will not produce an error. Instead, AWS will return the connection `id` that already exists, resulting in multiple `aws.ec2.VpcPeeringConnection` resources with the same `id`. ## Example Usage
Basic usage with connection options:package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.ec2.VpcPeeringConnection; import com.pulumi.aws.ec2.VpcPeeringConnectionArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var foo = new VpcPeeringConnection("foo", VpcPeeringConnectionArgs.builder() .peerOwnerId(peerOwnerId) .peerVpcId(bar.id()) .vpcId(fooAwsVpc.id()) .build()); } }
Basic usage with tags:package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.ec2.VpcPeeringConnection; import com.pulumi.aws.ec2.VpcPeeringConnectionArgs; import com.pulumi.aws.ec2.inputs.VpcPeeringConnectionAccepterArgs; import com.pulumi.aws.ec2.inputs.VpcPeeringConnectionRequesterArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var foo = new VpcPeeringConnection("foo", VpcPeeringConnectionArgs.builder() .accepter(VpcPeeringConnectionAccepterArgs.builder() .allowRemoteVpcDnsResolution(true) .build()) .requester(VpcPeeringConnectionRequesterArgs.builder() .allowRemoteVpcDnsResolution(true) .build()) .peerOwnerId(peerOwnerId) .peerVpcId(bar.id()) .vpcId(fooAwsVpc.id()) .build()); } }
Basic usage with region:package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.ec2.Vpc; import com.pulumi.aws.ec2.VpcArgs; import com.pulumi.aws.ec2.VpcPeeringConnection; import com.pulumi.aws.ec2.VpcPeeringConnectionArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var fooVpc = new Vpc("fooVpc", VpcArgs.builder() .cidrBlock("10.1.0.0/16") .build()); var bar = new Vpc("bar", VpcArgs.builder() .cidrBlock("10.2.0.0/16") .build()); var foo = new VpcPeeringConnection("foo", VpcPeeringConnectionArgs.builder() .peerOwnerId(peerOwnerId) .peerVpcId(bar.id()) .vpcId(fooVpc.id()) .autoAccept(true) .tags(Map.of("Name", "VPC Peering between foo and bar")) .build()); } }
## Import Using `pulumi import`, import VPC Peering resources using the VPC peering `id`. For example: ```sh $ pulumi import aws:ec2/vpcPeeringConnection:VpcPeeringConnection test_connection pcx-111aaa111 ```package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.ec2.Vpc; import com.pulumi.aws.ec2.VpcArgs; import com.pulumi.aws.ec2.VpcPeeringConnection; import com.pulumi.aws.ec2.VpcPeeringConnectionArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var fooVpc = new Vpc("fooVpc", VpcArgs.builder() .cidrBlock("10.1.0.0/16") .build()); var bar = new Vpc("bar", VpcArgs.builder() .cidrBlock("10.2.0.0/16") .build()); var foo = new VpcPeeringConnection("foo", VpcPeeringConnectionArgs.builder() .peerOwnerId(peerOwnerId) .peerVpcId(bar.id()) .vpcId(fooVpc.id()) .peerRegion("us-east-1") .build()); } }
-
-
Constructor Summary
Constructors Constructor Description VpcPeeringConnection(java.lang.String name)VpcPeeringConnection(java.lang.String name, VpcPeeringConnectionArgs args)VpcPeeringConnection(java.lang.String name, VpcPeeringConnectionArgs args, com.pulumi.resources.CustomResourceOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.pulumi.core.Output<VpcPeeringConnectionAccepter>accepter()com.pulumi.core.Output<java.lang.String>acceptStatus()com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>>autoAccept()static VpcPeeringConnectionget(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, VpcPeeringConnectionState state, com.pulumi.resources.CustomResourceOptions options)Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.com.pulumi.core.Output<java.lang.String>peerOwnerId()com.pulumi.core.Output<java.lang.String>peerRegion()com.pulumi.core.Output<java.lang.String>peerVpcId()com.pulumi.core.Output<java.lang.String>region()com.pulumi.core.Output<VpcPeeringConnectionRequester>requester()com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>>tags()com.pulumi.core.Output<java.util.Map<java.lang.String,java.lang.String>>tagsAll()com.pulumi.core.Output<java.lang.String>vpcId()
-
-
-
Constructor Detail
-
VpcPeeringConnection
public VpcPeeringConnection(java.lang.String name)
- Parameters:
name- The _unique_ name of the resulting resource.
-
VpcPeeringConnection
public VpcPeeringConnection(java.lang.String name, VpcPeeringConnectionArgs args)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.
-
VpcPeeringConnection
public VpcPeeringConnection(java.lang.String name, VpcPeeringConnectionArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.options- A bag of options that control this resource's behavior.
-
-
Method Detail
-
acceptStatus
public com.pulumi.core.Output<java.lang.String> acceptStatus()
- Returns:
- Status of the VPC Peering Connection request.
-
accepter
public com.pulumi.core.Output<VpcPeeringConnectionAccepter> accepter()
- Returns:
- Configuration block for [VPC Peering Connection](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options to set for the VPC that accepts the peering connection (a maximum of one). See `accepter` Block below.
-
autoAccept
public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> autoAccept()
- Returns:
- Whether to accept the peering (both VPCs need to be in the same AWS account and region).
-
peerOwnerId
public com.pulumi.core.Output<java.lang.String> peerOwnerId()
- Returns:
- AWS account ID of the target peer VPC. Defaults to the account ID the AWS provider is currently connected to, so must be managed if connecting cross-account.
-
peerRegion
public com.pulumi.core.Output<java.lang.String> peerRegion()
- Returns:
- Region of the accepter VPC of the VPC Peering Connection. `autoAccept` must be `false`, and use the `aws.ec2.VpcPeeringConnectionAccepter` to manage the accepter side.
-
peerVpcId
public com.pulumi.core.Output<java.lang.String> peerVpcId()
- Returns:
- ID of the target VPC with which you are creating the VPC Peering Connection.
-
region
public com.pulumi.core.Output<java.lang.String> region()
- Returns:
- Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
-
requester
public com.pulumi.core.Output<VpcPeeringConnectionRequester> requester()
- Returns:
- Configuration block for [VPC Peering Connection](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options to set for the VPC that requests the peering connection (a maximum of one). See `requester` Block below.
-
tags
public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>> tags()
- Returns:
- Map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
-
tagsAll
public com.pulumi.core.Output<java.util.Map<java.lang.String,java.lang.String>> tagsAll()
- Returns:
- Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
-
vpcId
public com.pulumi.core.Output<java.lang.String> vpcId()
- Returns:
- ID of the requester VPC.
-
get
public static VpcPeeringConnection get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, @Nullable VpcPeeringConnectionState state, @Nullable com.pulumi.resources.CustomResourceOptions options)
Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.- Parameters:
name- The _unique_ name of the resulting resource.id- The _unique_ provider ID of the resource to lookup.state-options- Optional settings to control the behavior of the CustomResource.
-
-