We recommend new projects start with resources from the AWS provider.
aws-native.s3.BucketPolicy
Explore with Pulumi AI
We recommend new projects start with resources from the AWS provider.
Applies an Amazon S3 bucket policy to an Amazon S3 bucket. If you are using an identity other than the root user of the AWS-account that owns the bucket, the calling identity must have the PutBucketPolicy
permissions on the specified bucket and belong to the bucket owner’s account in order to use this operation.
If you don’t have PutBucketPolicy
permissions, Amazon S3 returns a 403 Access Denied
error. If you have the correct permissions, but you’re not using an identity that belongs to the bucket owner’s account, Amazon S3 returns a 405 Method Not Allowed
error.
As a security precaution, the root user of the AWS-account that owns a bucket can always use this operation, even if the policy explicitly denies the root user the ability to perform this action.
For more information, see Bucket policy examples.
The following operations are related to PutBucketPolicy
:
Create BucketPolicy Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new BucketPolicy(name: string, args: BucketPolicyArgs, opts?: CustomResourceOptions);
@overload
def BucketPolicy(resource_name: str,
args: BucketPolicyArgs,
opts: Optional[ResourceOptions] = None)
@overload
def BucketPolicy(resource_name: str,
opts: Optional[ResourceOptions] = None,
bucket: Optional[str] = None,
policy_document: Optional[Any] = None)
func NewBucketPolicy(ctx *Context, name string, args BucketPolicyArgs, opts ...ResourceOption) (*BucketPolicy, error)
public BucketPolicy(string name, BucketPolicyArgs args, CustomResourceOptions? opts = null)
public BucketPolicy(String name, BucketPolicyArgs args)
public BucketPolicy(String name, BucketPolicyArgs args, CustomResourceOptions options)
type: aws-native:s3:BucketPolicy
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 BucketPolicyArgs
- 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 BucketPolicyArgs
- 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 BucketPolicyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args BucketPolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args BucketPolicyArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
BucketPolicy Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The BucketPolicy resource accepts the following input properties:
- Bucket string
- The name of the Amazon S3 bucket to which the policy applies.
- Policy
Document object A policy document containing permissions to add to the specified bucket. In IAM, you must provide policy documents in JSON format. However, in CloudFormation you can provide the policy in JSON or YAML format because CloudFormation converts YAML to JSON before submitting it to IAM. For more information, see the AWS::IAM::Policy PolicyDocument resource description in this guide and Access Policy Language Overview in the Amazon S3 User Guide.
Search the CloudFormation User Guide for
AWS::S3::BucketPolicy
for more information about the expected schema for this property.
- Bucket string
- The name of the Amazon S3 bucket to which the policy applies.
- Policy
Document interface{} A policy document containing permissions to add to the specified bucket. In IAM, you must provide policy documents in JSON format. However, in CloudFormation you can provide the policy in JSON or YAML format because CloudFormation converts YAML to JSON before submitting it to IAM. For more information, see the AWS::IAM::Policy PolicyDocument resource description in this guide and Access Policy Language Overview in the Amazon S3 User Guide.
Search the CloudFormation User Guide for
AWS::S3::BucketPolicy
for more information about the expected schema for this property.
- bucket String
- The name of the Amazon S3 bucket to which the policy applies.
- policy
Document Object A policy document containing permissions to add to the specified bucket. In IAM, you must provide policy documents in JSON format. However, in CloudFormation you can provide the policy in JSON or YAML format because CloudFormation converts YAML to JSON before submitting it to IAM. For more information, see the AWS::IAM::Policy PolicyDocument resource description in this guide and Access Policy Language Overview in the Amazon S3 User Guide.
Search the CloudFormation User Guide for
AWS::S3::BucketPolicy
for more information about the expected schema for this property.
- bucket string
- The name of the Amazon S3 bucket to which the policy applies.
- policy
Document any A policy document containing permissions to add to the specified bucket. In IAM, you must provide policy documents in JSON format. However, in CloudFormation you can provide the policy in JSON or YAML format because CloudFormation converts YAML to JSON before submitting it to IAM. For more information, see the AWS::IAM::Policy PolicyDocument resource description in this guide and Access Policy Language Overview in the Amazon S3 User Guide.
Search the CloudFormation User Guide for
AWS::S3::BucketPolicy
for more information about the expected schema for this property.
- bucket str
- The name of the Amazon S3 bucket to which the policy applies.
- policy_
document Any A policy document containing permissions to add to the specified bucket. In IAM, you must provide policy documents in JSON format. However, in CloudFormation you can provide the policy in JSON or YAML format because CloudFormation converts YAML to JSON before submitting it to IAM. For more information, see the AWS::IAM::Policy PolicyDocument resource description in this guide and Access Policy Language Overview in the Amazon S3 User Guide.
Search the CloudFormation User Guide for
AWS::S3::BucketPolicy
for more information about the expected schema for this property.
- bucket String
- The name of the Amazon S3 bucket to which the policy applies.
- policy
Document Any A policy document containing permissions to add to the specified bucket. In IAM, you must provide policy documents in JSON format. However, in CloudFormation you can provide the policy in JSON or YAML format because CloudFormation converts YAML to JSON before submitting it to IAM. For more information, see the AWS::IAM::Policy PolicyDocument resource description in this guide and Access Policy Language Overview in the Amazon S3 User Guide.
Search the CloudFormation User Guide for
AWS::S3::BucketPolicy
for more information about the expected schema for this property.
Outputs
All input properties are implicitly available as output properties. Additionally, the BucketPolicy resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Package Details
- Repository
- AWS Native pulumi/pulumi-aws-native
- License
- Apache-2.0
We recommend new projects start with resources from the AWS provider.