1. Packages
  2. AWS Classic
  3. API Docs
  4. ec2
  5. VpcEndpointPolicy

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.45.0 published on Tuesday, Jul 16, 2024 by Pulumi

aws.ec2.VpcEndpointPolicy

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.45.0 published on Tuesday, Jul 16, 2024 by Pulumi

    Provides a VPC Endpoint Policy resource.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const example = aws.ec2.getVpcEndpointService({
        service: "dynamodb",
    });
    const exampleVpc = new aws.ec2.Vpc("example", {cidrBlock: "10.0.0.0/16"});
    const exampleVpcEndpoint = new aws.ec2.VpcEndpoint("example", {
        serviceName: example.then(example => example.serviceName),
        vpcId: exampleVpc.id,
    });
    const exampleVpcEndpointPolicy = new aws.ec2.VpcEndpointPolicy("example", {
        vpcEndpointId: exampleVpcEndpoint.id,
        policy: JSON.stringify({
            Version: "2012-10-17",
            Statement: [{
                Sid: "AllowAll",
                Effect: "Allow",
                Principal: {
                    AWS: "*",
                },
                Action: ["dynamodb:*"],
                Resource: "*",
            }],
        }),
    });
    
    import pulumi
    import json
    import pulumi_aws as aws
    
    example = aws.ec2.get_vpc_endpoint_service(service="dynamodb")
    example_vpc = aws.ec2.Vpc("example", cidr_block="10.0.0.0/16")
    example_vpc_endpoint = aws.ec2.VpcEndpoint("example",
        service_name=example.service_name,
        vpc_id=example_vpc.id)
    example_vpc_endpoint_policy = aws.ec2.VpcEndpointPolicy("example",
        vpc_endpoint_id=example_vpc_endpoint.id,
        policy=json.dumps({
            "Version": "2012-10-17",
            "Statement": [{
                "Sid": "AllowAll",
                "Effect": "Allow",
                "Principal": {
                    "AWS": "*",
                },
                "Action": ["dynamodb:*"],
                "Resource": "*",
            }],
        }))
    
    package main
    
    import (
    	"encoding/json"
    
    	"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 {
    		example, err := ec2.LookupVpcEndpointService(ctx, &ec2.LookupVpcEndpointServiceArgs{
    			Service: pulumi.StringRef("dynamodb"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		exampleVpc, err := ec2.NewVpc(ctx, "example", &ec2.VpcArgs{
    			CidrBlock: pulumi.String("10.0.0.0/16"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleVpcEndpoint, err := ec2.NewVpcEndpoint(ctx, "example", &ec2.VpcEndpointArgs{
    			ServiceName: pulumi.String(example.ServiceName),
    			VpcId:       exampleVpc.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"Version": "2012-10-17",
    			"Statement": []map[string]interface{}{
    				map[string]interface{}{
    					"Sid":    "AllowAll",
    					"Effect": "Allow",
    					"Principal": map[string]interface{}{
    						"AWS": "*",
    					},
    					"Action": []string{
    						"dynamodb:*",
    					},
    					"Resource": "*",
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		_, err = ec2.NewVpcEndpointPolicy(ctx, "example", &ec2.VpcEndpointPolicyArgs{
    			VpcEndpointId: exampleVpcEndpoint.ID(),
    			Policy:        pulumi.String(json0),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Aws.Ec2.GetVpcEndpointService.Invoke(new()
        {
            Service = "dynamodb",
        });
    
        var exampleVpc = new Aws.Ec2.Vpc("example", new()
        {
            CidrBlock = "10.0.0.0/16",
        });
    
        var exampleVpcEndpoint = new Aws.Ec2.VpcEndpoint("example", new()
        {
            ServiceName = example.Apply(getVpcEndpointServiceResult => getVpcEndpointServiceResult.ServiceName),
            VpcId = exampleVpc.Id,
        });
    
        var exampleVpcEndpointPolicy = new Aws.Ec2.VpcEndpointPolicy("example", new()
        {
            VpcEndpointId = exampleVpcEndpoint.Id,
            Policy = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["Version"] = "2012-10-17",
                ["Statement"] = new[]
                {
                    new Dictionary<string, object?>
                    {
                        ["Sid"] = "AllowAll",
                        ["Effect"] = "Allow",
                        ["Principal"] = new Dictionary<string, object?>
                        {
                            ["AWS"] = "*",
                        },
                        ["Action"] = new[]
                        {
                            "dynamodb:*",
                        },
                        ["Resource"] = "*",
                    },
                },
            }),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.ec2.Ec2Functions;
    import com.pulumi.aws.ec2.inputs.GetVpcEndpointServiceArgs;
    import com.pulumi.aws.ec2.Vpc;
    import com.pulumi.aws.ec2.VpcArgs;
    import com.pulumi.aws.ec2.VpcEndpoint;
    import com.pulumi.aws.ec2.VpcEndpointArgs;
    import com.pulumi.aws.ec2.VpcEndpointPolicy;
    import com.pulumi.aws.ec2.VpcEndpointPolicyArgs;
    import static com.pulumi.codegen.internal.Serialization.*;
    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) {
            final var example = Ec2Functions.getVpcEndpointService(GetVpcEndpointServiceArgs.builder()
                .service("dynamodb")
                .build());
    
            var exampleVpc = new Vpc("exampleVpc", VpcArgs.builder()
                .cidrBlock("10.0.0.0/16")
                .build());
    
            var exampleVpcEndpoint = new VpcEndpoint("exampleVpcEndpoint", VpcEndpointArgs.builder()
                .serviceName(example.applyValue(getVpcEndpointServiceResult -> getVpcEndpointServiceResult.serviceName()))
                .vpcId(exampleVpc.id())
                .build());
    
            var exampleVpcEndpointPolicy = new VpcEndpointPolicy("exampleVpcEndpointPolicy", VpcEndpointPolicyArgs.builder()
                .vpcEndpointId(exampleVpcEndpoint.id())
                .policy(serializeJson(
                    jsonObject(
                        jsonProperty("Version", "2012-10-17"),
                        jsonProperty("Statement", jsonArray(jsonObject(
                            jsonProperty("Sid", "AllowAll"),
                            jsonProperty("Effect", "Allow"),
                            jsonProperty("Principal", jsonObject(
                                jsonProperty("AWS", "*")
                            )),
                            jsonProperty("Action", jsonArray("dynamodb:*")),
                            jsonProperty("Resource", "*")
                        )))
                    )))
                .build());
    
        }
    }
    
    resources:
      exampleVpc:
        type: aws:ec2:Vpc
        name: example
        properties:
          cidrBlock: 10.0.0.0/16
      exampleVpcEndpoint:
        type: aws:ec2:VpcEndpoint
        name: example
        properties:
          serviceName: ${example.serviceName}
          vpcId: ${exampleVpc.id}
      exampleVpcEndpointPolicy:
        type: aws:ec2:VpcEndpointPolicy
        name: example
        properties:
          vpcEndpointId: ${exampleVpcEndpoint.id}
          policy:
            fn::toJSON:
              Version: 2012-10-17
              Statement:
                - Sid: AllowAll
                  Effect: Allow
                  Principal:
                    AWS: '*'
                  Action:
                    - dynamodb:*
                  Resource: '*'
    variables:
      example:
        fn::invoke:
          Function: aws:ec2:getVpcEndpointService
          Arguments:
            service: dynamodb
    

    Create VpcEndpointPolicy Resource

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

    Constructor syntax

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

    Parameters

    name string
    The unique name of the resource.
    args VpcEndpointPolicyArgs
    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 VpcEndpointPolicyArgs
    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 VpcEndpointPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args VpcEndpointPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args VpcEndpointPolicyArgs
    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 vpcEndpointPolicyResource = new Aws.Ec2.VpcEndpointPolicy("vpcEndpointPolicyResource", new()
    {
        VpcEndpointId = "string",
        Policy = "string",
    });
    
    example, err := ec2.NewVpcEndpointPolicy(ctx, "vpcEndpointPolicyResource", &ec2.VpcEndpointPolicyArgs{
    	VpcEndpointId: pulumi.String("string"),
    	Policy:        pulumi.String("string"),
    })
    
    var vpcEndpointPolicyResource = new VpcEndpointPolicy("vpcEndpointPolicyResource", VpcEndpointPolicyArgs.builder()
        .vpcEndpointId("string")
        .policy("string")
        .build());
    
    vpc_endpoint_policy_resource = aws.ec2.VpcEndpointPolicy("vpcEndpointPolicyResource",
        vpc_endpoint_id="string",
        policy="string")
    
    const vpcEndpointPolicyResource = new aws.ec2.VpcEndpointPolicy("vpcEndpointPolicyResource", {
        vpcEndpointId: "string",
        policy: "string",
    });
    
    type: aws:ec2:VpcEndpointPolicy
    properties:
        policy: string
        vpcEndpointId: string
    

    VpcEndpointPolicy 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 VpcEndpointPolicy resource accepts the following input properties:

    VpcEndpointId string
    The VPC Endpoint ID.
    Policy string
    A policy to attach to the endpoint that controls access to the service. Defaults to full access. All Gateway and some Interface endpoints support policies - see the relevant AWS documentation for more details.
    VpcEndpointId string
    The VPC Endpoint ID.
    Policy string
    A policy to attach to the endpoint that controls access to the service. Defaults to full access. All Gateway and some Interface endpoints support policies - see the relevant AWS documentation for more details.
    vpcEndpointId String
    The VPC Endpoint ID.
    policy String
    A policy to attach to the endpoint that controls access to the service. Defaults to full access. All Gateway and some Interface endpoints support policies - see the relevant AWS documentation for more details.
    vpcEndpointId string
    The VPC Endpoint ID.
    policy string
    A policy to attach to the endpoint that controls access to the service. Defaults to full access. All Gateway and some Interface endpoints support policies - see the relevant AWS documentation for more details.
    vpc_endpoint_id str
    The VPC Endpoint ID.
    policy str
    A policy to attach to the endpoint that controls access to the service. Defaults to full access. All Gateway and some Interface endpoints support policies - see the relevant AWS documentation for more details.
    vpcEndpointId String
    The VPC Endpoint ID.
    policy String
    A policy to attach to the endpoint that controls access to the service. Defaults to full access. All Gateway and some Interface endpoints support policies - see the relevant AWS documentation for more details.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the VpcEndpointPolicy 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 VpcEndpointPolicy Resource

    Get an existing VpcEndpointPolicy 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?: VpcEndpointPolicyState, opts?: CustomResourceOptions): VpcEndpointPolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            policy: Optional[str] = None,
            vpc_endpoint_id: Optional[str] = None) -> VpcEndpointPolicy
    func GetVpcEndpointPolicy(ctx *Context, name string, id IDInput, state *VpcEndpointPolicyState, opts ...ResourceOption) (*VpcEndpointPolicy, error)
    public static VpcEndpointPolicy Get(string name, Input<string> id, VpcEndpointPolicyState? state, CustomResourceOptions? opts = null)
    public static VpcEndpointPolicy get(String name, Output<String> id, VpcEndpointPolicyState 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:
    Policy string
    A policy to attach to the endpoint that controls access to the service. Defaults to full access. All Gateway and some Interface endpoints support policies - see the relevant AWS documentation for more details.
    VpcEndpointId string
    The VPC Endpoint ID.
    Policy string
    A policy to attach to the endpoint that controls access to the service. Defaults to full access. All Gateway and some Interface endpoints support policies - see the relevant AWS documentation for more details.
    VpcEndpointId string
    The VPC Endpoint ID.
    policy String
    A policy to attach to the endpoint that controls access to the service. Defaults to full access. All Gateway and some Interface endpoints support policies - see the relevant AWS documentation for more details.
    vpcEndpointId String
    The VPC Endpoint ID.
    policy string
    A policy to attach to the endpoint that controls access to the service. Defaults to full access. All Gateway and some Interface endpoints support policies - see the relevant AWS documentation for more details.
    vpcEndpointId string
    The VPC Endpoint ID.
    policy str
    A policy to attach to the endpoint that controls access to the service. Defaults to full access. All Gateway and some Interface endpoints support policies - see the relevant AWS documentation for more details.
    vpc_endpoint_id str
    The VPC Endpoint ID.
    policy String
    A policy to attach to the endpoint that controls access to the service. Defaults to full access. All Gateway and some Interface endpoints support policies - see the relevant AWS documentation for more details.
    vpcEndpointId String
    The VPC Endpoint ID.

    Import

    Using pulumi import, import VPC Endpoint Policies using the id. For example:

    $ pulumi import aws:ec2/vpcEndpointPolicy:VpcEndpointPolicy example vpce-3ecf2a57
    

    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.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.45.0 published on Tuesday, Jul 16, 2024 by Pulumi