Skip to content
v2.277.0

InterfaceVpcEndpointOptions Struct ​

Options to add an interface endpoint to a VPC.

Example ​

ts
    // Add gateway endpoints when creating the VPC
    const vpc = new ec2.Vpc(this, 'MyVpc', {
      gatewayEndpoints: {
        S3: {
          service: ec2.GatewayVpcEndpointAwsService.S3,
        },
      },
    });

    // Alternatively gateway endpoints can be added on the VPC
    const dynamoDbEndpoint = vpc.addGatewayEndpoint('DynamoDbEndpoint', {
      service: ec2.GatewayVpcEndpointAwsService.DYNAMODB,
    });

    // This allows to customize the endpoint policy
    dynamoDbEndpoint.addToPolicy(
      new iam.PolicyStatement({ // Restrict to listing and describing tables
        principals: [new iam.AnyPrincipal()],
        actions: ['dynamodb:DescribeTable', 'dynamodb:ListTables'],
        resources: ['*'],
      }));

    // Add an interface endpoint
    vpc.addInterfaceEndpoint('EcrDockerEndpoint', {
      service: ec2.InterfaceVpcEndpointAwsService.ECR_DOCKER,

      // Uncomment the following to allow more fine-grained control over
      // who can access the endpoint via the '.connections' object.
      // open: false
    });
python
# Add gateway endpoints when creating the VPC
vpc = ec2.Vpc(self, "MyVpc",
    gateway_endpoints={
        "S3": cdk.aws_ec2.GatewayVpcEndpointOptions(
            service=ec2.GatewayVpcEndpointAwsService.S3
        )
    }
)

# Alternatively gateway endpoints can be added on the VPC
dynamo_db_endpoint = vpc.add_gateway_endpoint("DynamoDbEndpoint",
    service=ec2.GatewayVpcEndpointAwsService.DYNAMODB
)

# This allows to customize the endpoint policy
dynamo_db_endpoint.add_to_policy(
    iam.PolicyStatement( # Restrict to listing and describing tables
        principals=[iam.AnyPrincipal()],
        actions=["dynamodb:DescribeTable", "dynamodb:ListTables"],
        resources=["*"]))

# Add an interface endpoint
vpc.add_interface_endpoint("EcrDockerEndpoint",
    service=ec2.InterfaceVpcEndpointAwsService.ECR_DOCKER
)
java
// Add gateway endpoints when creating the VPC
Vpc vpc = Vpc.Builder.create(this, "MyVpc")
        .gatewayEndpoints(Map.of(
                "S3", GatewayVpcEndpointOptions.builder()
                        .service(GatewayVpcEndpointAwsService.S3)
                        .build()))
        .build();

// Alternatively gateway endpoints can be added on the VPC
GatewayVpcEndpoint dynamoDbEndpoint = vpc.addGatewayEndpoint("DynamoDbEndpoint", GatewayVpcEndpointOptions.builder()
        .service(GatewayVpcEndpointAwsService.DYNAMODB)
        .build());

// This allows to customize the endpoint policy
dynamoDbEndpoint.addToPolicy(
PolicyStatement.Builder.create() // Restrict to listing and describing tables
        .principals(List.of(new AnyPrincipal()))
        .actions(List.of("dynamodb:DescribeTable", "dynamodb:ListTables"))
        .resources(List.of("*")).build());

// Add an interface endpoint
vpc.addInterfaceEndpoint("EcrDockerEndpoint", InterfaceVpcEndpointOptions.builder()
        .service(InterfaceVpcEndpointAwsService.ECR_DOCKER)
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
// Add gateway endpoints when creating the VPC
var vpc = new Vpc(this, "MyVpc", new VpcProps {
    GatewayEndpoints = new Dictionary<string, GatewayVpcEndpointOptions> {
        { "S3", new GatewayVpcEndpointOptions {
            Service = GatewayVpcEndpointAwsService.S3
        } }
    }
});

// Alternatively gateway endpoints can be added on the VPC
var dynamoDbEndpoint = vpc.AddGatewayEndpoint("DynamoDbEndpoint", new GatewayVpcEndpointOptions {
    Service = GatewayVpcEndpointAwsService.DYNAMODB
});

// This allows to customize the endpoint policy
dynamoDbEndpoint.AddToPolicy(
new PolicyStatement(new PolicyStatementProps {  // Restrict to listing and describing tables
    Principals = new [] { new AnyPrincipal() },
    Actions = new [] { "dynamodb:DescribeTable", "dynamodb:ListTables" },
    Resources = new [] { "*" } }));

// Add an interface endpoint
vpc.AddInterfaceEndpoint("EcrDockerEndpoint", new InterfaceVpcEndpointOptions {
    Service = InterfaceVpcEndpointAwsService.ECR_DOCKER
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Add gateway endpoints when creating the VPC
vpc := ec2.NewVpc(this, jsii.String("MyVpc"), &VpcProps{
	GatewayEndpoints: map[string]GatewayVpcEndpointOptions{
		"S3": &GatewayVpcEndpointOptions{
			"service": ec2.GatewayVpcEndpointAwsService_S3(),
		},
	},
})

// Alternatively gateway endpoints can be added on the VPC
dynamoDbEndpoint := vpc.addGatewayEndpoint(jsii.String("DynamoDbEndpoint"), &GatewayVpcEndpointOptions{
	Service: ec2.GatewayVpcEndpointAwsService_DYNAMODB(),
})

// This allows to customize the endpoint policy
dynamoDbEndpoint.AddToPolicy(
iam.NewPolicyStatement(&PolicyStatementProps{
	 // Restrict to listing and describing tables
	Principals: []IPrincipal{
		iam.NewAnyPrincipal(),
	},
	Actions: []*string{
		jsii.String("dynamodb:DescribeTable"),
		jsii.String("dynamodb:ListTables"),
	},
	Resources: []*string{
		jsii.String("*"),
	},
}))

// Add an interface endpoint
vpc.addInterfaceEndpoint(jsii.String("EcrDockerEndpoint"), &InterfaceVpcEndpointOptions{
	Service: ec2.InterfaceVpcEndpointAwsService_ECR_DOCKER(),
})

Properties ​

dnsRecordIpTypeoptionalVpcEndpointDnsRecordIpTypedns_record_ip_typeoptionalVpcEndpointDnsRecordIpTypednsRecordIpTypeoptionalVpcEndpointDnsRecordIpTypeDnsRecordIpTypeoptionalVpcEndpointDnsRecordIpTypeDnsRecordIpTypeoptionalVpcEndpointDnsRecordIpType #
Type of DNS records created for the VPC endpoint.

Default: not specified

ipAddressTypeoptionalVpcEndpointIpAddressTypeip_address_typeoptionalVpcEndpointIpAddressTypeipAddressTypeoptionalVpcEndpointIpAddressTypeIpAddressTypeoptionalVpcEndpointIpAddressTypeIpAddressTypeoptionalVpcEndpointIpAddressType #
The IP address type for the endpoint.

Default: not specified

lookupSupportedAzsoptionalbooleanlookup_supported_azsoptionalboollookupSupportedAzsoptionalBooleanLookupSupportedAzsoptionalboolLookupSupportedAzsoptional*bool = false #
Limit to only those availability zones where the endpoint service can be created.

Setting this to 'true' requires a lookup to be performed at synthesis time. Account and region must be set on the containing stack for this to work.

openoptionalbooleanopenoptionalboolopenoptionalBooleanOpenoptionalboolOpenoptional*bool = true #
Whether to automatically allow VPC traffic to the endpoint.

If enabled, all traffic to the endpoint from within the VPC will be automatically allowed. This is done based on the VPC's CIDR range.

privateDnsEnabledoptionalbooleanprivate_dns_enabledoptionalboolprivateDnsEnabledoptionalBooleanPrivateDnsEnabledoptionalboolPrivateDnsEnabledoptional*bool #
Whether to associate a private hosted zone with the specified VPC.

Default: set by the instance of IInterfaceVpcEndpointService, or true if not defined by the instance of IInterfaceVpcEndpointService

This allows you to make requests to the service using its default DNS hostname.

privateDnsOnlyForInboundResolverEndpointoptionalVpcEndpointPrivateDnsOnlyForInboundResolverEndpointprivate_dns_only_for_inbound_resolver_endpointoptionalVpcEndpointPrivateDnsOnlyForInboundResolverEndpointprivateDnsOnlyForInboundResolverEndpointoptionalVpcEndpointPrivateDnsOnlyForInboundResolverEndpointPrivateDnsOnlyForInboundResolverEndpointoptionalVpcEndpointPrivateDnsOnlyForInboundResolverEndpointPrivateDnsOnlyForInboundResolverEndpointoptionalVpcEndpointPrivateDnsOnlyForInboundResolverEndpoint #
Whether to enable private DNS only for inbound endpoints.

Default: not specified

securityGroupsoptionalISecurityGroup[]security_groupsoptionaltyping.List[ISecurityGroup]securityGroupsoptionalList<ISecurityGroup>SecurityGroupsoptionalISecurityGroup[]SecurityGroupsoptional*[]ISecurityGroup #
The security groups to associate with this interface VPC endpoint.

Default: a new security group is created

The service to use for this interface VPC endpoint.
serviceRegionoptionalstringservice_regionoptionalstrserviceRegionoptionalStringServiceRegionoptionalstringServiceRegionoptional*string #
The region where the VPC endpoint service is located.

Default: Same region as the interface VPC endpoint

Only needs to be specified for cross-region VPC endpoints.

subnetsoptionalSubnetSelectionsubnetsoptionalSubnetSelectionsubnetsoptionalSubnetSelectionSubnetsoptionalSubnetSelectionSubnetsoptionalSubnetSelection #
The subnets in which to create an endpoint network interface.

Default: private subnets

At most one per availability zone.