1. Packages
  2. AWS
  3. API Docs
  4. ec2
  5. VpcEndpointSubnetAssociation
AWS v6.77.0 published on Wednesday, Apr 9, 2025 by Pulumi

aws.ec2.VpcEndpointSubnetAssociation

Explore with Pulumi AI

Provides a resource to create an association between a VPC endpoint and a subnet.

NOTE on VPC Endpoints and VPC Endpoint Subnet Associations: This provider provides both a standalone VPC Endpoint Subnet Association (an association between a VPC endpoint and a single subnet_id) and a VPC Endpoint resource with a subnet_ids attribute. Do not use the same subnet ID in both a VPC Endpoint resource and a VPC Endpoint Subnet Association resource. Doing so will cause a conflict of associations and will overwrite the association.

Example Usage

Basic usage:

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const snEc2 = new aws.ec2.VpcEndpointSubnetAssociation("sn_ec2", {
    vpcEndpointId: ec2.id,
    subnetId: sn.id,
});
Copy
import pulumi
import pulumi_aws as aws

sn_ec2 = aws.ec2.VpcEndpointSubnetAssociation("sn_ec2",
    vpc_endpoint_id=ec2["id"],
    subnet_id=sn["id"])
Copy
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ec2.NewVpcEndpointSubnetAssociation(ctx, "sn_ec2", &ec2.VpcEndpointSubnetAssociationArgs{
			VpcEndpointId: pulumi.Any(ec2.Id),
			SubnetId:      pulumi.Any(sn.Id),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var snEc2 = new Aws.Ec2.VpcEndpointSubnetAssociation("sn_ec2", new()
    {
        VpcEndpointId = ec2.Id,
        SubnetId = sn.Id,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.VpcEndpointSubnetAssociation;
import com.pulumi.aws.ec2.VpcEndpointSubnetAssociationArgs;
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 snEc2 = new VpcEndpointSubnetAssociation("snEc2", VpcEndpointSubnetAssociationArgs.builder()
            .vpcEndpointId(ec2.id())
            .subnetId(sn.id())
            .build());

    }
}
Copy
resources:
  snEc2:
    type: aws:ec2:VpcEndpointSubnetAssociation
    name: sn_ec2
    properties:
      vpcEndpointId: ${ec2.id}
      subnetId: ${sn.id}
Copy

Create VpcEndpointSubnetAssociation Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new VpcEndpointSubnetAssociation(name: string, args: VpcEndpointSubnetAssociationArgs, opts?: CustomResourceOptions);
@overload
def VpcEndpointSubnetAssociation(resource_name: str,
                                 args: VpcEndpointSubnetAssociationArgs,
                                 opts: Optional[ResourceOptions] = None)

@overload
def VpcEndpointSubnetAssociation(resource_name: str,
                                 opts: Optional[ResourceOptions] = None,
                                 subnet_id: Optional[str] = None,
                                 vpc_endpoint_id: Optional[str] = None)
func NewVpcEndpointSubnetAssociation(ctx *Context, name string, args VpcEndpointSubnetAssociationArgs, opts ...ResourceOption) (*VpcEndpointSubnetAssociation, error)
public VpcEndpointSubnetAssociation(string name, VpcEndpointSubnetAssociationArgs args, CustomResourceOptions? opts = null)
public VpcEndpointSubnetAssociation(String name, VpcEndpointSubnetAssociationArgs args)
public VpcEndpointSubnetAssociation(String name, VpcEndpointSubnetAssociationArgs args, CustomResourceOptions options)
type: aws:ec2:VpcEndpointSubnetAssociation
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

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

Constructor example

The following reference example uses placeholder values for all input properties.

var vpcEndpointSubnetAssociationResource = new Aws.Ec2.VpcEndpointSubnetAssociation("vpcEndpointSubnetAssociationResource", new()
{
    SubnetId = "string",
    VpcEndpointId = "string",
});
Copy
example, err := ec2.NewVpcEndpointSubnetAssociation(ctx, "vpcEndpointSubnetAssociationResource", &ec2.VpcEndpointSubnetAssociationArgs{
	SubnetId:      pulumi.String("string"),
	VpcEndpointId: pulumi.String("string"),
})
Copy
var vpcEndpointSubnetAssociationResource = new VpcEndpointSubnetAssociation("vpcEndpointSubnetAssociationResource", VpcEndpointSubnetAssociationArgs.builder()
    .subnetId("string")
    .vpcEndpointId("string")
    .build());
Copy
vpc_endpoint_subnet_association_resource = aws.ec2.VpcEndpointSubnetAssociation("vpcEndpointSubnetAssociationResource",
    subnet_id="string",
    vpc_endpoint_id="string")
Copy
const vpcEndpointSubnetAssociationResource = new aws.ec2.VpcEndpointSubnetAssociation("vpcEndpointSubnetAssociationResource", {
    subnetId: "string",
    vpcEndpointId: "string",
});
Copy
type: aws:ec2:VpcEndpointSubnetAssociation
properties:
    subnetId: string
    vpcEndpointId: string
Copy

VpcEndpointSubnetAssociation Resource Properties

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

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The VpcEndpointSubnetAssociation resource accepts the following input properties:

SubnetId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the subnet to be associated with the VPC endpoint.
VpcEndpointId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the VPC endpoint with which the subnet will be associated.
SubnetId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the subnet to be associated with the VPC endpoint.
VpcEndpointId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the VPC endpoint with which the subnet will be associated.
subnetId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the subnet to be associated with the VPC endpoint.
vpcEndpointId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the VPC endpoint with which the subnet will be associated.
subnetId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the subnet to be associated with the VPC endpoint.
vpcEndpointId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the VPC endpoint with which the subnet will be associated.
subnet_id
This property is required.
Changes to this property will trigger replacement.
str
The ID of the subnet to be associated with the VPC endpoint.
vpc_endpoint_id
This property is required.
Changes to this property will trigger replacement.
str
The ID of the VPC endpoint with which the subnet will be associated.
subnetId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the subnet to be associated with the VPC endpoint.
vpcEndpointId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the VPC endpoint with which the subnet will be associated.

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing VpcEndpointSubnetAssociation Resource

Get an existing VpcEndpointSubnetAssociation 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?: VpcEndpointSubnetAssociationState, opts?: CustomResourceOptions): VpcEndpointSubnetAssociation
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        subnet_id: Optional[str] = None,
        vpc_endpoint_id: Optional[str] = None) -> VpcEndpointSubnetAssociation
func GetVpcEndpointSubnetAssociation(ctx *Context, name string, id IDInput, state *VpcEndpointSubnetAssociationState, opts ...ResourceOption) (*VpcEndpointSubnetAssociation, error)
public static VpcEndpointSubnetAssociation Get(string name, Input<string> id, VpcEndpointSubnetAssociationState? state, CustomResourceOptions? opts = null)
public static VpcEndpointSubnetAssociation get(String name, Output<String> id, VpcEndpointSubnetAssociationState state, CustomResourceOptions options)
resources:  _:    type: aws:ec2:VpcEndpointSubnetAssociation    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
SubnetId Changes to this property will trigger replacement. string
The ID of the subnet to be associated with the VPC endpoint.
VpcEndpointId Changes to this property will trigger replacement. string
The ID of the VPC endpoint with which the subnet will be associated.
SubnetId Changes to this property will trigger replacement. string
The ID of the subnet to be associated with the VPC endpoint.
VpcEndpointId Changes to this property will trigger replacement. string
The ID of the VPC endpoint with which the subnet will be associated.
subnetId Changes to this property will trigger replacement. String
The ID of the subnet to be associated with the VPC endpoint.
vpcEndpointId Changes to this property will trigger replacement. String
The ID of the VPC endpoint with which the subnet will be associated.
subnetId Changes to this property will trigger replacement. string
The ID of the subnet to be associated with the VPC endpoint.
vpcEndpointId Changes to this property will trigger replacement. string
The ID of the VPC endpoint with which the subnet will be associated.
subnet_id Changes to this property will trigger replacement. str
The ID of the subnet to be associated with the VPC endpoint.
vpc_endpoint_id Changes to this property will trigger replacement. str
The ID of the VPC endpoint with which the subnet will be associated.
subnetId Changes to this property will trigger replacement. String
The ID of the subnet to be associated with the VPC endpoint.
vpcEndpointId Changes to this property will trigger replacement. String
The ID of the VPC endpoint with which the subnet will be associated.

Import

Using pulumi import, import VPC Endpoint Subnet Associations using vpc_endpoint_id together with subnet_id. For example:

$ pulumi import aws:ec2/vpcEndpointSubnetAssociation:VpcEndpointSubnetAssociation example vpce-aaaaaaaa/subnet-bbbbbbbbbbbbbbbbb
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.