The put-bucket-public-access-block command is used to enable or disable Block Public Access for buckets.
Notes
By default, an Alibaba Cloud account has the permission to enable or disable Block Public Access for buckets. Modifying the Block Public Access configurations as a RAM user or by using Security Token Service (STS) requires oss:PutBucketPublicAccessBlock
permission. For more information, see Attach a custom policy to a RAM user.
Command 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 | Configurations of Block Public Access. |
The put-bucket-public-access-block command corresponds to the PutBucketPublicAccessBlock operation. For more information about the parameters within, see PutBucketPublicAccessBlock.
--public-access-block-configuration
The --public-access-block-configuration option supports both XML and JSON formats. If the value of the option contains the file:// prefix, configuration parameters are read from the specified file.
XML format:
<PublicAccessBlockConfiguration> <BlockPublicAccess>true</BlockPublicAccess> </PublicAccessBlockConfiguration>
JSON format:
{ "BlockPublicAccess": "string" }
For more information about supported global command-line options, see Command-line options.
Examples
Enable Block Public Access for examplebucket
.
Create a configuration file named public-access-block-configuration.xml and add the following code:
<?xml version="1.0" encoding="UTF-8"?> <PublicAccessBlockConfiguration> <BlockPublicAccess>true</BlockPublicAccess> </PublicAccessBlockConfiguration>
Sample command:
ossutil api put-bucket-public-access-block --bucket examplebucket --public-access-block-configuration file://public-access-block-configuration.xml
Create a configuration file named public-access-block-configuration.json and add the following code:
{ "BlockPublicAccess": "true" }
Sample command:
ossutil api put-bucket-public-access-block --bucket examplebucket --public-access-block-configuration file://public-access-block-configuration.json
Configure parameters in the following command in the JSON format:
ossutil api put-bucket-public-access-block --bucket examplebucket --public-access-block-configuration "{\"BlockPublicAccess\":\"true\"}"