aws-cdk-lib.aws_cloudfront_origins.S3Origin

class S3Origin

LanguageType name
.NETAmazon.CDK.AWS.CloudFront.Origins.S3Origin
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscloudfrontorigins#S3Origin
Javasoftware.amazon.awscdk.services.cloudfront.origins.S3Origin
Pythonaws_cdk.aws_cloudfront_origins.S3Origin
TypeScript (source)aws-cdk-lib » aws_cloudfront_origins » S3Origin

Implements IOrigin

An Origin that is backed by an S3 bucket.

If the bucket is configured for website hosting, this origin will be configured to use the bucket as an HTTP server origin and will use the bucket's configured website redirects and error handling. Otherwise, the origin is created as a bucket origin and will use CloudFront's redirect and error handling.

Example

// Adding an existing Lambda@Edge function created in a different stack
// to a CloudFront distribution.
declare const s3Bucket: s3.Bucket;
const functionVersion = lambda.Version.fromVersionArn(this, 'Version', 'arn:aws:lambda:us-east-1:123456789012:function:functionName:1');

new cloudfront.Distribution(this, 'distro', {
  defaultBehavior: {
    origin: new origins.S3Origin(s3Bucket),
    edgeLambdas: [
      {
        functionVersion,
        eventType: cloudfront.LambdaEdgeEventType.VIEWER_REQUEST,
      },
    ],
  },
});

Initializer

new S3Origin(bucket: IBucket, props?: S3OriginProps)

Parameters

  • bucket IBucket
  • props S3OriginProps

Methods

NameDescription
bind(scope, options)The method called when a given Origin is added (for the first time) to a Distribution.

bind(scope, options)

public bind(scope: Construct, options: OriginBindOptions): OriginBindConfig

Parameters

  • scope Construct
  • options OriginBindOptions

Returns

  • OriginBindConfig

The method called when a given Origin is added (for the first time) to a Distribution.