Show / Hide Table of Contents

Interface ISourceConfiguration

A source configuration is a wrapper for CloudFront origins and behaviors.

Namespace: Amazon.CDK.AWS.CloudFront
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public interface ISourceConfiguration
Syntax (vb)
Public Interface ISourceConfiguration
Remarks

An origin is what CloudFront will "be in front of" - that is, CloudFront will pull its 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.

ExampleMetadata: fixture=_generated

Examples
// The code below shows an example of how to instantiate this type.
             // The values are placeholders you should change.
             using Amazon.CDK;
             using Amazon.CDK.AWS.CloudFront;
             using Amazon.CDK.AWS.Lambda;
             using Amazon.CDK.AWS.S3;

             Bucket bucket;
             IFunctionRef functionRef;
             KeyGroup keyGroup;
             OriginAccessIdentity originAccessIdentity;
             Version version;

             var sourceConfiguration = new SourceConfiguration {
                 Behaviors = new [] { new Behavior {
                     AllowedMethods = CloudFrontAllowedMethods.GET_HEAD,
                     CachedMethods = CloudFrontAllowedCachedMethods.GET_HEAD,
                     Compress = false,
                     DefaultTtl = Duration.Minutes(30),
                     ForwardedValues = new ForwardedValuesProperty {
                         QueryString = false,

                         // the properties below are optional
                         Cookies = new CookiesProperty {
                             Forward = "forward",

                             // the properties below are optional
                             WhitelistedNames = new [] { "whitelistedNames" }
                         },
                         Headers = new [] { "headers" },
                         QueryStringCacheKeys = new [] { "queryStringCacheKeys" }
                     },
                     FunctionAssociations = new [] { new FunctionAssociation {
                         EventType = FunctionEventType.VIEWER_REQUEST,
                         Function = functionRef
                     } },
                     IsDefaultBehavior = false,
                     LambdaFunctionAssociations = new [] { new LambdaFunctionAssociation {
                         EventType = LambdaEdgeEventType.ORIGIN_REQUEST,
                         LambdaFunction = version,

                         // the properties below are optional
                         IncludeBody = false
                     } },
                     MaxTtl = Duration.Minutes(30),
                     MinTtl = Duration.Minutes(30),
                     PathPattern = "pathPattern",
                     TrustedKeyGroups = new [] { keyGroup },
                     TrustedSigners = new [] { "trustedSigners" },
                     ViewerProtocolPolicy = ViewerProtocolPolicy.HTTPS_ONLY
                 } },

                 // the properties below are optional
                 ConnectionAttempts = 123,
                 ConnectionTimeout = Duration.Minutes(30),
                 CustomOriginSource = new CustomOriginConfig {
                     DomainName = "domainName",

                     // the properties below are optional
                     AllowedOriginSSLVersions = new [] { OriginSslPolicy.SSL_V3 },
                     HttpPort = 123,
                     HttpsPort = 123,
                     OriginHeaders = new Dictionary<string, string> {
                         { "originHeadersKey", "originHeaders" }
                     },
                     OriginKeepaliveTimeout = Duration.Minutes(30),
                     OriginPath = "originPath",
                     OriginProtocolPolicy = OriginProtocolPolicy.HTTP_ONLY,
                     OriginReadTimeout = Duration.Minutes(30),
                     OriginShieldRegion = "originShieldRegion"
                 },
                 FailoverCriteriaStatusCodes = new [] { FailoverStatusCode.FORBIDDEN },
                 FailoverCustomOriginSource = new CustomOriginConfig {
                     DomainName = "domainName",

                     // the properties below are optional
                     AllowedOriginSSLVersions = new [] { OriginSslPolicy.SSL_V3 },
                     HttpPort = 123,
                     HttpsPort = 123,
                     OriginHeaders = new Dictionary<string, string> {
                         { "originHeadersKey", "originHeaders" }
                     },
                     OriginKeepaliveTimeout = Duration.Minutes(30),
                     OriginPath = "originPath",
                     OriginProtocolPolicy = OriginProtocolPolicy.HTTP_ONLY,
                     OriginReadTimeout = Duration.Minutes(30),
                     OriginShieldRegion = "originShieldRegion"
                 },
                 FailoverS3OriginSource = new S3OriginConfig {
                     S3BucketSource = bucket,

                     // the properties below are optional
                     OriginAccessIdentity = originAccessIdentity,
                     OriginHeaders = new Dictionary<string, string> {
                         { "originHeadersKey", "originHeaders" }
                     },
                     OriginPath = "originPath",
                     OriginShieldRegion = "originShieldRegion"
                 },
                 OriginShieldRegion = "originShieldRegion",
                 S3OriginSource = new S3OriginConfig {
                     S3BucketSource = bucket,

                     // the properties below are optional
                     OriginAccessIdentity = originAccessIdentity,
                     OriginHeaders = new Dictionary<string, string> {
                         { "originHeadersKey", "originHeaders" }
                     },
                     OriginPath = "originPath",
                     OriginShieldRegion = "originShieldRegion"
                 }
             };

Synopsis

Properties

Behaviors

The behaviors associated with this source.

ConnectionAttempts

The number of times that CloudFront attempts to connect to the origin.

ConnectionTimeout

The number of seconds that CloudFront waits when trying to establish a connection to the origin.

CustomOriginSource

A custom origin source - for all non-s3 sources.

FailoverCriteriaStatusCodes

HTTP status code to failover to second origin.

FailoverCustomOriginSource

A custom origin source for failover in case the s3OriginSource returns invalid status code.

FailoverS3OriginSource

An s3 origin source for failover in case the s3OriginSource returns invalid status code.

OriginShieldRegion

When you enable Origin Shield in the AWS Region that has the lowest latency to your origin, you can get better network performance.

S3OriginSource

An s3 origin source - if you're using s3 for your assets.

Properties

Behaviors

The behaviors associated with this source.

IBehavior[] Behaviors { get; }
Property Value

IBehavior[]

Remarks

At least one (default) behavior must be included.

ConnectionAttempts

The number of times that CloudFront attempts to connect to the origin.

double? ConnectionAttempts { get; }
Property Value

double?

Remarks

You can specify 1, 2, or 3 as the number of attempts.

Default: 3

ConnectionTimeout

The number of seconds that CloudFront waits when trying to establish a connection to the origin.

Duration? ConnectionTimeout { get; }
Property Value

Duration

Remarks

You can specify a number of seconds between 1 and 10 (inclusive).

Default: cdk.Duration.seconds(10)

CustomOriginSource

A custom origin source - for all non-s3 sources.

ICustomOriginConfig? CustomOriginSource { get; }
Property Value

ICustomOriginConfig

Remarks

An origin is what CloudFront will "be in front of" - that is, CloudFront will pull its 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.

ExampleMetadata: fixture=_generated

FailoverCriteriaStatusCodes

HTTP status code to failover to second origin.

FailoverStatusCode[]? FailoverCriteriaStatusCodes { get; }
Property Value

FailoverStatusCode[]

Remarks

Default: [500, 502, 503, 504]

FailoverCustomOriginSource

A custom origin source for failover in case the s3OriginSource returns invalid status code.

ICustomOriginConfig? FailoverCustomOriginSource { get; }
Property Value

ICustomOriginConfig

Remarks

Default: - no failover configuration

FailoverS3OriginSource

An s3 origin source for failover in case the s3OriginSource returns invalid status code.

IS3OriginConfig? FailoverS3OriginSource { get; }
Property Value

IS3OriginConfig

Remarks

Default: - no failover configuration

OriginShieldRegion

When you enable Origin Shield in the AWS Region that has the lowest latency to your origin, you can get better network performance.

string? OriginShieldRegion { get; }
Property Value

string

Remarks

Default: - origin shield not enabled

See: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/origin-shield.html

S3OriginSource

An s3 origin source - if you're using s3 for your assets.

IS3OriginConfig? S3OriginSource { get; }
Property Value

IS3OriginConfig

Remarks

An origin is what CloudFront will "be in front of" - that is, CloudFront will pull its 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.

ExampleMetadata: fixture=_generated

Back to top Generated by DocFX