or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

access-control-security.mdbucket-configuration.mdbucket-operations.mdclient-configuration.mdindex.mdlisting-pagination.mdmultipart-upload.mdobject-operations.mdwaiters-utilities.md
tile.json

bucket-operations.mddocs/

Bucket Operations

Complete bucket management operations including creation, deletion, configuration, and metadata management for Amazon S3 buckets.

Capabilities

Create Buckets

Create new S3 buckets with location constraints and configuration options.

/**
 * Create a new S3 bucket
 */
class CreateBucketCommand {
  constructor(input: CreateBucketCommandInput);
}

interface CreateBucketCommandInput {
  /** Bucket name (must be globally unique) */
  Bucket: string;
  
  /** Bucket permissions */
  ACL?: BucketCannedACL;
  
  /** Bucket location configuration */
  CreateBucketConfiguration?: CreateBucketConfiguration;
  
  /** Grant full control to grantee */
  GrantFullControl?: string;
  
  /** Grant read permission to grantee */
  GrantRead?: string;
  
  /** Grant read ACP permission to grantee */
  GrantReadACP?: string;
  
  /** Grant write permission to grantee */
  GrantWrite?: string;
  
  /** Grant write ACP permission to grantee */
  GrantWriteACP?: string;
  
  /** Enable object lock for bucket */
  ObjectLockEnabledForBucket?: boolean;
  
  /** Object ownership controls */
  ObjectOwnership?: ObjectOwnership;
}

interface CreateBucketConfiguration {
  /** AWS region for the bucket */
  LocationConstraint?: BucketLocationConstraint;
  
  /** Location type for directory buckets */
  Location?: LocationInfo;
  
  /** Bucket information for directory buckets */
  Bucket?: BucketInfo;
}

interface CreateBucketCommandOutput {
  /** Bucket location URL */
  Location?: string;
}

Usage Examples:

import { S3Client, CreateBucketCommand } from "@aws-sdk/client-s3";

const client = new S3Client({ region: "us-east-1" });

// Create basic bucket in default region
const basicBucket = new CreateBucketCommand({
  Bucket: "my-unique-bucket-name-12345"
});
await client.send(basicBucket);

// Create bucket in specific region
const regionalBucket = new CreateBucketCommand({
  Bucket: "eu-bucket-12345",
  CreateBucketConfiguration: {
    LocationConstraint: "eu-west-1"
  }
});
await client.send(regionalBucket);

// Create bucket with object lock enabled
const objectLockBucket = new CreateBucketCommand({
  Bucket: "compliance-bucket-12345",
  ObjectLockEnabledForBucket: true
});
await client.send(objectLockBucket);

// Create bucket with custom ACL
const publicBucket = new CreateBucketCommand({
  Bucket: "public-assets-12345",
  ACL: "public-read"
});
await client.send(publicBucket);

Delete Buckets

Delete empty S3 buckets.

/**
 * Delete an empty S3 bucket
 */
class DeleteBucketCommand {
  constructor(input: DeleteBucketCommandInput);
}

interface DeleteBucketCommandInput {
  /** Bucket name to delete */
  Bucket: string;
  
  /** Expected bucket owner account ID */
  ExpectedBucketOwner?: string;
}

interface DeleteBucketCommandOutput {
  // No output properties
}

Usage Example:

import { S3Client, DeleteBucketCommand } from "@aws-sdk/client-s3";

const client = new S3Client({ region: "us-east-1" });

const deleteBucket = new DeleteBucketCommand({
  Bucket: "bucket-to-delete"
});

try {
  await client.send(deleteBucket);
  console.log("Bucket deleted successfully");
} catch (error) {
  if (error.name === "BucketNotEmpty") {
    console.error("Cannot delete bucket: bucket is not empty");
  } else {
    console.error("Delete failed:", error.message);
  }
}

List Buckets

List all buckets owned by the authenticated account.

/**
 * List all buckets for the account
 */
class ListBucketsCommand {
  constructor(input?: ListBucketsCommandInput);
}

interface ListBucketsCommandInput {
  /** Maximum number of buckets to return */
  MaxBuckets?: number;
  
  /** Continuation token for pagination */
  ContinuationToken?: string;
}

interface ListBucketsCommandOutput {
  /** List of buckets */
  Buckets?: Bucket[];
  
  /** Bucket owner information */
  Owner?: Owner;
  
  /** Continuation token for next page */
  ContinuationToken?: string;
}

interface Bucket {
  /** Bucket name */
  Name?: string;
  
  /** Bucket creation date */
  CreationDate?: Date;
}

Usage Example:

import { S3Client, ListBucketsCommand } from "@aws-sdk/client-s3";

const client = new S3Client({ region: "us-east-1" });

const listBuckets = new ListBucketsCommand({});
const response = await client.send(listBuckets);

console.log("Available buckets:");
response.Buckets?.forEach(bucket => {
  console.log(`- ${bucket.Name} (created: ${bucket.CreationDate})`);
});

List Directory Buckets

List S3 Express One Zone directory buckets.

/**
 * List S3 Express One Zone directory buckets
 */
class ListDirectoryBucketsCommand {  
  constructor(input?: ListDirectoryBucketsCommandInput);
}

interface ListDirectoryBucketsCommandInput {
  /** Continuation token for pagination */
  ContinuationToken?: string;
  
  /** Maximum number of buckets to return */
  MaxDirectoryBuckets?: number;
}

interface ListDirectoryBucketsCommandOutput {
  /** List of directory buckets */
  Buckets?: Bucket[];
  
  /** Continuation token for next page */
  ContinuationToken?: string;
}

Check Bucket Existence

Check if a bucket exists and you have permission to access it.

/**
 * Check if bucket exists and is accessible
 */
class HeadBucketCommand {
  constructor(input: HeadBucketCommandInput);
}

interface HeadBucketCommandInput {
  /** Bucket name to check */
  Bucket: string;
  
  /** Expected bucket owner account ID */
  ExpectedBucketOwner?: string;
}

interface HeadBucketCommandOutput {
  /** Bucket region */
  BucketRegion?: string;
  
  /** Access point alias flag */
  AccessPointAlias?: boolean;
  
  /** Bucket location type */
  BucketLocationType?: LocationType;
  
  /** Bucket location name */
  BucketLocationName?: string;
}

Usage Example:

import { S3Client, HeadBucketCommand } from "@aws-sdk/client-s3";

const client = new S3Client({ region: "us-east-1" });

async function bucketExists(bucketName: string): Promise<boolean> {
  try {
    const headBucket = new HeadBucketCommand({
      Bucket: bucketName
    });
    await client.send(headBucket);
    return true;
  } catch (error) {
    if (error.name === "NotFound") {
      return false;
    }
    throw error; // Re-throw other errors
  }
}

const exists = await bucketExists("my-bucket");
console.log(`Bucket exists: ${exists}`);

Bucket Location

Get the AWS region where a bucket is located.

/**
 * Get the region where a bucket is located
 */
class GetBucketLocationCommand {
  constructor(input: GetBucketLocationCommandInput);
}

interface GetBucketLocationCommandInput {
  /** Bucket name */
  Bucket: string;
  
  /** Expected bucket owner account ID */
  ExpectedBucketOwner?: string;
}

interface GetBucketLocationCommandOutput {
  /** Bucket location constraint (region) */
  LocationConstraint?: BucketLocationConstraint;
}

Usage Example:

import { S3Client, GetBucketLocationCommand } from "@aws-sdk/client-s3";

const client = new S3Client({ region: "us-east-1" });

const getBucketLocation = new GetBucketLocationCommand({
  Bucket: "my-bucket"
});

const location = await client.send(getBucketLocation);
console.log(`Bucket region: ${location.LocationConstraint || "us-east-1"}`);

Common Types

// Bucket canned ACL options
type BucketCannedACL = 
  | "private"
  | "public-read"
  | "public-read-write"
  | "authenticated-read";

// AWS regions for bucket location  
type BucketLocationConstraint =
  | "af-south-1"
  | "ap-east-1"
  | "ap-northeast-1"
  | "ap-northeast-2"
  | "ap-northeast-3"
  | "ap-south-1"
  | "ap-south-2"
  | "ap-southeast-1"
  | "ap-southeast-2"
  | "ap-southeast-3"
  | "ca-central-1"
  | "cn-north-1"
  | "cn-northwest-1"
  | "EU"
  | "eu-central-1"
  | "eu-north-1"
  | "eu-south-1"
  | "eu-west-1"
  | "eu-west-2"
  | "eu-west-3"
  | "me-south-1"
  | "sa-east-1"
  | "us-east-2"
  | "us-gov-east-1"
  | "us-gov-west-1"
  | "us-west-1"
  | "us-west-2";

// Object ownership options
type ObjectOwnership = 
  | "BucketOwnerPreferred"
  | "ObjectWriter"
  | "BucketOwnerEnforced";

// Location types
type LocationType =
  | "AvailabilityZone"
  | "LocalZone"
  | "Outposts"
  | "WavelengthZone";

// Core owner information
interface Owner {
  /** Display name of the owner */
  DisplayName?: string;
  
  /** Canonical user ID */
  ID?: string;
}