AWS Classic

Pulumi Official
Package maintained by Pulumi
v5.10.0 published on Monday, Jul 11, 2022 by Pulumi

AccessPointPolicy

Import

Access Point policies can be imported using the access_point_arn, e.g.

 $ pulumi import aws:s3control/accessPointPolicy:AccessPointPolicy example arn:aws:s3:us-west-2:123456789012:accesspoint/example

Example Usage

using System.Collections.Generic;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var exampleBucketV2 = new Aws.S3.BucketV2("exampleBucketV2", new Aws.S3.BucketV2Args
        {
        });
        var exampleAccessPoint = new Aws.S3.AccessPoint("exampleAccessPoint", new Aws.S3.AccessPointArgs
        {
            Bucket = exampleBucketV2.Id,
            PublicAccessBlockConfiguration = new Aws.S3.Inputs.AccessPointPublicAccessBlockConfigurationArgs
            {
                BlockPublicAcls = true,
                BlockPublicPolicy = false,
                IgnorePublicAcls = true,
                RestrictPublicBuckets = false,
            },
        });
        var exampleAccessPointPolicy = new Aws.S3Control.AccessPointPolicy("exampleAccessPointPolicy", new Aws.S3Control.AccessPointPolicyArgs
        {
            AccessPointArn = exampleAccessPoint.Arn,
            Policy = exampleAccessPoint.Arn.Apply(arn => JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                { "Version", "2008-10-17" },
                { "Statement", new[]
                    {
                        new Dictionary<string, object?>
                        {
                            { "Effect", "Allow" },
                            { "Action", "s3:GetObjectTagging" },
                            { "Principal", new Dictionary<string, object?>
                            {
                                { "AWS", "*" },
                            } },
                            { "Resource", $"{arn}/object/*" },
                        },
                    }
                 },
            })),
        });
    }

}
package main

import (
	"encoding/json"
	"fmt"

	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/s3"
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/s3control"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleBucketV2, err := s3.NewBucketV2(ctx, "exampleBucketV2", nil)
		if err != nil {
			return err
		}
		exampleAccessPoint, err := s3.NewAccessPoint(ctx, "exampleAccessPoint", &s3.AccessPointArgs{
			Bucket: exampleBucketV2.ID(),
			PublicAccessBlockConfiguration: &s3.AccessPointPublicAccessBlockConfigurationArgs{
				BlockPublicAcls:       pulumi.Bool(true),
				BlockPublicPolicy:     pulumi.Bool(false),
				IgnorePublicAcls:      pulumi.Bool(true),
				RestrictPublicBuckets: pulumi.Bool(false),
			},
		})
		if err != nil {
			return err
		}
		_, err = s3control.NewAccessPointPolicy(ctx, "exampleAccessPointPolicy", &s3control.AccessPointPolicyArgs{
			AccessPointArn: exampleAccessPoint.Arn,
			Policy: exampleAccessPoint.Arn.ApplyT(func(arn string) (pulumi.String, error) {
				var _zero pulumi.String
				tmpJSON0, err := json.Marshal(map[string]interface{}{
					"Version": "2008-10-17",
					"Statement": []map[string]interface{}{
						map[string]interface{}{
							"Effect": "Allow",
							"Action": "s3:GetObjectTagging",
							"Principal": map[string]interface{}{
								"AWS": "*",
							},
							"Resource": fmt.Sprintf("%v%v", arn, "/object/*"),
						},
					},
				})
				if err != nil {
					return _zero, err
				}
				json0 := string(tmpJSON0)
				return json0, nil
			}).(pulumi.StringOutput),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;
import static com.pulumi.codegen.internal.Serialization.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var exampleBucketV2 = new BucketV2("exampleBucketV2");

        var exampleAccessPoint = new AccessPoint("exampleAccessPoint", AccessPointArgs.builder()        
            .bucket(exampleBucketV2.id())
            .publicAccessBlockConfiguration(AccessPointPublicAccessBlockConfigurationArgs.builder()
                .blockPublicAcls(true)
                .blockPublicPolicy(false)
                .ignorePublicAcls(true)
                .restrictPublicBuckets(false)
                .build())
            .build());

        var exampleAccessPointPolicy = new AccessPointPolicy("exampleAccessPointPolicy", AccessPointPolicyArgs.builder()        
            .accessPointArn(exampleAccessPoint.arn())
            .policy(exampleAccessPoint.arn().apply(arn -> serializeJson(
                jsonObject(
                    jsonProperty("Version", "2008-10-17"),
                    jsonProperty("Statement", jsonArray(jsonObject(
                        jsonProperty("Effect", "Allow"),
                        jsonProperty("Action", "s3:GetObjectTagging"),
                        jsonProperty("Principal", jsonObject(
                            jsonProperty("AWS", "*")
                        )),
                        jsonProperty("Resource", String.format("%s/object/*", arn))
                    )))
                ))))
            .build());

    }
}
import pulumi
import json
import pulumi_aws as aws

example_bucket_v2 = aws.s3.BucketV2("exampleBucketV2")
example_access_point = aws.s3.AccessPoint("exampleAccessPoint",
    bucket=example_bucket_v2.id,
    public_access_block_configuration=aws.s3.AccessPointPublicAccessBlockConfigurationArgs(
        block_public_acls=True,
        block_public_policy=False,
        ignore_public_acls=True,
        restrict_public_buckets=False,
    ))
example_access_point_policy = aws.s3control.AccessPointPolicy("exampleAccessPointPolicy",
    access_point_arn=example_access_point.arn,
    policy=example_access_point.arn.apply(lambda arn: json.dumps({
        "Version": "2008-10-17",
        "Statement": [{
            "Effect": "Allow",
            "Action": "s3:GetObjectTagging",
            "Principal": {
                "AWS": "*",
            },
            "Resource": f"{arn}/object/*",
        }],
    })))
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const exampleBucketV2 = new aws.s3.BucketV2("exampleBucketV2", {});
const exampleAccessPoint = new aws.s3.AccessPoint("exampleAccessPoint", {
    bucket: exampleBucketV2.id,
    publicAccessBlockConfiguration: {
        blockPublicAcls: true,
        blockPublicPolicy: false,
        ignorePublicAcls: true,
        restrictPublicBuckets: false,
    },
});
const exampleAccessPointPolicy = new aws.s3control.AccessPointPolicy("exampleAccessPointPolicy", {
    accessPointArn: exampleAccessPoint.arn,
    policy: exampleAccessPoint.arn.apply(arn => JSON.stringify({
        Version: "2008-10-17",
        Statement: [{
            Effect: "Allow",
            Action: "s3:GetObjectTagging",
            Principal: {
                AWS: "*",
            },
            Resource: `${arn}/object/*`,
        }],
    })),
});
resources:
  exampleBucketV2:
    type: aws:s3:BucketV2
  exampleAccessPoint:
    type: aws:s3:AccessPoint
    properties:
      bucket: ${exampleBucketV2.id}
      publicAccessBlockConfiguration:
        blockPublicAcls: true
        blockPublicPolicy: false
        ignorePublicAcls: true
        restrictPublicBuckets: false
  exampleAccessPointPolicy:
    type: aws:s3control:AccessPointPolicy
    properties:
      accessPointArn: ${exampleAccessPoint.arn}
      policy:
        Fn::ToJSON:
          Version: 2008-10-17
          Statement:
            - Effect: Allow
              Action: s3:GetObjectTagging
              Principal:
                AWS: '*'
              Resource: ${exampleAccessPoint.arn}/object/*

Create a AccessPointPolicy Resource

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

name string
The unique name of the resource.
args AccessPointPolicyArgs
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 AccessPointPolicyArgs
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 AccessPointPolicyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args AccessPointPolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args AccessPointPolicyArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

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

AccessPointArn string

The ARN of the access point that you want to associate with the specified policy.

Policy string

The policy that you want to apply to the specified access point.

AccessPointArn string

The ARN of the access point that you want to associate with the specified policy.

Policy string

The policy that you want to apply to the specified access point.

accessPointArn String

The ARN of the access point that you want to associate with the specified policy.

policy String

The policy that you want to apply to the specified access point.

accessPointArn string

The ARN of the access point that you want to associate with the specified policy.

policy string

The policy that you want to apply to the specified access point.

access_point_arn str

The ARN of the access point that you want to associate with the specified policy.

policy str

The policy that you want to apply to the specified access point.

accessPointArn String

The ARN of the access point that you want to associate with the specified policy.

policy String

The policy that you want to apply to the specified access point.

Outputs

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

HasPublicAccessPolicy bool

Indicates whether this access point currently has a policy that allows public access.

Id string

The provider-assigned unique ID for this managed resource.

HasPublicAccessPolicy bool

Indicates whether this access point currently has a policy that allows public access.

Id string

The provider-assigned unique ID for this managed resource.

hasPublicAccessPolicy Boolean

Indicates whether this access point currently has a policy that allows public access.

id String

The provider-assigned unique ID for this managed resource.

hasPublicAccessPolicy boolean

Indicates whether this access point currently has a policy that allows public access.

id string

The provider-assigned unique ID for this managed resource.

has_public_access_policy bool

Indicates whether this access point currently has a policy that allows public access.

id str

The provider-assigned unique ID for this managed resource.

hasPublicAccessPolicy Boolean

Indicates whether this access point currently has a policy that allows public access.

id String

The provider-assigned unique ID for this managed resource.

Look up an Existing AccessPointPolicy Resource

Get an existing AccessPointPolicy 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?: AccessPointPolicyState, opts?: CustomResourceOptions): AccessPointPolicy
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        access_point_arn: Optional[str] = None,
        has_public_access_policy: Optional[bool] = None,
        policy: Optional[str] = None) -> AccessPointPolicy
func GetAccessPointPolicy(ctx *Context, name string, id IDInput, state *AccessPointPolicyState, opts ...ResourceOption) (*AccessPointPolicy, error)
public static AccessPointPolicy Get(string name, Input<string> id, AccessPointPolicyState? state, CustomResourceOptions? opts = null)
public static AccessPointPolicy get(String name, Output<String> id, AccessPointPolicyState 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:
AccessPointArn string

The ARN of the access point that you want to associate with the specified policy.

HasPublicAccessPolicy bool

Indicates whether this access point currently has a policy that allows public access.

Policy string

The policy that you want to apply to the specified access point.

AccessPointArn string

The ARN of the access point that you want to associate with the specified policy.

HasPublicAccessPolicy bool

Indicates whether this access point currently has a policy that allows public access.

Policy string

The policy that you want to apply to the specified access point.

accessPointArn String

The ARN of the access point that you want to associate with the specified policy.

hasPublicAccessPolicy Boolean

Indicates whether this access point currently has a policy that allows public access.

policy String

The policy that you want to apply to the specified access point.

accessPointArn string

The ARN of the access point that you want to associate with the specified policy.

hasPublicAccessPolicy boolean

Indicates whether this access point currently has a policy that allows public access.

policy string

The policy that you want to apply to the specified access point.

access_point_arn str

The ARN of the access point that you want to associate with the specified policy.

has_public_access_policy bool

Indicates whether this access point currently has a policy that allows public access.

policy str

The policy that you want to apply to the specified access point.

accessPointArn String

The ARN of the access point that you want to associate with the specified policy.

hasPublicAccessPolicy Boolean

Indicates whether this access point currently has a policy that allows public access.

policy String

The policy that you want to apply to the specified access point.

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.