AccessPointPolicy

Provides a resource to manage an S3 Access Point resource policy.

NOTE on Access Points and Access Point Policies: The provider provides both a standalone Access Point Policy resource and an Access Point resource with a resource policy defined in-line. You cannot use an Access Point with in-line resource policy in conjunction with an Access Point Policy resource. Doing so will cause a conflict of policies and will overwrite the access point’s resource policy.

Example Usage

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

return await Deployment.RunAsync(() => 
{
    var exampleBucketV2 = new Aws.S3.BucketV2("exampleBucketV2");

    var exampleAccessPoint = new Aws.S3.AccessPoint("exampleAccessPoint", new()
    {
        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()
    {
        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/object/*", arn),
						},
					},
				})
				if err != nil {
					return _zero, err
				}
				json0 := string(tmpJSON0)
				return pulumi.String(json0), nil
			}).(pulumi.StringOutput),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.s3.BucketV2;
import com.pulumi.aws.s3.AccessPoint;
import com.pulumi.aws.s3.AccessPointArgs;
import com.pulumi.aws.s3.inputs.AccessPointPublicAccessBlockConfigurationArgs;
import com.pulumi.aws.s3control.AccessPointPolicy;
import com.pulumi.aws.s3control.AccessPointPolicyArgs;
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) {
        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().applyValue(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 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 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.

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

Package Details

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

This Pulumi package is based on the aws Terraform Provider.