class S3BucketOrigin
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.CloudFront.Origins.S3BucketOrigin |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awscloudfrontorigins#S3BucketOrigin |
Java | software.amazon.awscdk.services.cloudfront.origins.S3BucketOrigin |
Python | aws_cdk.aws_cloudfront_origins.S3BucketOrigin |
TypeScript (source) | aws-cdk-lib » aws_cloudfront_origins » S3BucketOrigin |
Implements
IOrigin
Extends
Origin
A S3 Bucket Origin.
Example
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
new S3BucketOrigin(bucket: IBucket, props?: S3BucketOriginBaseProps)
Parameters
- bucket
IBucket - props
S3Bucket Origin Base Props
Methods
| Name | Description |
|---|---|
| bind(scope, options) | Binds the origin to the associated Distribution. |
| protected render | |
| static with | Create a S3 Origin with default S3 bucket settings (no origin access control). |
| static with | Create a S3 Origin with Origin Access Control (OAC) configured. |
| static with | 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). |
bind(scope, options)
public bind(scope: Construct, options: OriginBindOptions): OriginBindConfig
Parameters
- scope
Construct - options
OriginBind Options
Returns
Binds the origin to the associated Distribution.
Can be used to grant permissions, create dependent resources, etc.
protected renderS3OriginConfig()
protected renderS3OriginConfig(): S3OriginConfigProperty
Returns
static withBucketDefaults(bucket, props?)
public static withBucketDefaults(bucket: IBucket, props?: OriginProps): IOrigin
Parameters
- bucket
IBucket - props
OriginProps
Returns
Create a S3 Origin with default S3 bucket settings (no origin access control).
static withOriginAccessControl(bucket, props?)
public static withOriginAccessControl(bucket: IBucket, props?: S3BucketOriginWithOACProps): IOrigin
Parameters
- bucket
IBucket - props
S3Bucket Origin With OACProps
Returns
Create a S3 Origin with Origin Access Control (OAC) configured.
static withOriginAccessIdentity(bucket, props?)
public static withOriginAccessIdentity(bucket: IBucket, props?: S3BucketOriginWithOAIProps): IOrigin
Parameters
- bucket
IBucket - props
S3Bucket Origin With OAIProps
Returns
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).

.NET
Go
Java
Python
TypeScript (