Interface SourceConfiguration
- All Superinterfaces:
software.amazon.jsii.JsiiSerializable
- All Known Implementing Classes:
SourceConfiguration.Jsii$Proxy
An origin is what CloudFront will "be in front of" - that is, CloudFront will pull it's assets from an origin.
If you're using s3 as a source - pass the s3Origin
property, otherwise, pass the customOriginSource
property.
One or the other must be passed, and it is invalid to pass both in the same SourceConfiguration.
Example:
// The code below shows an example of how to instantiate this type. // The values are placeholders you should change. import software.amazon.awscdk.services.cloudfront.*; import software.amazon.awscdk.services.lambda.*; import software.amazon.awscdk.services.s3.*; import software.amazon.awscdk.core.*; Bucket bucket; Function function_; KeyGroup keyGroup; OriginAccessIdentity originAccessIdentity; Version version; SourceConfiguration sourceConfiguration = SourceConfiguration.builder() .behaviors(List.of(Behavior.builder() .allowedMethods(CloudFrontAllowedMethods.GET_HEAD) .cachedMethods(CloudFrontAllowedCachedMethods.GET_HEAD) .compress(false) .defaultTtl(Duration.minutes(30)) .forwardedValues(ForwardedValuesProperty.builder() .queryString(false) // the properties below are optional .cookies(CookiesProperty.builder() .forward("forward") // the properties below are optional .whitelistedNames(List.of("whitelistedNames")) .build()) .headers(List.of("headers")) .queryStringCacheKeys(List.of("queryStringCacheKeys")) .build()) .functionAssociations(List.of(FunctionAssociation.builder() .eventType(FunctionEventType.VIEWER_REQUEST) .function(function_) .build())) .isDefaultBehavior(false) .lambdaFunctionAssociations(List.of(LambdaFunctionAssociation.builder() .eventType(LambdaEdgeEventType.ORIGIN_REQUEST) .lambdaFunction(version) // the properties below are optional .includeBody(false) .build())) .maxTtl(Duration.minutes(30)) .minTtl(Duration.minutes(30)) .pathPattern("pathPattern") .trustedKeyGroups(List.of(keyGroup)) .trustedSigners(List.of("trustedSigners")) .viewerProtocolPolicy(ViewerProtocolPolicy.HTTPS_ONLY) .build())) // the properties below are optional .connectionAttempts(123) .connectionTimeout(Duration.minutes(30)) .customOriginSource(CustomOriginConfig.builder() .domainName("domainName") // the properties below are optional .allowedOriginSSLVersions(List.of(OriginSslPolicy.SSL_V3)) .httpPort(123) .httpsPort(123) .originHeaders(Map.of( "originHeadersKey", "originHeaders")) .originKeepaliveTimeout(Duration.minutes(30)) .originPath("originPath") .originProtocolPolicy(OriginProtocolPolicy.HTTP_ONLY) .originReadTimeout(Duration.minutes(30)) .originShieldRegion("originShieldRegion") .build()) .failoverCriteriaStatusCodes(List.of(FailoverStatusCode.FORBIDDEN)) .failoverCustomOriginSource(CustomOriginConfig.builder() .domainName("domainName") // the properties below are optional .allowedOriginSSLVersions(List.of(OriginSslPolicy.SSL_V3)) .httpPort(123) .httpsPort(123) .originHeaders(Map.of( "originHeadersKey", "originHeaders")) .originKeepaliveTimeout(Duration.minutes(30)) .originPath("originPath") .originProtocolPolicy(OriginProtocolPolicy.HTTP_ONLY) .originReadTimeout(Duration.minutes(30)) .originShieldRegion("originShieldRegion") .build()) .failoverS3OriginSource(S3OriginConfig.builder() .s3BucketSource(bucket) // the properties below are optional .originAccessIdentity(originAccessIdentity) .originHeaders(Map.of( "originHeadersKey", "originHeaders")) .originPath("originPath") .originShieldRegion("originShieldRegion") .build()) .originHeaders(Map.of( "originHeadersKey", "originHeaders")) .originPath("originPath") .originShieldRegion("originShieldRegion") .s3OriginSource(S3OriginConfig.builder() .s3BucketSource(bucket) // the properties below are optional .originAccessIdentity(originAccessIdentity) .originHeaders(Map.of( "originHeadersKey", "originHeaders")) .originPath("originPath") .originShieldRegion("originShieldRegion") .build()) .build();
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic final class
A builder forSourceConfiguration
static final class
An implementation forSourceConfiguration
-
Method Summary
Modifier and TypeMethodDescriptionstatic SourceConfiguration.Builder
builder()
The behaviors associated with this source.default Number
The number of times that CloudFront attempts to connect to the origin.default Duration
The number of seconds that CloudFront waits when trying to establish a connection to the origin.default CustomOriginConfig
A custom origin source - for all non-s3 sources.default List<FailoverStatusCode>
HTTP status code to failover to second origin.default CustomOriginConfig
A custom origin source for failover in case the s3OriginSource returns invalid status code.default S3OriginConfig
An s3 origin source for failover in case the s3OriginSource returns invalid status code.Deprecated.Use originHeaders on s3OriginSource or customOriginSourcedefault String
Deprecated.Use originPath on s3OriginSource or customOriginSourcedefault 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 S3OriginConfig
An s3 origin source - if you're using s3 for your assets.Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Method Details
-
getBehaviors
The behaviors associated with this source.At least one (default) behavior must be included.
-
getConnectionAttempts
The number of times that CloudFront attempts to connect to the origin.You can specify 1, 2, or 3 as the number of attempts.
Default: 3
-
getConnectionTimeout
The number of seconds that CloudFront waits when trying to establish a connection to the origin.You can specify a number of seconds between 1 and 10 (inclusive).
Default: cdk.Duration.seconds(10)
-
getCustomOriginSource
A custom origin source - for all non-s3 sources. -
getFailoverCriteriaStatusCodes
HTTP status code to failover to second origin.Default: [500, 502, 503, 504]
-
getFailoverCustomOriginSource
A custom origin source for failover in case the s3OriginSource returns invalid status code.Default: - no failover configuration
-
getFailoverS3OriginSource
An s3 origin source for failover in case the s3OriginSource returns invalid status code.Default: - no failover configuration
-
getOriginHeaders
Deprecated.Use originHeaders on s3OriginSource or customOriginSource(deprecated) Any additional headers to pass to the origin.Default: - No additional headers are passed.
-
getOriginPath
Deprecated.Use originPath on s3OriginSource or customOriginSource(deprecated) The relative path to the origin root to use for sources.Default: /
-
getOriginShieldRegion
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
- See Also:
-
getS3OriginSource
An s3 origin source - if you're using s3 for your assets. -
builder
- Returns:
- a
SourceConfiguration.Builder
ofSourceConfiguration
-