Enables or disables Block Public Access for a bucket.
Prerequisites
Before you begin, ensure that you have:
The
oss:PutBucketPublicAccessBlockpermission, if operating as a RAM user or using Security Token Service (STS). Alibaba Cloud accounts have this permission by default. For setup instructions, see Attach a custom policy to a RAM user
Syntax
ossutil api put-bucket-public-access-block --bucket <value> --public-access-block-configuration <value> [flags]| Parameter | Type | Description |
|---|---|---|
--bucket | string | Name of the bucket |
--public-access-block-configuration | string | Block Public Access configuration |
Note: This command maps to the PutBucketPublicAccessBlock API operation. For all supported global flags, see Command-line options.
--public-access-block-configuration
The --public-access-block-configuration parameter accepts XML or JSON. To load the configuration from a file, prefix the file path with file://.
XML format:
<PublicAccessBlockConfiguration>
<BlockPublicAccess>true</BlockPublicAccess>
</PublicAccessBlockConfiguration>JSON format:
{
"BlockPublicAccess": "string"
}Examples
The following examples enable Block Public Access for examplebucket.
Using an XML configuration file:
Create
public-access-block-configuration.xmlwith the following content:<?xml version="1.0" encoding="UTF-8"?> <PublicAccessBlockConfiguration> <BlockPublicAccess>true</BlockPublicAccess> </PublicAccessBlockConfiguration>Run the command:
ossutil api put-bucket-public-access-block --bucket examplebucket --public-access-block-configuration file://public-access-block-configuration.xml
Using a JSON configuration file:
Create
public-access-block-configuration.jsonwith the following content:{ "BlockPublicAccess": "true" }Run the command:
ossutil api put-bucket-public-access-block --bucket examplebucket --public-access-block-configuration file://public-access-block-configuration.json
Using inline JSON:
ossutil api put-bucket-public-access-block --bucket examplebucket --public-access-block-configuration "{\"BlockPublicAccess\":\"true\"}"