amazonka-s3-2.0: Amazon Simple Storage Service SDK.
Copyright(c) 2013-2023 Brendan Hay
LicenseMozilla Public License, v. 2.0.
MaintainerBrendan Hay
Stabilityauto-generated
Portabilitynon-portable (GHC extensions)
Safe HaskellSafe-Inferred
LanguageHaskell2010

Amazonka.S3.PutBucketPolicy

Description

Applies an Amazon S3 bucket policy to an Amazon S3 bucket. If you are using an identity other than the root user of the Amazon Web Services 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 Amazon Web Services 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:

Synopsis

Creating a Request

data PutBucketPolicy Source #

See: newPutBucketPolicy smart constructor.

Constructors

PutBucketPolicy' 

Fields

  • checksumAlgorithm :: Maybe ChecksumAlgorithm

    Indicates the algorithm used to create the checksum for the object when using the SDK. This header will not provide any additional functionality if not using the SDK. When sending this header, there must be a corresponding x-amz-checksum or x-amz-trailer header sent. Otherwise, Amazon S3 fails the request with the HTTP status code 400 Bad Request. For more information, see Checking object integrity in the Amazon S3 User Guide.

    If you provide an individual checksum, Amazon S3 ignores any provided ChecksumAlgorithm parameter.

  • confirmRemoveSelfBucketAccess :: Maybe Bool

    Set this parameter to true to confirm that you want to remove your permissions to change this bucket policy in the future.

  • contentMD5 :: Maybe Text

    The MD5 hash of the request body.

    For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.

  • expectedBucketOwner :: Maybe Text

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request fails with the HTTP status code 403 Forbidden (access denied).

  • bucket :: BucketName

    The name of the bucket.

  • policy :: ByteString

    The bucket policy as a JSON document.

Instances

Instances details
ToBody PutBucketPolicy Source # 
Instance details

Defined in Amazonka.S3.PutBucketPolicy

ToHeaders PutBucketPolicy Source # 
Instance details

Defined in Amazonka.S3.PutBucketPolicy

ToPath PutBucketPolicy Source # 
Instance details

Defined in Amazonka.S3.PutBucketPolicy

ToQuery PutBucketPolicy Source # 
Instance details

Defined in Amazonka.S3.PutBucketPolicy

AWSRequest PutBucketPolicy Source # 
Instance details

Defined in Amazonka.S3.PutBucketPolicy

Associated Types

type AWSResponse PutBucketPolicy #

Generic PutBucketPolicy Source # 
Instance details

Defined in Amazonka.S3.PutBucketPolicy

Associated Types

type Rep PutBucketPolicy :: Type -> Type #

Show PutBucketPolicy Source # 
Instance details

Defined in Amazonka.S3.PutBucketPolicy

NFData PutBucketPolicy Source # 
Instance details

Defined in Amazonka.S3.PutBucketPolicy

Methods

rnf :: PutBucketPolicy -> () #

Eq PutBucketPolicy Source # 
Instance details

Defined in Amazonka.S3.PutBucketPolicy

Hashable PutBucketPolicy Source # 
Instance details

Defined in Amazonka.S3.PutBucketPolicy

type AWSResponse PutBucketPolicy Source # 
Instance details

Defined in Amazonka.S3.PutBucketPolicy

type Rep PutBucketPolicy Source # 
Instance details

Defined in Amazonka.S3.PutBucketPolicy

type Rep PutBucketPolicy = D1 ('MetaData "PutBucketPolicy" "Amazonka.S3.PutBucketPolicy" "amazonka-s3-2.0-CNZtv1UmVzj28JXsFvwNoj" 'False) (C1 ('MetaCons "PutBucketPolicy'" 'PrefixI 'True) ((S1 ('MetaSel ('Just "checksumAlgorithm") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe ChecksumAlgorithm)) :*: (S1 ('MetaSel ('Just "confirmRemoveSelfBucketAccess") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Bool)) :*: S1 ('MetaSel ('Just "contentMD5") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text)))) :*: (S1 ('MetaSel ('Just "expectedBucketOwner") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text)) :*: (S1 ('MetaSel ('Just "bucket") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 BucketName) :*: S1 ('MetaSel ('Just "policy") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ByteString)))))

newPutBucketPolicy Source #

Create a value of PutBucketPolicy with all optional fields omitted.

Use generic-lens or optics to modify other optional fields.

The following record fields are available, with the corresponding lenses provided for backwards compatibility:

PutBucketPolicy, putBucketPolicy_checksumAlgorithm - Indicates the algorithm used to create the checksum for the object when using the SDK. This header will not provide any additional functionality if not using the SDK. When sending this header, there must be a corresponding x-amz-checksum or x-amz-trailer header sent. Otherwise, Amazon S3 fails the request with the HTTP status code 400 Bad Request. For more information, see Checking object integrity in the Amazon S3 User Guide.

If you provide an individual checksum, Amazon S3 ignores any provided ChecksumAlgorithm parameter.

$sel:confirmRemoveSelfBucketAccess:PutBucketPolicy', putBucketPolicy_confirmRemoveSelfBucketAccess - Set this parameter to true to confirm that you want to remove your permissions to change this bucket policy in the future.

$sel:contentMD5:PutBucketPolicy', putBucketPolicy_contentMD5 - The MD5 hash of the request body.

For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.

$sel:expectedBucketOwner:PutBucketPolicy', putBucketPolicy_expectedBucketOwner - The account ID of the expected bucket owner. If the bucket is owned by a different account, the request fails with the HTTP status code 403 Forbidden (access denied).

PutBucketPolicy, putBucketPolicy_bucket - The name of the bucket.

$sel:policy:PutBucketPolicy', putBucketPolicy_policy - The bucket policy as a JSON document.

Request Lenses

putBucketPolicy_checksumAlgorithm :: Lens' PutBucketPolicy (Maybe ChecksumAlgorithm) Source #

Indicates the algorithm used to create the checksum for the object when using the SDK. This header will not provide any additional functionality if not using the SDK. When sending this header, there must be a corresponding x-amz-checksum or x-amz-trailer header sent. Otherwise, Amazon S3 fails the request with the HTTP status code 400 Bad Request. For more information, see Checking object integrity in the Amazon S3 User Guide.

If you provide an individual checksum, Amazon S3 ignores any provided ChecksumAlgorithm parameter.

putBucketPolicy_confirmRemoveSelfBucketAccess :: Lens' PutBucketPolicy (Maybe Bool) Source #

Set this parameter to true to confirm that you want to remove your permissions to change this bucket policy in the future.

putBucketPolicy_contentMD5 :: Lens' PutBucketPolicy (Maybe Text) Source #

The MD5 hash of the request body.

For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.

putBucketPolicy_expectedBucketOwner :: Lens' PutBucketPolicy (Maybe Text) Source #

The account ID of the expected bucket owner. If the bucket is owned by a different account, the request fails with the HTTP status code 403 Forbidden (access denied).

putBucketPolicy_policy :: Lens' PutBucketPolicy ByteString Source #

The bucket policy as a JSON document.

Destructuring the Response

data PutBucketPolicyResponse Source #

See: newPutBucketPolicyResponse smart constructor.

Instances

Instances details
Generic PutBucketPolicyResponse Source # 
Instance details

Defined in Amazonka.S3.PutBucketPolicy

Associated Types

type Rep PutBucketPolicyResponse :: Type -> Type #

Read PutBucketPolicyResponse Source # 
Instance details

Defined in Amazonka.S3.PutBucketPolicy

Show PutBucketPolicyResponse Source # 
Instance details

Defined in Amazonka.S3.PutBucketPolicy

NFData PutBucketPolicyResponse Source # 
Instance details

Defined in Amazonka.S3.PutBucketPolicy

Methods

rnf :: PutBucketPolicyResponse -> () #

Eq PutBucketPolicyResponse Source # 
Instance details

Defined in Amazonka.S3.PutBucketPolicy

type Rep PutBucketPolicyResponse Source # 
Instance details

Defined in Amazonka.S3.PutBucketPolicy

type Rep PutBucketPolicyResponse = D1 ('MetaData "PutBucketPolicyResponse" "Amazonka.S3.PutBucketPolicy" "amazonka-s3-2.0-CNZtv1UmVzj28JXsFvwNoj" 'False) (C1 ('MetaCons "PutBucketPolicyResponse'" 'PrefixI 'False) (U1 :: Type -> Type))

newPutBucketPolicyResponse :: PutBucketPolicyResponse Source #

Create a value of PutBucketPolicyResponse with all optional fields omitted.

Use generic-lens or optics to modify other optional fields.