# BucketNamespace

The namespace for the bucket name when using `bucketNamePrefix`.

Determines how CloudFormation generates the unique portion of the bucket name.

- Source: [`aws-s3/lib/bucket.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-s3/lib/bucket.ts#L1811)
- Type last changed: v2.256.0 · 20 May 2026

## Example

TypeScript:

```ts
new s3.Bucket(this, 'MyBucket', {
  bucketNamePrefix: 'my-app',
  bucketNamespace: s3.BucketNamespace.ACCOUNT_REGIONAL,
});
// Resulting bucket name: my-app-123456789012-us-east-1-an
```

Python:

```python
s3.Bucket(self, "MyBucket",
    bucket_name_prefix="my-app",
    bucket_namespace=s3.BucketNamespace.ACCOUNT_REGIONAL
)
```

Java:

```java
Bucket.Builder.create(this, "MyBucket")
        .bucketNamePrefix("my-app")
        .bucketNamespace(BucketNamespace.ACCOUNT_REGIONAL)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
new Bucket(this, "MyBucket", new BucketProps {
    BucketNamePrefix = "my-app",
    BucketNamespace = BucketNamespace.ACCOUNT_REGIONAL
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
s3.NewBucket(this, jsii.String("MyBucket"), &BucketProps{
	BucketNamePrefix: jsii.String("my-app"),
	BucketNamespace: s3.BucketNamespace_ACCOUNT_REGIONAL,
})
```

## Members

| Member | Description |
| --- | --- |
| `GLOBAL` | The bucket name is globally unique. |
| `ACCOUNT_REGIONAL` | The bucket name is unique within the account and region. |

## Referenced by

- [`BucketProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.BucketProps.html).bucketNamespace
