List Buckets
Retrieves a list of all storage buckets in a Google Cloud project.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- GCS Client Id - The client identifier obtained from the Connect node. Optional if credentials are provided directly.
- Project Id - The Google Cloud project ID to list buckets from.
Output
- List - An array of bucket names (strings) in the specified project. Stored in message context as
list.
Options
- Credentials - Google Cloud service account credentials (optional). Use this instead of GCS Client Id for direct authentication without Connect node.
How It Works
The List Buckets node retrieves all buckets in a project. When executed, the node:
- Establishes connection using either GCS Client Id or credentials
- Validates the project ID
- Queries Google Cloud Storage for all buckets in the project
- Iterates through bucket list (10-second timeout)
- Returns array of bucket names
Example
List All Buckets
// Input:
// Project Id: "my-gcp-project"
// Output in message.list:
// ["production-data", "staging-data", "backups-2024", "logs"]
Process Each Bucket
// After List Buckets:
const buckets = message.list;
console.log(`Found ${buckets.length} buckets`);
// Use Loop node to process each bucket
buckets.forEach(bucketName => {
console.log(`Processing bucket: ${bucketName}`);
// Get bucket details, list objects, etc.
});
Find Specific Bucket
// Search for buckets matching pattern
const buckets = message.list;
const prodBuckets = buckets.filter(name =>
name.includes('production')
);
console.log('Production buckets:', prodBuckets);
Bucket Inventory
// Create bucket inventory
const buckets = message.list;
console.log('Bucket Inventory Report');
console.log('=====================');
console.log(`Total buckets: ${buckets.length}`);
console.log('Bucket names:');
buckets.forEach((bucket, index) => {
console.log(`${index + 1}. ${bucket}`);
});
Requirements
- Either valid GCS Client Id OR credentials provided directly
- Valid Google Cloud Project ID
- Appropriate IAM permissions:
storage.buckets.listpermissionroles/storage.objectVieweror higher
Error Handling
| Error Code | Description |
|---|---|
ErrInvalidArg | Project Id is empty or invalid |
ErrBucketAttribute | Could not find any bucket attribute |
ErrIterator | Error iterating through buckets |
Common error scenarios:
- Invalid or empty Project ID
- Insufficient permissions
- Operation timeout (10 seconds)
- Network connectivity issues
- Project doesn't exist
Usage Notes
- Returns simple array of bucket names
- Only buckets with read access are included
- 10-second timeout for operation
- Empty projects return empty array
[] - List may be incomplete if permissions limited
- Useful for inventory and validation
- Bucket names are unique within a project
Tips for Effective Use
- Use for bucket discovery and inventory
- Combine with Get Bucket for detailed information
- Filter results based on naming patterns
- Use with Loop nodes for batch operations
- Cache results to avoid repeated API calls
- Implement pagination for projects with many buckets
- Use for automated bucket management
Common Errors and Solutions
Error: "Project Id cannot be empty"
- Solution: Provide valid project ID
- Verify project ID format (not project name)
Error: "Could not find any bucket attribute"
- Solution: Project may have no buckets
- Verify project ID is correct
- Check permissions to list buckets
Empty list but buckets exist
- Solution: Verify service account has list permission
- Check if using correct project ID
- Ensure buckets aren't in different project
Operation timeout
- Solution: Project may have many buckets
- Check network connectivity
- Retry operation
Use Cases
Bucket Inventory
- List all buckets for auditing
- Generate bucket inventory reports
- Track bucket creation and usage
Automated Management
- Discover buckets for batch operations
- Find buckets matching naming pattern
- Validate bucket existence
Compliance and Governance
- Audit bucket configurations
- Verify naming conventions
- Track bucket ownership
Cost Management
- Identify all project buckets for cost analysis
- Find unused or old buckets
- Generate bucket usage reports
Multi-Bucket Operations
- Process all buckets in project
- Apply consistent configurations
- Bulk bucket updates
Advanced Examples
Filter by Naming Convention
const buckets = message.list;
// Find buckets by environment
const prodBuckets = buckets.filter(b => b.includes('prod'));
const devBuckets = buckets.filter(b => b.includes('dev'));
console.log(`Production: ${prodBuckets.length}`);
console.log(`Development: ${devBuckets.length}`);
Group by Purpose
const buckets = message.list;
const categories = {
backups: [],
logs: [],
data: [],
other: []
};
buckets.forEach(bucket => {
if (bucket.includes('backup')) categories.backups.push(bucket);
else if (bucket.includes('log')) categories.logs.push(bucket);
else if (bucket.includes('data')) categories.data.push(bucket);
else categories.other.push(bucket);
});
console.log('Buckets by category:', categories);
Find Old Buckets
// Assume naming includes date: "backup-2023-01"
const buckets = message.list;
const oldBuckets = buckets.filter(bucket => {
const year = bucket.match(/\d{4}/);
return year && parseInt(year[0]) < 2024;
});
console.log('Old buckets to review:', oldBuckets);