Skip to content
v2.278.0

S3BucketOriginWithOAIProps Struct ​

Properties for configuring a S3 origin with OAI.

Example ​

ts
const myBucket = new s3.Bucket(this, 'myBucket');
const myOai = new cloudfront.OriginAccessIdentity(this, 'myOAI', {
  comment: 'My custom OAI'
});
const s3Origin = origins.S3BucketOrigin.withOriginAccessIdentity(myBucket, {
  originAccessIdentity: myOai
});
new cloudfront.Distribution(this, 'myDist', {
  defaultBehavior: {
    origin: s3Origin
  },
});
python
my_bucket = s3.Bucket(self, "myBucket")
my_oai = cloudfront.OriginAccessIdentity(self, "myOAI",
    comment="My custom OAI"
)
s3_origin = origins.S3BucketOrigin.with_origin_access_identity(my_bucket,
    origin_access_identity=my_oai
)
cloudfront.Distribution(self, "myDist",
    default_behavior=cloudfront.BehaviorOptions(
        origin=s3_origin
    )
)
java
Bucket myBucket = new Bucket(this, "myBucket");
OriginAccessIdentity myOai = OriginAccessIdentity.Builder.create(this, "myOAI")
        .comment("My custom OAI")
        .build();
IOrigin s3Origin = S3BucketOrigin.withOriginAccessIdentity(myBucket, S3BucketOriginWithOAIProps.builder()
        .originAccessIdentity(myOai)
        .build());
Distribution.Builder.create(this, "myDist")
        .defaultBehavior(BehaviorOptions.builder()
                .origin(s3Origin)
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
var myBucket = new Bucket(this, "myBucket");
var myOai = new OriginAccessIdentity(this, "myOAI", new OriginAccessIdentityProps {
    Comment = "My custom OAI"
});
var s3Origin = S3BucketOrigin.WithOriginAccessIdentity(myBucket, new S3BucketOriginWithOAIProps {
    OriginAccessIdentity = myOai
});
new Distribution(this, "myDist", new DistributionProps {
    DefaultBehavior = new BehaviorOptions {
        Origin = s3Origin
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
myBucket := s3.NewBucket(this, jsii.String("myBucket"))
myOai := cloudfront.NewOriginAccessIdentity(this, jsii.String("myOAI"), &OriginAccessIdentityProps{
	Comment: jsii.String("My custom OAI"),
})
s3Origin := origins.S3BucketOrigin_WithOriginAccessIdentity(myBucket, &S3BucketOriginWithOAIProps{
	OriginAccessIdentity: myOai,
})
cloudfront.NewDistribution(this, jsii.String("myDist"), &DistributionProps{
	DefaultBehavior: &BehaviorOptions{
		Origin: s3Origin,
	},
})

Properties ​

connectionAttemptsoptionalnumberconnection_attemptsoptionalint | floatconnectionAttemptsoptionalNumberConnectionAttemptsoptionaldoubleConnectionAttemptsoptional*float64 = 3 #
The number of times that CloudFront attempts to connect to the origin;

valid values are 1, 2, or 3 attempts.

connectionTimeoutoptionalDurationconnection_timeoutoptionalDurationconnectionTimeoutoptionalDurationConnectionTimeoutoptionalDurationConnectionTimeoutoptionalDuration = Duration.seconds(10) #
The number of seconds that CloudFront waits when trying to establish a connection to the origin.

Valid values are 1-10 seconds, inclusive.

customHeadersoptional{ [key: string]: string }custom_headersoptionaltyping.Mapping[str, str]customHeadersoptionalMap<String, String>CustomHeadersoptionalIDictionary<string, string>CustomHeadersoptional*map[string]*string = {} #
A list of HTTP header names and values that CloudFront adds to requests it sends to the origin.
originAccessControlIdoptionalstringorigin_access_control_idoptionalstroriginAccessControlIdoptionalStringOriginAccessControlIdoptionalstringOriginAccessControlIdoptional*string #
The unique identifier of an origin access control for this origin.

Default: no origin access control

originAccessIdentityoptionalanyorigin_access_identityoptionalanyoriginAccessIdentityoptionalanyOriginAccessIdentityoptionalanyOriginAccessIdentityoptionalany #
An optional Origin Access Identity.

Default: an Origin Access Identity will be created.

originIdoptionalstringorigin_idoptionalstroriginIdoptionalStringOriginIdoptionalstringOriginIdoptional*string #
A unique identifier for the origin.

Default: an originid will be generated for you

This value must be unique within the distribution.

originPathoptionalstringorigin_pathoptionalstroriginPathoptionalStringOriginPathoptionalstringOriginPathoptional*string = '/' #
An optional path that CloudFront appends to the origin domain name when CloudFront requests content from the origin.

Must begin, but not end, with '/' (e.g., '/production/images').

originShieldEnabledoptionalbooleanorigin_shield_enabledoptionalbooloriginShieldEnabledoptionalBooleanOriginShieldEnabledoptionalboolOriginShieldEnabledoptional*bool = true #
Origin Shield is enabled by setting originShieldRegion to a valid region, after this to disable Origin Shield again you must set this flag to false.
originShieldRegionoptionalstringorigin_shield_regionoptionalstroriginShieldRegionoptionalStringOriginShieldRegionoptionalstringOriginShieldRegionoptional*string #
When you enable Origin Shield in the AWS Region that has the lowest latency to your origin, you can get better network performance.

Default: origin shield not enabled

responseCompletionTimeoutoptionalDurationresponse_completion_timeoutoptionalDurationresponseCompletionTimeoutoptionalDurationResponseCompletionTimeoutoptionalDurationResponseCompletionTimeoutoptionalDuration #
The time that a request from CloudFront to the origin can stay open and wait for a response.

Default: undefined - AWS CloudFront default is not enforcing a maximum value

If the complete response isn't received from the origin by this time, CloudFront ends the connection.

Valid values are 1-3600 seconds, inclusive.