Using Wait Conditions For a Bucket

You can use wait commands to pause your script execution until a specific condition is met for your bucket. This is particularly useful for automated workflows, where you need to ensure that a certain state is reached before proceeding with the next execution.

If you need to retrieve metadata about a specific bucket without actually retrieving its content, see Getting Information About a Bucket Using AWS CLI > Checking for Bucket Existence and Access.

Using Wait Conditions For a Bucket Using AWS CLI (s3api)

Before you begin: Install and configure AWS CLI. For more information, see Installing and Configuring AWS CLI.

Wait Until a Bucket Exists

To ensure that a bucket exists and is accessible before performing further actions, use the wait bucket-exists command following this syntax:

Request sample
$ aws s3api wait bucket-exists \
    --profile YOUR_PROFILE \
    --bucket BUCKET \
    --endpoint https://oos.eu-west-2.outscale.com

This command contains the following attributes that you need to specify:

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • bucket: The name of the bucket you want to verify the existence of.

  • endpoint: The endpoint corresponding to the Region you want to send the request to. For more information, see Installing and Configuring AWS CLI.

The command polls the bucket every 5 seconds until a successful state is reached, after which the command should return no output.

However, after 20 successive failed checks (100 seconds in total), the command returns the following error message:

Result sample
Waiter BucketExists failed: Max attempts exceeded. Previously accepted state: Matched expected HTTP status code: 404

Wait Until a Bucket No Longer Exists

To ensure that a bucket no longer exists before performing further actions, use the wait bucket-not-exists command following this syntax:

Request sample
$ aws s3api wait bucket-not-exists \
    --profile YOUR_PROFILE \
    --bucket BUCKET \
    --endpoint https://oos.eu-west-2.outscale.com

This command contains the following attributes that you need to specify:

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • bucket: The name of the bucket you want to wait for until it no longer exists.

  • endpoint: The endpoint corresponding to the Region you want to send the request to. For more information, see Installing and Configuring AWS CLI.

The command polls the bucket every 5 seconds until a successful state is reached, after which the command should return no output.

However, after 20 successive failed checks (100 seconds in total), the command returns the following error message:

Result sample
Waiter BucketNotExists failed: Max attempts exceeded.

Related Pages

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.