VpcEndpointPolicy class
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": "*",
}],
}))
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 main
import (
"encoding/json"
"github.com/pulumi/pulumi-aws/sdk/v7/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().ToIDOutput().ToStringOutput(),
})
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]string{
"AWS": "*",
},
"Action": []string{
"dynamodb:*",
},
"Resource": "*",
},
},
})
if err != nil {
return err
}
json0 := string(tmpJSON0)
_, err = ec2.NewVpcEndpointPolicy(ctx, "example", &ec2.VpcEndpointPolicyArgs{
VpcEndpointId: exampleVpcEndpoint.ID().ToIDOutput().ToStringOutput(),
Policy: pulumi.String(json0),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
data "aws_ec2_getvpcendpointservice" "example" {
service = "dynamodb"
}
resource "aws_ec2_vpc" "example" {
cidr_block = "10.0.0.0/16"
}
resource "aws_ec2_vpcendpoint" "example" {
service_name = data.aws_ec2_getvpcendpointservice.example.service_name
vpc_id = aws_ec2_vpc.example.id
}
resource "aws_ec2_vpcendpointpolicy" "example" {
vpc_endpoint_id = aws_ec2_vpcendpoint.example.id
policy = jsonencode({
"Version" = "2012-10-17"
"Statement" = [{
"Sid" = "AllowAll"
"Effect" = "Allow"
"Principal" = {
"AWS" = "*"
}
"Action" = ["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.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 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.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
Import
Using pulumi import, import VPC Endpoint Policies using the id. For example:
$ pulumi import aws:ec2/vpcEndpointPolicy:VpcEndpointPolicy example vpce-3ecf2a57
Constructors
- VpcEndpointPolicy(String name, {VpcEndpointPolicyArgs? args, CustomResourceOptions? options})
-
Creates a new VpcEndpointPolicy.
nameThe Pulumi resource name.argsArguments used to configure this VpcEndpointPolicy. The set of arguments for VpcEndpointPolicy.optionsResource options controlling this resource's behavior. - VpcEndpointPolicy.reference(String urn)
- Creates a typed reference to an existing VpcEndpointPolicy resource.
Properties
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
policy
↔ Output<
String> -
A policy to attach to the endpoint that controls access to the service. Defaults to full access. All
Gatewayand someInterfaceendpoints support policies - see the relevant AWS documentation for more details.latefinal -
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
-
vpcEndpointId
↔ Output<
String> -
The VPC Endpoint ID.
latefinal
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {VpcEndpointPolicyState? state, CustomResourceOptions? options}) → VpcEndpointPolicy -
Gets an existing VpcEndpointPolicy resource's state with the given
nameandid.