AwsNetworkPeering

The AWS network peering resource allows you to manage a network peering between an HVN and a peer AWS VPC.

Example Usage

using System.Collections.Generic;
using Pulumi;
using Aws = Pulumi.Aws;
using Hcp = Pulumi.Hcp;

return await Deployment.RunAsync(() => 
{
    var main = new Hcp.Hvn("main", new()
    {
        HvnId = "main-hvn",
        CloudProvider = "aws",
        Region = "us-west-2",
        CidrBlock = "172.25.16.0/20",
    });

    var peerVpc = new Aws.Ec2.Vpc("peerVpc", new()
    {
        CidrBlock = "172.31.0.0/16",
    });

    var peerArn = Aws.GetArn.Invoke(new()
    {
        Arn = peerVpc.Arn,
    });

    var dev = new Hcp.AwsNetworkPeering("dev", new()
    {
        HvnId = main.HvnId,
        PeeringId = "dev",
        PeerVpcId = peerVpc.Id,
        PeerAccountId = peerVpc.OwnerId,
        PeerVpcRegion = peerArn.Apply(getArnResult => getArnResult.Region),
    });

    var main_to_dev = new Hcp.HvnRoute("main-to-dev", new()
    {
        HvnLink = main.SelfLink,
        HvnRouteId = "main-to-dev",
        DestinationCidr = "172.31.0.0/16",
        TargetLink = dev.SelfLink,
    });

    var peerVpcPeeringConnectionAccepter = new Aws.Ec2.VpcPeeringConnectionAccepter("peerVpcPeeringConnectionAccepter", new()
    {
        VpcPeeringConnectionId = dev.ProviderPeeringId,
        AutoAccept = true,
    });

});
package main

import (
	"github.com/grapl-security/pulumi-hcp/sdk/go/hcp"
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws"
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		main, err := hcp.NewHvn(ctx, "main", &hcp.HvnArgs{
			HvnId:         pulumi.String("main-hvn"),
			CloudProvider: pulumi.String("aws"),
			Region:        pulumi.String("us-west-2"),
			CidrBlock:     pulumi.String("172.25.16.0/20"),
		})
		if err != nil {
			return err
		}
		peerVpc, err := ec2.NewVpc(ctx, "peerVpc", &ec2.VpcArgs{
			CidrBlock: pulumi.String("172.31.0.0/16"),
		})
		if err != nil {
			return err
		}
		peerArn := aws.GetArnOutput(ctx, GetArnOutputArgs{
			Arn: peerVpc.Arn,
		}, nil)
		dev, err := hcp.NewAwsNetworkPeering(ctx, "dev", &hcp.AwsNetworkPeeringArgs{
			HvnId:         main.HvnId,
			PeeringId:     pulumi.String("dev"),
			PeerVpcId:     peerVpc.ID(),
			PeerAccountId: peerVpc.OwnerId,
			PeerVpcRegion: peerArn.ApplyT(func(peerArn GetArnResult) (string, error) {
				return peerArn.Region, nil
			}).(pulumi.StringOutput),
		})
		if err != nil {
			return err
		}
		_, err = hcp.NewHvnRoute(ctx, "main-to-dev", &hcp.HvnRouteArgs{
			HvnLink:         main.SelfLink,
			HvnRouteId:      pulumi.String("main-to-dev"),
			DestinationCidr: pulumi.String("172.31.0.0/16"),
			TargetLink:      dev.SelfLink,
		})
		if err != nil {
			return err
		}
		_, err = ec2.NewVpcPeeringConnectionAccepter(ctx, "peerVpcPeeringConnectionAccepter", &ec2.VpcPeeringConnectionAccepterArgs{
			VpcPeeringConnectionId: dev.ProviderPeeringId,
			AutoAccept:             pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.hcp.Hvn;
import com.pulumi.hcp.HvnArgs;
import com.pulumi.aws.ec2.Vpc;
import com.pulumi.aws.ec2.VpcArgs;
import com.pulumi.aws.AwsFunctions;
import com.pulumi.aws.inputs.GetArnArgs;
import com.pulumi.hcp.AwsNetworkPeering;
import com.pulumi.hcp.AwsNetworkPeeringArgs;
import com.pulumi.hcp.HvnRoute;
import com.pulumi.hcp.HvnRouteArgs;
import com.pulumi.aws.ec2.VpcPeeringConnectionAccepter;
import com.pulumi.aws.ec2.VpcPeeringConnectionAccepterArgs;
import java.util.List;
import java.util.ArrayList;
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 main = new Hvn("main", HvnArgs.builder()        
            .hvnId("main-hvn")
            .cloudProvider("aws")
            .region("us-west-2")
            .cidrBlock("172.25.16.0/20")
            .build());

        var peerVpc = new Vpc("peerVpc", VpcArgs.builder()        
            .cidrBlock("172.31.0.0/16")
            .build());

        final var peerArn = AwsFunctions.getArn(GetArnArgs.builder()
            .arn(peerVpc.arn())
            .build());

        var dev = new AwsNetworkPeering("dev", AwsNetworkPeeringArgs.builder()        
            .hvnId(main.hvnId())
            .peeringId("dev")
            .peerVpcId(peerVpc.id())
            .peerAccountId(peerVpc.ownerId())
            .peerVpcRegion(peerArn.applyValue(getArnResult -> getArnResult).applyValue(peerArn -> peerArn.applyValue(getArnResult -> getArnResult.region())))
            .build());

        var main_to_dev = new HvnRoute("main-to-dev", HvnRouteArgs.builder()        
            .hvnLink(main.selfLink())
            .hvnRouteId("main-to-dev")
            .destinationCidr("172.31.0.0/16")
            .targetLink(dev.selfLink())
            .build());

        var peerVpcPeeringConnectionAccepter = new VpcPeeringConnectionAccepter("peerVpcPeeringConnectionAccepter", VpcPeeringConnectionAccepterArgs.builder()        
            .vpcPeeringConnectionId(dev.providerPeeringId())
            .autoAccept(true)
            .build());

    }
}
import pulumi
import pulumi_aws as aws
import pulumi_hcp as hcp

main = hcp.Hvn("main",
    hvn_id="main-hvn",
    cloud_provider="aws",
    region="us-west-2",
    cidr_block="172.25.16.0/20")
peer_vpc = aws.ec2.Vpc("peerVpc", cidr_block="172.31.0.0/16")
peer_arn = aws.get_arn_output(arn=peer_vpc.arn)
dev = hcp.AwsNetworkPeering("dev",
    hvn_id=main.hvn_id,
    peering_id="dev",
    peer_vpc_id=peer_vpc.id,
    peer_account_id=peer_vpc.owner_id,
    peer_vpc_region=peer_arn.region)
main_to_dev = hcp.HvnRoute("main-to-dev",
    hvn_link=main.self_link,
    hvn_route_id="main-to-dev",
    destination_cidr="172.31.0.0/16",
    target_link=dev.self_link)
peer_vpc_peering_connection_accepter = aws.ec2.VpcPeeringConnectionAccepter("peerVpcPeeringConnectionAccepter",
    vpc_peering_connection_id=dev.provider_peering_id,
    auto_accept=True)
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as hcp from "@grapl/pulumi-hcp";

const main = new hcp.Hvn("main", {
    hvnId: "main-hvn",
    cloudProvider: "aws",
    region: "us-west-2",
    cidrBlock: "172.25.16.0/20",
});
const peerVpc = new aws.ec2.Vpc("peerVpc", {cidrBlock: "172.31.0.0/16"});
const peerArn = aws.getArnOutput({
    arn: peerVpc.arn,
});
const dev = new hcp.AwsNetworkPeering("dev", {
    hvnId: main.hvnId,
    peeringId: "dev",
    peerVpcId: peerVpc.id,
    peerAccountId: peerVpc.ownerId,
    peerVpcRegion: peerArn.apply(peerArn => peerArn.region),
});
const main_to_dev = new hcp.HvnRoute("main-to-dev", {
    hvnLink: main.selfLink,
    hvnRouteId: "main-to-dev",
    destinationCidr: "172.31.0.0/16",
    targetLink: dev.selfLink,
});
const peerVpcPeeringConnectionAccepter = new aws.ec2.VpcPeeringConnectionAccepter("peerVpcPeeringConnectionAccepter", {
    vpcPeeringConnectionId: dev.providerPeeringId,
    autoAccept: true,
});
resources:
  main:
    type: hcp:Hvn
    properties:
      hvnId: main-hvn
      cloudProvider: aws
      region: us-west-2
      cidrBlock: 172.25.16.0/20
  peerVpc:
    type: aws:ec2:Vpc
    properties:
      cidrBlock: 172.31.0.0/16
  dev:
    type: hcp:AwsNetworkPeering
    properties:
      hvnId: ${main.hvnId}
      peeringId: dev
      peerVpcId: ${peerVpc.id}
      peerAccountId: ${peerVpc.ownerId}
      peerVpcRegion: ${peerArn.region}
  main-to-dev:
    type: hcp:HvnRoute
    properties:
      hvnLink: ${main.selfLink}
      hvnRouteId: main-to-dev
      destinationCidr: 172.31.0.0/16
      targetLink: ${dev.selfLink}
  peerVpcPeeringConnectionAccepter:
    type: aws:ec2:VpcPeeringConnectionAccepter
    properties:
      vpcPeeringConnectionId: ${dev.providerPeeringId}
      autoAccept: true
variables:
  peerArn:
    Fn::Invoke:
      Function: aws:getArn
      Arguments:
        arn: ${peerVpc.arn}

Create AwsNetworkPeering Resource

new AwsNetworkPeering(name: string, args: AwsNetworkPeeringArgs, opts?: CustomResourceOptions);
@overload
def AwsNetworkPeering(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      hvn_id: Optional[str] = None,
                      peer_account_id: Optional[str] = None,
                      peer_vpc_id: Optional[str] = None,
                      peer_vpc_region: Optional[str] = None,
                      peering_id: Optional[str] = None)
@overload
def AwsNetworkPeering(resource_name: str,
                      args: AwsNetworkPeeringArgs,
                      opts: Optional[ResourceOptions] = None)
func NewAwsNetworkPeering(ctx *Context, name string, args AwsNetworkPeeringArgs, opts ...ResourceOption) (*AwsNetworkPeering, error)
public AwsNetworkPeering(string name, AwsNetworkPeeringArgs args, CustomResourceOptions? opts = null)
public AwsNetworkPeering(String name, AwsNetworkPeeringArgs args)
public AwsNetworkPeering(String name, AwsNetworkPeeringArgs args, CustomResourceOptions options)
type: hcp:AwsNetworkPeering
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args AwsNetworkPeeringArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args AwsNetworkPeeringArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args AwsNetworkPeeringArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args AwsNetworkPeeringArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args AwsNetworkPeeringArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

AwsNetworkPeering Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The AwsNetworkPeering resource accepts the following input properties:

HvnId string

The ID of the HashiCorp Virtual Network (HVN).

PeerAccountId string

The account ID of the peer VPC in AWS.

PeerVpcId string

The ID of the peer VPC in AWS.

PeerVpcRegion string

The region of the peer VPC in AWS.

PeeringId string

The ID of the network peering.

HvnId string

The ID of the HashiCorp Virtual Network (HVN).

PeerAccountId string

The account ID of the peer VPC in AWS.

PeerVpcId string

The ID of the peer VPC in AWS.

PeerVpcRegion string

The region of the peer VPC in AWS.

PeeringId string

The ID of the network peering.

hvnId String

The ID of the HashiCorp Virtual Network (HVN).

peerAccountId String

The account ID of the peer VPC in AWS.

peerVpcId String

The ID of the peer VPC in AWS.

peerVpcRegion String

The region of the peer VPC in AWS.

peeringId String

The ID of the network peering.

hvnId string

The ID of the HashiCorp Virtual Network (HVN).

peerAccountId string

The account ID of the peer VPC in AWS.

peerVpcId string

The ID of the peer VPC in AWS.

peerVpcRegion string

The region of the peer VPC in AWS.

peeringId string

The ID of the network peering.

hvn_id str

The ID of the HashiCorp Virtual Network (HVN).

peer_account_id str

The account ID of the peer VPC in AWS.

peer_vpc_id str

The ID of the peer VPC in AWS.

peer_vpc_region str

The region of the peer VPC in AWS.

peering_id str

The ID of the network peering.

hvnId String

The ID of the HashiCorp Virtual Network (HVN).

peerAccountId String

The account ID of the peer VPC in AWS.

peerVpcId String

The ID of the peer VPC in AWS.

peerVpcRegion String

The region of the peer VPC in AWS.

peeringId String

The ID of the network peering.

Outputs

All input properties are implicitly available as output properties. Additionally, the AwsNetworkPeering resource produces the following output properties:

CreatedAt string

The time that the network peering was created.

ExpiresAt string

The time after which the network peering will be considered expired if it hasn't transitioned into ACCEPTED or ACTIVE state.

Id string

The provider-assigned unique ID for this managed resource.

OrganizationId string

The ID of the HCP organization where the network peering is located. Always matches the HVN's organization.

ProjectId string

The ID of the HCP project where the network peering is located. Always matches the HVN's project.

ProviderPeeringId string

The peering connection ID used by AWS.

SelfLink string

A unique URL identifying the network peering.

State string

The state of the network peering.

CreatedAt string

The time that the network peering was created.

ExpiresAt string

The time after which the network peering will be considered expired if it hasn't transitioned into ACCEPTED or ACTIVE state.

Id string

The provider-assigned unique ID for this managed resource.

OrganizationId string

The ID of the HCP organization where the network peering is located. Always matches the HVN's organization.

ProjectId string

The ID of the HCP project where the network peering is located. Always matches the HVN's project.

ProviderPeeringId string

The peering connection ID used by AWS.

SelfLink string

A unique URL identifying the network peering.

State string

The state of the network peering.

createdAt String

The time that the network peering was created.

expiresAt String

The time after which the network peering will be considered expired if it hasn't transitioned into ACCEPTED or ACTIVE state.

id String

The provider-assigned unique ID for this managed resource.

organizationId String

The ID of the HCP organization where the network peering is located. Always matches the HVN's organization.

projectId String

The ID of the HCP project where the network peering is located. Always matches the HVN's project.

providerPeeringId String

The peering connection ID used by AWS.

selfLink String

A unique URL identifying the network peering.

state String

The state of the network peering.

createdAt string

The time that the network peering was created.

expiresAt string

The time after which the network peering will be considered expired if it hasn't transitioned into ACCEPTED or ACTIVE state.

id string

The provider-assigned unique ID for this managed resource.

organizationId string

The ID of the HCP organization where the network peering is located. Always matches the HVN's organization.

projectId string

The ID of the HCP project where the network peering is located. Always matches the HVN's project.

providerPeeringId string

The peering connection ID used by AWS.

selfLink string

A unique URL identifying the network peering.

state string

The state of the network peering.

created_at str

The time that the network peering was created.

expires_at str

The time after which the network peering will be considered expired if it hasn't transitioned into ACCEPTED or ACTIVE state.

id str

The provider-assigned unique ID for this managed resource.

organization_id str

The ID of the HCP organization where the network peering is located. Always matches the HVN's organization.

project_id str

The ID of the HCP project where the network peering is located. Always matches the HVN's project.

provider_peering_id str

The peering connection ID used by AWS.

self_link str

A unique URL identifying the network peering.

state str

The state of the network peering.

createdAt String

The time that the network peering was created.

expiresAt String

The time after which the network peering will be considered expired if it hasn't transitioned into ACCEPTED or ACTIVE state.

id String

The provider-assigned unique ID for this managed resource.

organizationId String

The ID of the HCP organization where the network peering is located. Always matches the HVN's organization.

projectId String

The ID of the HCP project where the network peering is located. Always matches the HVN's project.

providerPeeringId String

The peering connection ID used by AWS.

selfLink String

A unique URL identifying the network peering.

state String

The state of the network peering.

Look up Existing AwsNetworkPeering Resource

Get an existing AwsNetworkPeering resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: AwsNetworkPeeringState, opts?: CustomResourceOptions): AwsNetworkPeering
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        created_at: Optional[str] = None,
        expires_at: Optional[str] = None,
        hvn_id: Optional[str] = None,
        organization_id: Optional[str] = None,
        peer_account_id: Optional[str] = None,
        peer_vpc_id: Optional[str] = None,
        peer_vpc_region: Optional[str] = None,
        peering_id: Optional[str] = None,
        project_id: Optional[str] = None,
        provider_peering_id: Optional[str] = None,
        self_link: Optional[str] = None,
        state: Optional[str] = None) -> AwsNetworkPeering
func GetAwsNetworkPeering(ctx *Context, name string, id IDInput, state *AwsNetworkPeeringState, opts ...ResourceOption) (*AwsNetworkPeering, error)
public static AwsNetworkPeering Get(string name, Input<string> id, AwsNetworkPeeringState? state, CustomResourceOptions? opts = null)
public static AwsNetworkPeering get(String name, Output<String> id, AwsNetworkPeeringState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
CreatedAt string

The time that the network peering was created.

ExpiresAt string

The time after which the network peering will be considered expired if it hasn't transitioned into ACCEPTED or ACTIVE state.

HvnId string

The ID of the HashiCorp Virtual Network (HVN).

OrganizationId string

The ID of the HCP organization where the network peering is located. Always matches the HVN's organization.

PeerAccountId string

The account ID of the peer VPC in AWS.

PeerVpcId string

The ID of the peer VPC in AWS.

PeerVpcRegion string

The region of the peer VPC in AWS.

PeeringId string

The ID of the network peering.

ProjectId string

The ID of the HCP project where the network peering is located. Always matches the HVN's project.

ProviderPeeringId string

The peering connection ID used by AWS.

SelfLink string

A unique URL identifying the network peering.

State string

The state of the network peering.

CreatedAt string

The time that the network peering was created.

ExpiresAt string

The time after which the network peering will be considered expired if it hasn't transitioned into ACCEPTED or ACTIVE state.

HvnId string

The ID of the HashiCorp Virtual Network (HVN).

OrganizationId string

The ID of the HCP organization where the network peering is located. Always matches the HVN's organization.

PeerAccountId string

The account ID of the peer VPC in AWS.

PeerVpcId string

The ID of the peer VPC in AWS.

PeerVpcRegion string

The region of the peer VPC in AWS.

PeeringId string

The ID of the network peering.

ProjectId string

The ID of the HCP project where the network peering is located. Always matches the HVN's project.

ProviderPeeringId string

The peering connection ID used by AWS.

SelfLink string

A unique URL identifying the network peering.

State string

The state of the network peering.

createdAt String

The time that the network peering was created.

expiresAt String

The time after which the network peering will be considered expired if it hasn't transitioned into ACCEPTED or ACTIVE state.

hvnId String

The ID of the HashiCorp Virtual Network (HVN).

organizationId String

The ID of the HCP organization where the network peering is located. Always matches the HVN's organization.

peerAccountId String

The account ID of the peer VPC in AWS.

peerVpcId String

The ID of the peer VPC in AWS.

peerVpcRegion String

The region of the peer VPC in AWS.

peeringId String

The ID of the network peering.

projectId String

The ID of the HCP project where the network peering is located. Always matches the HVN's project.

providerPeeringId String

The peering connection ID used by AWS.

selfLink String

A unique URL identifying the network peering.

state String

The state of the network peering.

createdAt string

The time that the network peering was created.

expiresAt string

The time after which the network peering will be considered expired if it hasn't transitioned into ACCEPTED or ACTIVE state.

hvnId string

The ID of the HashiCorp Virtual Network (HVN).

organizationId string

The ID of the HCP organization where the network peering is located. Always matches the HVN's organization.

peerAccountId string

The account ID of the peer VPC in AWS.

peerVpcId string

The ID of the peer VPC in AWS.

peerVpcRegion string

The region of the peer VPC in AWS.

peeringId string

The ID of the network peering.

projectId string

The ID of the HCP project where the network peering is located. Always matches the HVN's project.

providerPeeringId string

The peering connection ID used by AWS.

selfLink string

A unique URL identifying the network peering.

state string

The state of the network peering.

created_at str

The time that the network peering was created.

expires_at str

The time after which the network peering will be considered expired if it hasn't transitioned into ACCEPTED or ACTIVE state.

hvn_id str

The ID of the HashiCorp Virtual Network (HVN).

organization_id str

The ID of the HCP organization where the network peering is located. Always matches the HVN's organization.

peer_account_id str

The account ID of the peer VPC in AWS.

peer_vpc_id str

The ID of the peer VPC in AWS.

peer_vpc_region str

The region of the peer VPC in AWS.

peering_id str

The ID of the network peering.

project_id str

The ID of the HCP project where the network peering is located. Always matches the HVN's project.

provider_peering_id str

The peering connection ID used by AWS.

self_link str

A unique URL identifying the network peering.

state str

The state of the network peering.

createdAt String

The time that the network peering was created.

expiresAt String

The time after which the network peering will be considered expired if it hasn't transitioned into ACCEPTED or ACTIVE state.

hvnId String

The ID of the HashiCorp Virtual Network (HVN).

organizationId String

The ID of the HCP organization where the network peering is located. Always matches the HVN's organization.

peerAccountId String

The account ID of the peer VPC in AWS.

peerVpcId String

The ID of the peer VPC in AWS.

peerVpcRegion String

The region of the peer VPC in AWS.

peeringId String

The ID of the network peering.

projectId String

The ID of the HCP project where the network peering is located. Always matches the HVN's project.

providerPeeringId String

The peering connection ID used by AWS.

selfLink String

A unique URL identifying the network peering.

state String

The state of the network peering.

Import

The import ID is {hvn_id}:{peering_id}

 $ pulumi import hcp:index/awsNetworkPeering:AwsNetworkPeering peer main-hvn:11eb60b3-d4ec-5eed-aacc-0242ac120015

Package Details

Repository
https://github.com/grapl-security/pulumi-hcp
License
Apache-2.0
Notes

This Pulumi package is based on the hcp Terraform Provider.