# BucketAttributes

A reference to a bucket outside this stack.

Used as argument in: [Bucket.fromBucketAttributes](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.Bucket.html#frombucketattributes)

- 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#L454)
- Type last changed: v2.277.0 · 13 Nov 2026

## Example

TypeScript:

```ts
// Deploy an imported S3 bucket from a different account
declare const stage: codepipeline.IStage;
declare const input: codepipeline.Artifact;
stage.addAction(new codepipeline_actions.S3DeployAction({
  bucket: s3.Bucket.fromBucketAttributes(this, 'Bucket', {
    account: '123456789012',
    // ...
  }),
  input: input,
  actionName: 's3-deploy-action',
  // ...
}));
```

Python:

```python
# Deploy an imported S3 bucket from a different account
# stage: codepipeline.IStage
# input: codepipeline.Artifact

stage.add_action(codepipeline_actions.S3DeployAction(
    bucket=s3.Bucket.from_bucket_attributes(self, "Bucket",
        account="123456789012"
    ),
    input=input,
    action_name="s3-deploy-action"
))
```

Java:

```java
// Deploy an imported S3 bucket from a different account
IStage stage;
Artifact input;

stage.addAction(S3DeployAction.Builder.create()
        .bucket(Bucket.fromBucketAttributes(this, "Bucket", BucketAttributes.builder()
                .account("123456789012")
                .build()))
        .input(input)
        .actionName("s3-deploy-action")
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// Deploy an imported S3 bucket from a different account
IStage stage;
Artifact input;

stage.AddAction(new S3DeployAction(new S3DeployActionProps {
    Bucket = Bucket.FromBucketAttributes(this, "Bucket", new BucketAttributes {
        Account = "123456789012"
    }),
    Input = input,
    ActionName = "s3-deploy-action"
}));
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Deploy an imported S3 bucket from a different account
var stage IStage
var input Artifact

stage.AddAction(codepipeline_actions.NewS3DeployAction(&S3DeployActionProps{
	Bucket: s3.Bucket_FromBucketAttributes(this, jsii.String("Bucket"), &BucketAttributes{
		Account: jsii.String("123456789012"),
	}),
	Input: input,
	ActionName: jsii.String("s3-deploy-action"),
}))
```

## Properties

- `account`: string — The account this existing bucket belongs to.

  **Default:** it's assumed the bucket belongs to the same account as the scope it's being imported into

- `bucketArn`: string — The ARN of the bucket.

  At least one of bucketArn or bucketName must be
  defined in order to initialize a bucket ref.

- `bucketDomainName`: string — The domain name of the bucket.

  **Default:** Inferred from bucket name

- `bucketDualStackDomainName`: string — The IPv6 DNS name of the specified bucket.

- `bucketName`: string — The name of the bucket.

  If the underlying value of ARN is a string, the
  name will be parsed from the ARN. Otherwise, the name is optional, but
  some features that require the bucket name such as auto-creating a bucket
  policy, won't work.

- `bucketRegionalDomainName`: string — The regional domain name of the specified bucket.

- `bucketWebsiteNewUrlFormat`: boolean — The correct website url format can be inferred automatically from the bucket `region`. Always provide the bucket region if the `bucketWebsiteUrl` will be used. Alternatively provide the full `bucketWebsiteUrl` manually.

  **Default:** inferred from available region information, `false` otherwise

  This should be true for
  regions launched since 2014.

- `bucketWebsiteUrl`: string — The website URL of the bucket (if static web hosting is enabled).

  **Default:** Inferred from bucket name and region

- `encryption`: [BucketEncryption](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.BucketEncryption.html) — The default server-side encryption mode of the imported bucket.

  **Default:** the encryption mode of the imported bucket is unknown

  `UNENCRYPTED` is reported as `S3_MANAGED`, because S3 applies SSE-S3 to every bucket
  that has no default encryption rule.

- `encryptionKey`: [IKey](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_kms.IKey.html) — KMS encryption key associated with this bucket.

  **Default:** no encryption key

- `isWebsite`: boolean = false — If this bucket has been configured for static website hosting.

- `notificationsHandlerRole`: [IRole](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — The role to be used by the notifications handler.

  **Default:** a new role will be created.

- `region`: string — The region this existing bucket is in.

  **Default:** it's assumed the bucket is in the same region as the scope it's being imported into

  Features that require the region (e.g. `bucketWebsiteUrl`) won't fully work
  if the region cannot be correctly inferred.
