Try AWS Native preview for resources not in the classic version.
aws.s3control.AccessPointPolicy
Explore with Pulumi AI
Try AWS Native preview for resources not in the classic version.
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
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.s3.BucketV2("example", {bucket: "example"});
const exampleAccessPoint = new aws.s3.AccessPoint("example", {
bucket: example.id,
name: "example",
publicAccessBlockConfiguration: {
blockPublicAcls: true,
blockPublicPolicy: false,
ignorePublicAcls: true,
restrictPublicBuckets: false,
},
});
const exampleAccessPointPolicy = new aws.s3control.AccessPointPolicy("example", {
accessPointArn: exampleAccessPoint.arn,
policy: pulumi.jsonStringify({
Version: "2008-10-17",
Statement: [{
Effect: "Allow",
Action: "s3:GetObjectTagging",
Principal: {
AWS: "*",
},
Resource: pulumi.interpolate`${exampleAccessPoint.arn}/object/*`,
}],
}),
});
import pulumi
import json
import pulumi_aws as aws
example = aws.s3.BucketV2("example", bucket="example")
example_access_point = aws.s3.AccessPoint("example",
bucket=example.id,
name="example",
public_access_block_configuration={
"blockPublicAcls": True,
"blockPublicPolicy": False,
"ignorePublicAcls": True,
"restrictPublicBuckets": False,
})
example_access_point_policy = aws.s3control.AccessPointPolicy("example",
access_point_arn=example_access_point.arn,
policy=pulumi.Output.json_dumps({
"Version": "2008-10-17",
"Statement": [{
"Effect": "Allow",
"Action": "s3:GetObjectTagging",
"Principal": {
"AWS": "*",
},
"Resource": example_access_point.arn.apply(lambda arn: f"{arn}/object/*"),
}],
}))
package main
import (
"encoding/json"
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3control"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{
Bucket: pulumi.String("example"),
})
if err != nil {
return err
}
exampleAccessPoint, err := s3.NewAccessPoint(ctx, "example", &s3.AccessPointArgs{
Bucket: example.ID(),
Name: pulumi.String("example"),
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, "example", &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
})
}
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.S3.BucketV2("example", new()
{
Bucket = "example",
});
var exampleAccessPoint = new Aws.S3.AccessPoint("example", new()
{
Bucket = example.Id,
Name = "example",
PublicAccessBlockConfiguration = new Aws.S3.Inputs.AccessPointPublicAccessBlockConfigurationArgs
{
BlockPublicAcls = true,
BlockPublicPolicy = false,
IgnorePublicAcls = true,
RestrictPublicBuckets = false,
},
});
var exampleAccessPointPolicy = new Aws.S3Control.AccessPointPolicy("example", new()
{
AccessPointArn = exampleAccessPoint.Arn,
Policy = Output.JsonSerialize(Output.Create(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"] = exampleAccessPoint.Arn.Apply(arn => $"{arn}/object/*"),
},
},
})),
});
});
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.BucketV2Args;
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 example = new BucketV2("example", BucketV2Args.builder()
.bucket("example")
.build());
var exampleAccessPoint = new AccessPoint("exampleAccessPoint", AccessPointArgs.builder()
.bucket(example.id())
.name("example")
.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());
}
}
resources:
example:
type: aws:s3:BucketV2
properties:
bucket: example
exampleAccessPoint:
type: aws:s3:AccessPoint
name: example
properties:
bucket: ${example.id}
name: example
publicAccessBlockConfiguration:
blockPublicAcls: true
blockPublicPolicy: false
ignorePublicAcls: true
restrictPublicBuckets: false
exampleAccessPointPolicy:
type: aws:s3control:AccessPointPolicy
name: example
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
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new AccessPointPolicy(name: string, args: AccessPointPolicyArgs, opts?: CustomResourceOptions);
@overload
def AccessPointPolicy(resource_name: str,
args: AccessPointPolicyArgs,
opts: Optional[ResourceOptions] = None)
@overload
def AccessPointPolicy(resource_name: str,
opts: Optional[ResourceOptions] = None,
access_point_arn: Optional[str] = None,
policy: Optional[str] = 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.
Parameters
- 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.
Constructor example
The following reference example uses placeholder values for all input properties.
var accessPointPolicyResource = new Aws.S3Control.AccessPointPolicy("accessPointPolicyResource", new()
{
AccessPointArn = "string",
Policy = "string",
});
example, err := s3control.NewAccessPointPolicy(ctx, "accessPointPolicyResource", &s3control.AccessPointPolicyArgs{
AccessPointArn: pulumi.String("string"),
Policy: pulumi.String("string"),
})
var accessPointPolicyResource = new AccessPointPolicy("accessPointPolicyResource", AccessPointPolicyArgs.builder()
.accessPointArn("string")
.policy("string")
.build());
access_point_policy_resource = aws.s3control.AccessPointPolicy("accessPointPolicyResource",
access_point_arn="string",
policy="string")
const accessPointPolicyResource = new aws.s3control.AccessPointPolicy("accessPointPolicyResource", {
accessPointArn: "string",
policy: "string",
});
type: aws:s3control:AccessPointPolicy
properties:
accessPointArn: string
policy: string
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:
- Access
Point stringArn - 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 stringArn - 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 StringArn - 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 stringArn - 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_ strarn - 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.
- access
Point StringArn - 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:
- Has
Public boolAccess Policy - 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 boolAccess Policy - 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 BooleanAccess Policy - 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 booleanAccess Policy - 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_ boolaccess_ policy - Indicates whether this access point currently has a policy that allows public access.
- id str
- The provider-assigned unique ID for this managed resource.
- has
Public BooleanAccess Policy - 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.
- Access
Point stringArn - The ARN of the access point that you want to associate with the specified policy.
- Has
Public boolAccess Policy - 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 stringArn - The ARN of the access point that you want to associate with the specified policy.
- Has
Public boolAccess Policy - 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 StringArn - The ARN of the access point that you want to associate with the specified policy.
- has
Public BooleanAccess Policy - 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 stringArn - The ARN of the access point that you want to associate with the specified policy.
- has
Public booleanAccess Policy - 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_ strarn - The ARN of the access point that you want to associate with the specified policy.
- has_
public_ boolaccess_ policy - 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.
- access
Point StringArn - The ARN of the access point that you want to associate with the specified policy.
- has
Public BooleanAccess Policy - 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
Using pulumi import
, import Access Point policies using the access_point_arn
. For example:
$ pulumi import aws:s3control/accessPointPolicy:AccessPointPolicy example arn:aws:s3:us-west-2:123456789012:accesspoint/example
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.
Try AWS Native preview for resources not in the classic version.