Skip to content
v2.275.0

S3BucketOrigin Class ​

A S3 Bucket Origin.

Example ​

ts
import * as kms from 'aws-cdk-lib/aws-kms';

const myKmsKey = new kms.Key(this, 'myKMSKey');
const myBucket = new s3.Bucket(this, 'mySSEKMSEncryptedBucket', {
  encryption: s3.BucketEncryption.KMS,
  encryptionKey: myKmsKey,
  objectOwnership: s3.ObjectOwnership.BUCKET_OWNER_ENFORCED,
});
new cloudfront.Distribution(this, 'myDist', {
  defaultBehavior: {
    origin: origins.S3BucketOrigin.withOriginAccessControl(myBucket) // Automatically grants Distribution access to `myKmsKey`
  },
});

Initializer ​

ts
new S3BucketOrigin(bucket: IBucket, props?: S3BucketOriginBaseProps)
python
S3BucketOrigin(bucket: IBucket, props: typing.Optional[S3BucketOriginBaseProps] = None)
java
new S3BucketOrigin(IBucket bucket, S3BucketOriginBaseProps props)
csharp
new S3BucketOrigin(IBucket bucket, S3BucketOriginBaseProps? props = null)
go
NewS3BucketOrigin(Bucket IBucket, Props S3BucketOriginBaseProps)

Methods ​

bind(scope: Construct, options: OriginBindOptions): OriginBindConfigdef bind(self, scope: Construct, options: OriginBindOptions) -> OriginBindConfigpublic OriginBindConfig bind(Construct scope, OriginBindOptions options)public OriginBindConfig Bind(Construct scope, OriginBindOptions options)func Bind(Scope Construct, Options OriginBindOptions) OriginBindConfig#
Binds the origin to the associated Distribution.

Can be used to grant permissions, create dependent resources, etc.

withBucketDefaults(bucket: IBucket, props?: OriginProps): IOrigin@staticmethod def with_bucket_defaults(bucket: IBucket, props: typing.Optional[OriginProps] = None) -> IOriginpublic static IOrigin withBucketDefaults(IBucket bucket, OriginProps props)public static IOrigin WithBucketDefaults(IBucket bucket, OriginProps? props = null)func WithBucketDefaults(Bucket IBucket, Props OriginProps) IOriginstatic#
Create a S3 Origin with default S3 bucket settings (no origin access control).
withOriginAccessControl(bucket: IBucket, props?: S3BucketOriginWithOACProps): IOrigin@staticmethod def with_origin_access_control(bucket: IBucket, props: typing.Optional[S3BucketOriginWithOACProps] = None) -> IOriginpublic static IOrigin withOriginAccessControl(IBucket bucket, S3BucketOriginWithOACProps props)public static IOrigin WithOriginAccessControl(IBucket bucket, S3BucketOriginWithOACProps? props = null)func WithOriginAccessControl(Bucket IBucket, Props S3BucketOriginWithOACProps) IOriginstatic#
Create a S3 Origin with Origin Access Control (OAC) configured.
withOriginAccessIdentity(bucket: IBucket, props?: S3BucketOriginWithOAIProps): IOrigin@staticmethod def with_origin_access_identity(bucket: IBucket, props: typing.Optional[S3BucketOriginWithOAIProps] = None) -> IOriginpublic static IOrigin withOriginAccessIdentity(IBucket bucket, S3BucketOriginWithOAIProps props)public static IOrigin WithOriginAccessIdentity(IBucket bucket, S3BucketOriginWithOAIProps? props = null)func WithOriginAccessIdentity(Bucket IBucket, Props S3BucketOriginWithOAIProps) IOriginstatic#
Create a S3 Origin with Origin Access Identity (OAI) configured OAI is a legacy feature and we **strongly** recommend you to use OAC via `withOriginAccessControl()` unless it is not supported in your required region (e.g. China regions).