aws-cdk-lib.aws_s3.BucketAttributes

interface BucketAttributes

LanguageType name
.NETAmazon.CDK.AWS.S3.BucketAttributes
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awss3#BucketAttributes
Javasoftware.amazon.awscdk.services.s3.BucketAttributes
Pythonaws_cdk.aws_s3.BucketAttributes
TypeScript (source)aws-cdk-lib » aws_s3 » BucketAttributes

A reference to a bucket outside this stack.

Example

declare const myLambda: lambda.Function;
const bucket = s3.Bucket.fromBucketAttributes(this, 'ImportedBucket', {
  bucketArn: 'arn:aws:s3:::my-bucket',
});

// now you can just call methods on the bucket
bucket.addEventNotification(s3.EventType.OBJECT_CREATED, new s3n.LambdaDestination(myLambda), {
  prefix: 'home/myusername/*',
});

Properties

NameTypeDescription
account?stringThe account this existing bucket belongs to.
bucketArn?stringThe ARN of the bucket.
bucketDomainName?stringThe domain name of the bucket.
bucketDualStackDomainName?stringThe IPv6 DNS name of the specified bucket.
bucketName?stringThe name of the bucket.
bucketRegionalDomainName?stringThe regional domain name of the specified bucket.
bucketWebsiteNewUrlFormat?⚠️booleanForce the format of the website URL of the bucket.
bucketWebsiteUrl?stringThe website URL of the bucket (if static web hosting is enabled).
encryptionKey?IKeyKMS encryption key associated with this bucket.
isWebsite?booleanIf this bucket has been configured for static website hosting.
notificationsHandlerRole?IRoleThe role to be used by the notifications handler.
region?stringThe region this existing bucket is in.

account?

Type: string (optional, default: it's assumed the bucket belongs to the same account as the scope it's being imported into)

The account this existing bucket belongs to.


bucketArn?

Type: string (optional)

The ARN of the bucket.

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


bucketDomainName?

Type: string (optional, default: Inferred from bucket name)

The domain name of the bucket.


bucketDualStackDomainName?

Type: string (optional)

The IPv6 DNS name of the specified bucket.


bucketName?

Type: string (optional)

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?

Type: string (optional)

The regional domain name of the specified bucket.


bucketWebsiteNewUrlFormat?⚠️

⚠️ Deprecated: 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.

Type: boolean (optional, default: inferred from available region information, false otherwise)

Force the format of the website URL of the bucket.

This should be true for regions launched since 2014.


bucketWebsiteUrl?

Type: string (optional, default: Inferred from bucket name and region)

The website URL of the bucket (if static web hosting is enabled).


encryptionKey?

Type: IKey (optional, default: no encryption key)

KMS encryption key associated with this bucket.


isWebsite?

Type: boolean (optional, default: false)

If this bucket has been configured for static website hosting.


notificationsHandlerRole?

Type: IRole (optional, default: a new role will be created.)

The role to be used by the notifications handler.


region?

Type: string (optional, default: it's assumed the bucket is in the same region as the scope it's being imported into)

The region this existing bucket is in.

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