Expand description
Attaches a policy to an S3 bucket resource.
Policies can be attached to both S3 general purpose buckets and S3 directory buckets.
§Example Usage
§Basic Usage
resources:
example:
type: aws:s3:BucketV2
properties:
bucket: my-tf-test-bucket
allowAccessFromAnotherAccountBucketPolicy:
type: aws:s3:BucketPolicy
name: allow_access_from_another_account
properties:
bucket: ${example.id}
policy: ${allowAccessFromAnotherAccount.json}
variables:
allowAccessFromAnotherAccount:
fn::invoke:
function: aws:iam:getPolicyDocument
arguments:
statements:
- principals:
- type: AWS
identifiers:
- '123456789012'
actions:
- s3:GetObject
- s3:ListBucket
resources:
- ${example.arn}
- ${example.arn}/*
§Import
Using pulumi import
, import S3 bucket policies using the bucket name. For example:
$ pulumi import aws:s3/bucketPolicy:BucketPolicy allow_access_from_another_account my-tf-test-bucket
Structs§
- Use builder syntax to set the inputs and finish with
build_struct()
.
Functions§
- Registers a new resource with the given unique name and arguments