Filter objects in Lightsail buckets by name prefix
You can use filtering to find objects in your bucket in the Amazon Lightsail object storage service. In this guide, we show you how to filter objects using the Lightsail console, and the AWS Command Line Interface (AWS CLI). For more information about buckets, see Object storage.
Filter objects using the Lightsail console
Complete the following procedure to filter objects in a bucket using the Lightsail console.
-
Sign in to the Lightsail console
. -
In the left navigation pane, choose Storage.
-
Choose the name of the bucket for which you want to find objects.
-
In the Objects tab, type an object prefix in the Filter by name text box.
The list of objects in the folder that you're currently viewing are filtered to match the text you enter. The following example shows that if you enter
sail
, the list of objects on the page are filtered to display only those that start withsail
.To filter the list of objects in a different folder, navigate to that folder. Then, enter the object prefix into the Filter by name text box there.
Filter objects using the AWS CLI
Complete the following procedure to filter objects in a bucket using the AWS Command Line Interface
(AWS CLI). You do this by using the list-objects-v2
command. For more information,
see list-objects-v2 in the AWS CLI Command Reference.
Note
You must install the AWS CLI and configure it for Lightsail and Amazon S3 before continuing with this procedure. For more information, see Configure the AWS Command Line Interface to work with Amazon Lightsail.
-
Open a Command Prompt or Terminal window.
-
Enter the following command to list objects that start with a specific object key name prefix.
aws s3api list-objects-v2 --bucket
BucketName
--prefixObjectKeyNamePrefix
--query "Contents[].{Key: Key, Size: Size}"In the command, replace the following example text with your own:
-
BucketName
- The name of the bucket for which you want to list all objects. -
ObjectKeyNamePrefix
- An object key name prefix to limit the response to keys that begin with the specified prefix.
Note
This command uses the
--query
parameter to filter the response of thelist-objects-v2
request to the key value and size of each object.Example:
aws s3api list-objects-v2 --bucket
amzn-s3-demo-bucket
--prefixarchived/
--query "Contents[].{Key: Key, Size: Size}"You should see a result similar to the following example.
-
Manage buckets and objects
These are the general steps to manage your Lightsail object storage bucket:
-
Learn about objects and buckets in the Amazon Lightsail object storage service. For more information, see Object storage in Amazon Lightsail.
-
Learn about the names that you can give your buckets in Amazon Lightsail. For more information, see Bucket naming rules in Amazon Lightsail.
-
Get started with the Lightsail object storage service by creating a bucket. For more information, see Creating buckets in Amazon Lightsail.
-
Learn about security best practices for buckets and the access permissions that you can configure for your bucket. You can make all objects in your bucket public or private, or you can choose to make individual objects public. You can also grant access to your bucket by creating access keys, attaching instances to your bucket, and granting access to other AWS accounts. For more information, see Security Best Practices for Amazon Lightsail object storage and Understanding bucket permissions in Amazon Lightsail.
After learning about bucket access permissions, see the following guides to grant access to your bucket:
-
Learn how to enable access logging for your bucket, and how to use access logs to audit the security of your bucket. For more information, see the following guides.
-
Access logging for buckets in the Amazon Lightsail object storage service
-
Access log format for a bucket in the Amazon Lightsail object storage service
-
Enabling access logging for a bucket in the Amazon Lightsail object storage service
-
Using access logs for a bucket in Amazon Lightsail to identify requests
-
-
Create an IAM policy that grants a user the ability to manage a bucket in Lightsail. For more information, see IAM policy to manage buckets in Amazon Lightsail.
-
Learn about the way that objects in your bucket are labeled and identified. For more information, see Understanding object key names in Amazon Lightsail.
-
Learn how to upload files and manage objects in your buckets. For more information, see the following guides.
-
Enable object versioning to preserve, retrieve, and restore every version of every object stored in your bucket. For more information, see Enabling and suspending object versioning in a bucket in Amazon Lightsail.
-
After enabling object versioning, you can restore previous versions of objects in your bucket. For more information, see Restoring previous versions of objects in a bucket in Amazon Lightsail.
-
Monitor the utilization of your bucket. For more information, see Viewing metrics for your bucket in Amazon Lightsail.
-
Configure an alarm for bucket metrics to be notified when the utilization of your bucket crosses a threshold. For more information, see Creating bucket metric alarms in Amazon Lightsail.
-
Change the storage plan of your bucket if it's running low on storage and network transfer. For more information, see Changing the plan of your bucket in Amazon Lightsail.
-
Learn how to connect your bucket to other resources. For more information, see the following tutorials.
-
Delete your bucket if you're no longer using it. For more information, see Deleting buckets in Amazon Lightsail.