Show / Hide Table of Contents

Class SourceConfiguration

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

Inheritance
object
SourceConfiguration
Implements
ISourceConfiguration
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: Amazon.CDK.AWS.CloudFront
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class SourceConfiguration : ISourceConfiguration
Syntax (vb)
Public Class SourceConfiguration Implements 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.IAM;
             using Amazon.CDK.AWS.Lambda;
             using Amazon.CDK.AWS.S3;
             using Amazon.CDK.Interfaces.CloudFront;

             Bucket bucket;
             ICloudFrontOriginAccessIdentityRef /* & IGrantable */ cloudFrontOriginAccessIdentityRef;
             IFunctionRef functionRef;
             IKeyGroupRef keyGroupRef;
             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 [] { keyGroupRef },
                     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 = cloudFrontOriginAccessIdentityRef,
                     OriginHeaders = new Dictionary<string, string> {
                         { "originHeadersKey", "originHeaders" }
                     },
                     OriginPath = "originPath",
                     OriginShieldRegion = "originShieldRegion"
                 },
                 OriginShieldRegion = "originShieldRegion",
                 S3OriginSource = new S3OriginConfig {
                     S3BucketSource = bucket,

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

Synopsis

Constructors

SourceConfiguration()

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

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.

Constructors

SourceConfiguration()

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

public SourceConfiguration()
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.IAM;
             using Amazon.CDK.AWS.Lambda;
             using Amazon.CDK.AWS.S3;
             using Amazon.CDK.Interfaces.CloudFront;

             Bucket bucket;
             ICloudFrontOriginAccessIdentityRef /* & IGrantable */ cloudFrontOriginAccessIdentityRef;
             IFunctionRef functionRef;
             IKeyGroupRef keyGroupRef;
             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 [] { keyGroupRef },
                     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 = cloudFrontOriginAccessIdentityRef,
                     OriginHeaders = new Dictionary<string, string> {
                         { "originHeadersKey", "originHeaders" }
                     },
                     OriginPath = "originPath",
                     OriginShieldRegion = "originShieldRegion"
                 },
                 OriginShieldRegion = "originShieldRegion",
                 S3OriginSource = new S3OriginConfig {
                     S3BucketSource = bucket,

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

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 double? ConnectionAttempts { get; set; }
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.

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

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.

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

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

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

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

Implements

ISourceConfiguration
Back to top Generated by DocFX