Class VpcEndpoint


  • public class VpcEndpoint
    extends com.pulumi.resources.CustomResource
    Provides a VPC Endpoint resource. > **NOTE on VPC Endpoints and VPC Endpoint Associations:** The provider provides both standalone VPC Endpoint Associations for Route Tables - (an association between a VPC endpoint and a single `routeTableId`), Security Groups - (an association between a VPC endpoint and a single `securityGroupId`), and Subnets - (an association between a VPC endpoint and a single `subnetId`) and a VPC Endpoint resource with `routeTableIds` and `subnetIds` attributes. Do not use the same resource ID in both a VPC Endpoint resource and a VPC Endpoint Association resource. Doing so will cause a conflict of associations and will overwrite the association. ## Example Usage ### Basic
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.ec2.VpcEndpoint;
     import com.pulumi.aws.ec2.VpcEndpointArgs;
     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 s3 = new VpcEndpoint("s3", VpcEndpointArgs.builder()
                 .vpcId(main.id())
                 .serviceName("com.amazonaws.us-west-2.s3")
                 .build());
     
         }
     }
     
     
    ### Basic w/ Tags
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.ec2.VpcEndpoint;
     import com.pulumi.aws.ec2.VpcEndpointArgs;
     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 s3 = new VpcEndpoint("s3", VpcEndpointArgs.builder()
                 .vpcId(main.id())
                 .serviceName("com.amazonaws.us-west-2.s3")
                 .tags(Map.of("Environment", "test"))
                 .build());
     
         }
     }
     
     
    ### Cross-region enabled AWS services
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.ec2.VpcEndpoint;
     import com.pulumi.aws.ec2.VpcEndpointArgs;
     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 s3 = new VpcEndpoint("s3", VpcEndpointArgs.builder()
                 .region("us-west-2")
                 .vpcId(main.id())
                 .serviceName("com.amazonaws.us-east-2.s3")
                 .serviceRegion("us-east-2")
                 .tags(Map.of("Environment", "test"))
                 .build());
     
         }
     }
     
     
    ### Interface Endpoint Type
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.ec2.VpcEndpoint;
     import com.pulumi.aws.ec2.VpcEndpointArgs;
     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 ec2 = new VpcEndpoint("ec2", VpcEndpointArgs.builder()
                 .vpcId(main.id())
                 .serviceName("com.amazonaws.us-west-2.ec2")
                 .vpcEndpointType("Interface")
                 .securityGroupIds(sg1.id())
                 .privateDnsEnabled(true)
                 .build());
     
         }
     }
     
     
    ### Interface Endpoint Type with User-Defined IP Address
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.ec2.VpcEndpoint;
     import com.pulumi.aws.ec2.VpcEndpointArgs;
     import com.pulumi.aws.ec2.inputs.VpcEndpointSubnetConfigurationArgs;
     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 ec2 = new VpcEndpoint("ec2", VpcEndpointArgs.builder()
                 .subnetConfigurations(            
                     VpcEndpointSubnetConfigurationArgs.builder()
                         .ipv4("10.0.1.10")
                         .subnetId(example1.id())
                         .build(),
                     VpcEndpointSubnetConfigurationArgs.builder()
                         .ipv4("10.0.2.10")
                         .subnetId(example2.id())
                         .build())
                 .vpcId(example.id())
                 .serviceName("com.amazonaws.us-west-2.ec2")
                 .vpcEndpointType("Interface")
                 .subnetIds(            
                     example1.id(),
                     example2.id())
                 .build());
     
         }
     }
     
     
    ### Gateway Load Balancer Endpoint Type
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.AwsFunctions;
     import com.pulumi.aws.inputs.GetCallerIdentityArgs;
     import com.pulumi.aws.ec2.VpcEndpointService;
     import com.pulumi.aws.ec2.VpcEndpointServiceArgs;
     import com.pulumi.aws.ec2.VpcEndpoint;
     import com.pulumi.aws.ec2.VpcEndpointArgs;
     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) {
             final var current = AwsFunctions.getCallerIdentity(GetCallerIdentityArgs.builder()
                 .build());
     
             var example = new VpcEndpointService("example", VpcEndpointServiceArgs.builder()
                 .acceptanceRequired(false)
                 .allowedPrincipals(current.arn())
                 .gatewayLoadBalancerArns(exampleAwsLb.arn())
                 .build());
     
             var exampleVpcEndpoint = new VpcEndpoint("exampleVpcEndpoint", VpcEndpointArgs.builder()
                 .serviceName(example.serviceName())
                 .subnetIds(exampleAwsSubnet.id())
                 .vpcEndpointType(example.serviceType())
                 .vpcId(exampleAwsVpc.id())
                 .build());
     
         }
     }
     
     
    ### VPC Lattice Resource Configuration Endpoint Type
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.ec2.VpcEndpoint;
     import com.pulumi.aws.ec2.VpcEndpointArgs;
     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 example = new VpcEndpoint("example", VpcEndpointArgs.builder()
                 .resourceConfigurationArn(exampleAwsVpclatticeResourceConfiguration.arn())
                 .subnetIds(exampleAwsSubnet.id())
                 .vpcEndpointType("Resource")
                 .vpcId(exampleAwsVpc.id())
                 .build());
     
         }
     }
     
     
    ### VPC Lattice Service Network Endpoint Type
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.ec2.VpcEndpoint;
     import com.pulumi.aws.ec2.VpcEndpointArgs;
     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 example = new VpcEndpoint("example", VpcEndpointArgs.builder()
                 .serviceNetworkArn(exampleAwsVpclatticeServiceNetwork.arn())
                 .subnetIds(exampleAwsSubnet.id())
                 .vpcEndpointType("ServiceNetwork")
                 .vpcId(exampleAwsVpc.id())
                 .build());
     
         }
     }
     
     
    ### Non-AWS Service
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.ec2.VpcEndpoint;
     import com.pulumi.aws.ec2.VpcEndpointArgs;
     import com.pulumi.aws.route53.Route53Functions;
     import com.pulumi.aws.route53.inputs.GetZoneArgs;
     import com.pulumi.aws.route53.Record;
     import com.pulumi.aws.route53.RecordArgs;
     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 ptfeService = new VpcEndpoint("ptfeService", VpcEndpointArgs.builder()
                 .vpcId(vpcId)
                 .serviceName(ptfeServiceConfig)
                 .vpcEndpointType("Interface")
                 .securityGroupIds(ptfeServiceAwsSecurityGroup.id())
                 .subnetIds(subnetIds)
                 .privateDnsEnabled(false)
                 .build());
     
             final var internal = Route53Functions.getZone(GetZoneArgs.builder()
                 .name("vpc.internal.")
                 .privateZone(true)
                 .vpcId(vpcId)
                 .build());
     
             var ptfeServiceRecord = new Record("ptfeServiceRecord", RecordArgs.builder()
                 .zoneId(internal.zoneId())
                 .name(String.format("ptfe.%s", internal.name()))
                 .type("CNAME")
                 .ttl(300)
                 .records(ptfeService.dnsEntries().applyValue(_dnsEntries -> _dnsEntries[0].dns_name()))
                 .build());
     
         }
     }
     
     
    > **NOTE The `dnsEntry` output is a list of maps:** This provider interpolation support for lists of maps requires the `lookup` and `[]` until full support of lists of maps is available ## Import ### Identity Schema #### Required * `id` - (String) ID of the VPC endpoint. #### Optional * `accountId` (String) AWS Account where this resource is managed. * `region` (String) Region where this resource is managed. Using `pulumi import`, import VPC Endpoints using the VPC endpoint `id`. For example: ```sh $ pulumi import aws:ec2/vpcEndpoint:VpcEndpoint example vpce-3ecf2a57 ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.lang.String> arn()  
      com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> autoAccept()  
      com.pulumi.core.Output<java.util.List<java.lang.String>> cidrBlocks()  
      com.pulumi.core.Output<java.util.List<VpcEndpointDnsEntry>> dnsEntries()  
      com.pulumi.core.Output<VpcEndpointDnsOptions> dnsOptions()  
      static VpcEndpoint get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, VpcEndpointState 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> ipAddressType()  
      com.pulumi.core.Output<java.util.List<java.lang.String>> networkInterfaceIds()  
      com.pulumi.core.Output<java.lang.String> ownerId()  
      com.pulumi.core.Output<java.lang.String> policy()  
      com.pulumi.core.Output<java.lang.String> prefixListId()  
      com.pulumi.core.Output<java.lang.Boolean> privateDnsEnabled()  
      com.pulumi.core.Output<java.lang.String> region()  
      com.pulumi.core.Output<java.lang.Boolean> requesterManaged()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> resourceConfigurationArn()  
      com.pulumi.core.Output<java.util.List<java.lang.String>> routeTableIds()  
      com.pulumi.core.Output<java.util.List<java.lang.String>> securityGroupIds()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> serviceName()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> serviceNetworkArn()  
      com.pulumi.core.Output<java.lang.String> serviceRegion()  
      com.pulumi.core.Output<java.lang.String> state()  
      com.pulumi.core.Output<java.util.List<VpcEndpointSubnetConfiguration>> subnetConfigurations()  
      com.pulumi.core.Output<java.util.List<java.lang.String>> subnetIds()  
      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.util.Optional<java.lang.String>> vpcEndpointType()  
      com.pulumi.core.Output<java.lang.String> vpcId()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • VpcEndpoint

        public VpcEndpoint​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • VpcEndpoint

        public VpcEndpoint​(java.lang.String name,
                           VpcEndpointArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • VpcEndpoint

        public VpcEndpoint​(java.lang.String name,
                           VpcEndpointArgs 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

      • arn

        public com.pulumi.core.Output<java.lang.String> arn()
        Returns:
        ARN of the VPC endpoint.
      • autoAccept

        public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> autoAccept()
        Returns:
        Whether to accept the VPC endpoint (the VPC endpoint and service need to be in the same AWS account).
      • cidrBlocks

        public com.pulumi.core.Output<java.util.List<java.lang.String>> cidrBlocks()
        Returns:
        List of CIDR blocks for the exposed AWS service. Applicable for endpoints of type `Gateway`.
      • dnsEntries

        public com.pulumi.core.Output<java.util.List<VpcEndpointDnsEntry>> dnsEntries()
        Returns:
        DNS entries for the VPC Endpoint. Applicable for endpoints of type `Interface`. See `dnsEntry` below.
      • dnsOptions

        public com.pulumi.core.Output<VpcEndpointDnsOptions> dnsOptions()
        Returns:
        DNS options for the endpoint. See `dnsOptions` below.
      • ipAddressType

        public com.pulumi.core.Output<java.lang.String> ipAddressType()
        Returns:
        IP address type for the endpoint. Valid values are `ipv4`, `dualstack`, and `ipv6`.
      • networkInterfaceIds

        public com.pulumi.core.Output<java.util.List<java.lang.String>> networkInterfaceIds()
        Returns:
        One or more network interfaces for the VPC Endpoint. Applicable for endpoints of type `Interface`.
      • ownerId

        public com.pulumi.core.Output<java.lang.String> ownerId()
        Returns:
        ID of the AWS account that owns the VPC endpoint.
      • policy

        public com.pulumi.core.Output<java.lang.String> policy()
        Returns:
        Policy to attach to the endpoint that controls access to the service. This is a JSON formatted string. Defaults to full access. All `Gateway` and some `Interface` endpoints support policies - see the [relevant AWS documentation](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-endpoints-access.html) for more details. For more information about building AWS IAM policy documents with Pulumi, see the AWS IAM Policy Document Guide.
      • prefixListId

        public com.pulumi.core.Output<java.lang.String> prefixListId()
        Returns:
        Prefix list ID of the exposed AWS service. Applicable for endpoints of type `Gateway`.
      • privateDnsEnabled

        public com.pulumi.core.Output<java.lang.Boolean> privateDnsEnabled()
        Returns:
        Whether to associate a private hosted zone with the specified VPC. Available for AWS services and AWS Marketplace partner services only. Applicable for endpoints of type `Interface`. Most users will want this enabled to allow services within the VPC to automatically use the endpoint. Defaults to `false`. If `vpcEndpointType` is anything other than `Interface`, changing this value forces a new resource to be created.
      • 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.
      • requesterManaged

        public com.pulumi.core.Output<java.lang.Boolean> requesterManaged()
        Returns:
        Whether or not the VPC Endpoint is being managed by its service - `true` or `false`.
      • resourceConfigurationArn

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> resourceConfigurationArn()
        Returns:
        ARN of a Resource Configuration to connect this VPC Endpoint to. Exactly one of `resourceConfigurationArn`, `serviceName` or `serviceNetworkArn` is required.
      • routeTableIds

        public com.pulumi.core.Output<java.util.List<java.lang.String>> routeTableIds()
        Returns:
        One or more route table IDs. Applicable for endpoints of type `Gateway`.
      • securityGroupIds

        public com.pulumi.core.Output<java.util.List<java.lang.String>> securityGroupIds()
        Returns:
        ID of one or more security groups to associate with the network interface. Applicable for endpoints of type `Interface`. If no security groups are specified, the VPC's [default security group](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html#DefaultSecurityGroup) is associated with the endpoint.
      • serviceName

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> serviceName()
        Returns:
        Service name. For AWS services the service name is usually in the form `com.amazonaws.<region>.<service>` (the SageMaker AI Notebook service is an exception to this rule, the service name is in the form `aws.sagemaker.<region>.notebook`). Exactly one of `resourceConfigurationArn`, `serviceName` or `serviceNetworkArn` is required.
      • serviceNetworkArn

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> serviceNetworkArn()
        Returns:
        ARN of a Service Network to connect this VPC Endpoint to. Exactly one of `resourceConfigurationArn`, `serviceName` or `serviceNetworkArn` is required.
      • serviceRegion

        public com.pulumi.core.Output<java.lang.String> serviceRegion()
        Returns:
        AWS region of the VPC Endpoint Service. If specified, the VPC endpoint will connect to the service in the provided region. Applicable for endpoints of type `Interface`.
      • state

        public com.pulumi.core.Output<java.lang.String> state()
        Returns:
        State of the VPC endpoint.
      • subnetConfigurations

        public com.pulumi.core.Output<java.util.List<VpcEndpointSubnetConfiguration>> subnetConfigurations()
        Returns:
        Subnet configuration for the endpoint, used to select specific IPv4 and/or IPv6 addresses to the endpoint. See subnetConfiguration below.
      • subnetIds

        public com.pulumi.core.Output<java.util.List<java.lang.String>> subnetIds()
        Returns:
        ID of one or more subnets in which to create a network interface for the endpoint. Applicable for endpoints of type `GatewayLoadBalancer` and `Interface`. Interface type endpoints cannot function without being assigned to a subnet.
      • 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.
      • vpcEndpointType

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> vpcEndpointType()
        Returns:
        VPC endpoint type, `Gateway`, `GatewayLoadBalancer`,`Interface`, `Resource` or `ServiceNetwork`. Defaults to `Gateway`.
      • vpcId

        public com.pulumi.core.Output<java.lang.String> vpcId()
        Returns:
        ID of the VPC in which the endpoint will be used.
      • get

        public static VpcEndpoint get​(java.lang.String name,
                                      com.pulumi.core.Output<java.lang.String> id,
                                      @Nullable
                                      VpcEndpointState 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.