Skip to content

update_bucket

update_bucket(
    bucket_name: BucketName,
    *,
    config_overrides: Optional[LightsailClientConfig] = None,
    access_rules: Optional[AccessRules] = None,
    versioning: Optional[NonEmptyString] = None,
    readonly_access_accounts: Optional[PartnerIdList] = None,
    access_log_config: Optional[BucketAccessLogConfig] = None,
    cors: Optional[BucketCorsConfig] = None,
) -> UpdateBucketResult

Updates an existing Amazon Lightsail bucket.

Use this action to update the configuration of an existing bucket, such as versioning, public accessibility, and the Amazon Web Services accounts that can access the bucket.

Parameters:

  • bucket_name (BucketName) –

    The name of the bucket to update.

  • access_rules (Optional[AccessRules], default: None ) –

    An object that sets the public accessibility of objects in the specified bucket.

  • versioning (Optional[NonEmptyString], default: None ) –

    Specifies whether to enable or suspend versioning of objects in the bucket.

    The following options can be specified:

    • Enabled - Enables versioning of objects in the specified bucket.

    • Suspended - Suspends versioning of objects in the specified bucket. Existing object versions are retained.

  • readonly_access_accounts (Optional[PartnerIdList], default: None ) –

    An array of strings to specify the Amazon Web Services account IDs that can access the bucket.

    You can give a maximum of 10 Amazon Web Services accounts access to a bucket.

  • access_log_config (Optional[BucketAccessLogConfig], default: None ) –

    An object that describes the access log configuration for the bucket.

  • cors (Optional[BucketCorsConfig], default: None ) –

    Sets the cross-origin resource sharing (CORS) configuration for your bucket. If a CORS configuration exists, it is replaced with the specified configuration. For AWS CLI operations, this parameter can also be passed as a file. For more information, see Configuring cross-origin resource sharing (CORS).

    CORS information is only returned in a response when you update the CORS policy.

Raises:

  • AccessDeniedException –

    Lightsail throws this exception when the user cannot be authenticated or uses invalid credentials to access a resource.

  • InvalidInputException –

    Lightsail throws this exception when user input does not conform to the validation rules of an input field.

    Domain and distribution APIs are only available in the N. Virginia (us-east-1) Amazon Web Services Region. Please set your Amazon Web Services Region configuration to us-east-1 to create, view, or edit these resources.

  • NotFoundException –

    Lightsail throws this exception when it cannot find a resource.

  • RegionSetupInProgressException –

    Lightsail throws this exception when an operation is performed on resources in an opt-in Region that is currently being set up.

  • ServiceException –

    A general service exception.

  • UnauthenticatedException –

    Lightsail throws this exception when the user has not been authenticated.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_lightsail/_services/lightsail.py
def update_bucket(
    self,
    bucket_name: "capo_lightsail.types.bucket_name.BucketName",
    *,
    config_overrides: Optional[LightsailClientConfig] = None,
    access_rules: Optional["capo_lightsail.types.access_rules.AccessRules"] = None,
    versioning: Optional[
        "capo_lightsail.types.non_empty_string.NonEmptyString"
    ] = None,
    readonly_access_accounts: Optional[
        "capo_lightsail.types.partner_id_list.PartnerIdList"
    ] = None,
    access_log_config: Optional[
        "capo_lightsail.types.bucket_access_log_config.BucketAccessLogConfig"
    ] = None,
    cors: Optional[
        "capo_lightsail.types.bucket_cors_config.BucketCorsConfig"
    ] = None,
) -> "capo_lightsail.types.update_bucket_result.UpdateBucketResult":
    """<p>Updates an existing Amazon Lightsail bucket.</p> <p>Use this action to update the configuration of an existing bucket, such as versioning, public accessibility, and the Amazon Web Services accounts that can access the bucket.</p>

    Args:
        bucket_name: <p>The name of the bucket to update.</p>
        access_rules: <p>An object that sets the public accessibility of objects in the specified bucket.</p>
        versioning: <p>Specifies whether to enable or suspend versioning of objects in the bucket.</p> <p>The following options can be specified:</p> <ul> <li> <p> <code>Enabled</code> - Enables versioning of objects in the specified bucket.</p> </li> <li> <p> <code>Suspended</code> - Suspends versioning of objects in the specified bucket. Existing object versions are retained.</p> </li> </ul>
        readonly_access_accounts: <p>An array of strings to specify the Amazon Web Services account IDs that can access the bucket.</p> <p>You can give a maximum of 10 Amazon Web Services accounts access to a bucket.</p>
        access_log_config: <p>An object that describes the access log configuration for the bucket.</p>
        cors: <p>Sets the cross-origin resource sharing (CORS) configuration for your bucket. If a CORS configuration exists, it is replaced with the specified configuration. For AWS CLI operations, this parameter can also be passed as a file. For more information, see <a href="https://docs.aws.amazon.com/lightsail/latest/userguide/configure-cors.html">Configuring cross-origin resource sharing (CORS)</a>.</p> <note> <p>CORS information is only returned in a response when you update the CORS policy.</p> </note>

    Raises:
        capo_lightsail.errors.access_denied_exception.AccessDeniedException: <p>Lightsail throws this exception when the user cannot be authenticated or uses invalid credentials to access a resource.</p>
        capo_lightsail.errors.invalid_input_exception.InvalidInputException: <p>Lightsail throws this exception when user input does not conform to the validation rules of an input field.</p> <note> <p>Domain and distribution APIs are only available in the N. Virginia (<code>us-east-1</code>) Amazon Web Services Region. Please set your Amazon Web Services Region configuration to <code>us-east-1</code> to create, view, or edit these resources.</p> </note>
        capo_lightsail.errors.not_found_exception.NotFoundException: <p>Lightsail throws this exception when it cannot find a resource.</p>
        capo_lightsail.errors.region_setup_in_progress_exception.RegionSetupInProgressException: <p>Lightsail throws this exception when an operation is performed on resources in an opt-in Region that is currently being set up.</p>
        capo_lightsail.errors.service_exception.ServiceException: <p>A general service exception.</p>
        capo_lightsail.errors.unauthenticated_exception.UnauthenticatedException: <p>Lightsail throws this exception when the user has not been authenticated.</p>
        capo_lightsail.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_lightsail.types.update_bucket_request.UpdateBucketRequest]",
    ) -> OperationResponse[
        "capo_lightsail.types.update_bucket_result.UpdateBucketResult"
    ]:
        import capo_lightsail._operations.lightsail_20161128.update_bucket

        output, http_response = (
            capo_lightsail._operations.lightsail_20161128.update_bucket.update_bucket(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateBucket")
    )
    input_: capo_lightsail.types.update_bucket_request.UpdateBucketRequest = {
        "bucket_name": bucket_name
    }
    if access_rules is not None:
        input_["access_rules"] = access_rules
    if versioning is not None:
        input_["versioning"] = versioning
    if readonly_access_accounts is not None:
        input_["readonly_access_accounts"] = readonly_access_accounts
    if access_log_config is not None:
        input_["access_log_config"] = access_log_config
    if cors is not None:
        input_["cors"] = cors

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output