Skip to content

S3  >  Operations  >  put_public_access_block

put_public_access_block

Operation

put_public_access_block async

put_public_access_block(request: PutPublicAccessBlockInput | PutPublicAccessBlockInputDict, /, *, plugins: list[Plugin] | None = None) -> PutPublicAccessBlockOutput
put_public_access_block(*, plugins: list[Plugin] | None = None, **kwargs: Unpack[PutPublicAccessBlockInputDict]) -> PutPublicAccessBlockOutput
Note

This operation is not supported for directory buckets.

Creates or modifies the PublicAccessBlock configuration for an Amazon S3 bucket. To use this operation, you must have the s3:PutBucketPublicAccessBlock permission. For more information about Amazon S3 permissions, see Specifying Permissions in a Policy.

Warning

When Amazon S3 evaluates the PublicAccessBlock configuration for a bucket or an object, it checks the PublicAccessBlock configuration for both the bucket (or the bucket that contains the object) and the bucket owner's account. Account-level settings automatically inherit from organization-level policies when present. If the PublicAccessBlock configurations are different between the bucket and the account, Amazon S3 uses the most restrictive combination of the bucket-level and account-level settings.

For more information about when Amazon S3 considers a bucket or an object public, see The Meaning of "Public".

The following operations are related to PutPublicAccessBlock:

Warning

You must URL encode any signed header values that contain spaces. For example, if your header value is my file.txt, containing two spaces after my, you must URL encode this value to my%20%20file.txt.

Parameters:

Name Type Description Default
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None

Returns:

Type Description
PutPublicAccessBlockOutput

An instance of PutPublicAccessBlockOutput.

Input

Pass the input fields as keyword arguments, or pass a model or dictionary as the first positional argument. Pass plugins separately as a keyword argument.

Model

PutPublicAccessBlockInput dataclass

Bases: _SerdeShape

Dataclass for PutPublicAccessBlockInput structure.

Attributes
bucket class-attribute instance-attribute
bucket: str | None = ...

The name of the Amazon S3 bucket whose PublicAccessBlock configuration you want to set.

checksum_algorithm class-attribute instance-attribute
checksum_algorithm: str | None = ...

Indicates the algorithm used to create the checksum for the object when you use the SDK. This header will not provide any additional functionality if you don't use the SDK. When you send 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.

content_md5 class-attribute instance-attribute
content_md5: str | None = ...

The MD5 hash of the PutPublicAccessBlock request body.

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

expected_bucket_owner class-attribute instance-attribute
expected_bucket_owner: str | None = ...

The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code 403 Forbidden (access denied).

public_access_block_configuration class-attribute instance-attribute
public_access_block_configuration: PublicAccessBlockConfiguration | None = ...

The PublicAccessBlock configuration that you want to apply to this Amazon S3 bucket. You can enable the configuration options in any combination. For more information about when Amazon S3 considers a bucket or object public, see The Meaning of "Public" in the Amazon S3 User Guide.

Dictionaries

PutPublicAccessBlockInputDict

Bases: TypedDict

Dictionary form of PutPublicAccessBlockInput.

Attributes
bucket instance-attribute
bucket: Required[str]

The name of the Amazon S3 bucket whose PublicAccessBlock configuration you want to set.

checksum_algorithm instance-attribute
checksum_algorithm: str | None

Indicates the algorithm used to create the checksum for the object when you use the SDK. This header will not provide any additional functionality if you don't use the SDK. When you send 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.

content_md5 instance-attribute
content_md5: str | None

The MD5 hash of the PutPublicAccessBlock request body.

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

expected_bucket_owner instance-attribute
expected_bucket_owner: str | None

The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code 403 Forbidden (access denied).

public_access_block_configuration instance-attribute

The PublicAccessBlock configuration that you want to apply to this Amazon S3 bucket. You can enable the configuration options in any combination. For more information about when Amazon S3 considers a bucket or object public, see The Meaning of "Public" in the Amazon S3 User Guide.

Output

PutPublicAccessBlockOutput dataclass

Bases: _SerdeShape

Dataclass for PutPublicAccessBlockOutput structure.

Attributes

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.