Show / Hide Table of Contents

Class SourceConfiguration

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

Inheritance
System.Object
SourceConfiguration
Implements
ISourceConfiguration
Namespace: Amazon.CDK.AWS.CloudFront
Assembly: Amazon.CDK.AWS.CloudFront.dll
Syntax (csharp)
public class SourceConfiguration : Object, ISourceConfiguration
Syntax (vb)
Public Class SourceConfiguration
    Inherits Object
    Implements ISourceConfiguration
Remarks

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.

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.AWS.CloudFront;
using Amazon.CDK.AWS.Lambda;
using Amazon.CDK.AWS.S3;
using Amazon.CDK;

Bucket bucket;
Function function_;
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 = function_
        } },
        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"
    },
    OriginHeaders = new Dictionary<string, string> {
        { "originHeadersKey", "originHeaders" }
    },
    OriginPath = "originPath",
    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

Constructors

SourceConfiguration()

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.

OriginHeaders

(deprecated) Any additional headers to pass to the origin.

OriginPath

(deprecated) The relative path to the origin root to use for sources.

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.

Constructors

SourceConfiguration()

public SourceConfiguration()

Properties

Behaviors

The behaviors associated with this source.

public IBehavior[] Behaviors { get; set; }
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.

public Nullable<double> ConnectionAttempts { get; set; }
Property Value

System.Nullable<System.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.

public Duration ConnectionTimeout { get; set; }
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.

public ICustomOriginConfig CustomOriginSource { get; set; }
Property Value

ICustomOriginConfig

FailoverCriteriaStatusCodes

HTTP status code to failover to second origin.

public FailoverStatusCode[] FailoverCriteriaStatusCodes { get; set; }
Property Value

FailoverStatusCode[]

Remarks

Default: [500, 502, 503, 504]

FailoverCustomOriginSource

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

public ICustomOriginConfig FailoverCustomOriginSource { get; set; }
Property Value

ICustomOriginConfig

Remarks

Default: - no failover configuration

FailoverS3OriginSource

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

public IS3OriginConfig FailoverS3OriginSource { get; set; }
Property Value

IS3OriginConfig

Remarks

Default: - no failover configuration

OriginHeaders

(deprecated) Any additional headers to pass to the origin.

public IDictionary<string, string> OriginHeaders { get; set; }
Property Value

System.Collections.Generic.IDictionary<System.String, System.String>

Remarks

Default: - No additional headers are passed.

Stability: Deprecated

OriginPath

(deprecated) The relative path to the origin root to use for sources.

public string OriginPath { get; set; }
Property Value

System.String

Remarks

Default: /

Stability: Deprecated

OriginShieldRegion

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

public string OriginShieldRegion { get; set; }
Property Value

System.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.

public IS3OriginConfig S3OriginSource { get; set; }
Property Value

IS3OriginConfig

Implements

ISourceConfiguration
Back to top Generated by DocFX