214 lines
7.5 KiB
TypeScript
214 lines
7.5 KiB
TypeScript
import type { Construct } from 'constructs';
|
|
import type { CfnDistribution } from './cloudfront.generated';
|
|
import type { Duration } from '../../core';
|
|
/**
|
|
* The selection criteria for the origin group.
|
|
*/
|
|
export declare enum OriginSelectionCriteria {
|
|
/**
|
|
* Default selection behavior.
|
|
*/
|
|
DEFAULT = "default",
|
|
/**
|
|
* Selection based on media quality.
|
|
*
|
|
* This option is only valid for AWS Elemental MediaPackage v2 Origins.
|
|
*/
|
|
MEDIA_QUALITY_BASED = "media-quality-based"
|
|
}
|
|
/**
|
|
* The IP address type for the origin.
|
|
* Determines whether CloudFront uses IPv4, IPv6, or both when connecting to the origin.
|
|
*/
|
|
export declare enum OriginIpAddressType {
|
|
/**
|
|
* Use only IPv4 addresses
|
|
*/
|
|
IPV4 = "ipv4",
|
|
/**
|
|
* Use only IPv6 addresses
|
|
*/
|
|
IPV6 = "ipv6",
|
|
/**
|
|
* Use both IPv4 and IPv6 addresses
|
|
*/
|
|
DUALSTACK = "dualstack"
|
|
}
|
|
/**
|
|
* The failover configuration used for Origin Groups,
|
|
* returned in `OriginBindConfig.failoverConfig`.
|
|
*/
|
|
export interface OriginFailoverConfig {
|
|
/** The origin to use as the fallback origin. */
|
|
readonly failoverOrigin: IOrigin;
|
|
/**
|
|
* The HTTP status codes of the response that trigger querying the failover Origin.
|
|
*
|
|
* @default - 500, 502, 503 and 504
|
|
*/
|
|
readonly statusCodes?: number[];
|
|
}
|
|
/** The struct returned from `IOrigin.bind`. */
|
|
export interface OriginBindConfig {
|
|
/**
|
|
* The CloudFormation OriginProperty configuration for this Origin.
|
|
*
|
|
* @default - nothing is returned
|
|
*/
|
|
readonly originProperty?: CfnDistribution.OriginProperty;
|
|
/**
|
|
* The failover configuration for this Origin.
|
|
*
|
|
* @default - nothing is returned
|
|
*/
|
|
readonly failoverConfig?: OriginFailoverConfig;
|
|
/**
|
|
* The selection criteria for how your origins are selected.
|
|
*
|
|
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/high_availability_origin_failover.html#concept_origin_groups.creating
|
|
*
|
|
* @default - OriginSelectionCriteria.DEFAULT
|
|
*/
|
|
readonly selectionCriteria?: OriginSelectionCriteria;
|
|
}
|
|
/**
|
|
* Represents the concept of a CloudFront Origin.
|
|
* You provide one or more origins when creating a Distribution.
|
|
*/
|
|
export interface IOrigin {
|
|
/**
|
|
* The method called when a given Origin is added
|
|
* (for the first time) to a Distribution.
|
|
*/
|
|
bind(scope: Construct, options: OriginBindOptions): OriginBindConfig;
|
|
}
|
|
/**
|
|
* Options to define an Origin.
|
|
*/
|
|
export interface OriginOptions {
|
|
/**
|
|
* The number of seconds that CloudFront waits when trying to establish a connection to the origin.
|
|
* Valid values are 1-10 seconds, inclusive.
|
|
*
|
|
* @default Duration.seconds(10)
|
|
*/
|
|
readonly connectionTimeout?: Duration;
|
|
/**
|
|
* The number of times that CloudFront attempts to connect to the origin; valid values are 1, 2, or 3 attempts.
|
|
*
|
|
* @default 3
|
|
*/
|
|
readonly connectionAttempts?: number;
|
|
/**
|
|
* A list of HTTP header names and values that CloudFront adds to requests it sends to the origin.
|
|
*
|
|
* @default {}
|
|
*/
|
|
readonly customHeaders?: Record<string, string>;
|
|
/**
|
|
* When you enable Origin Shield in the AWS Region that has the lowest latency to your origin, you can get better network performance
|
|
*
|
|
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/origin-shield.html
|
|
*
|
|
* @default - origin shield not enabled
|
|
*/
|
|
readonly originShieldRegion?: string;
|
|
/**
|
|
* 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.
|
|
*
|
|
* @default - true
|
|
*/
|
|
readonly originShieldEnabled?: boolean;
|
|
/**
|
|
* A unique identifier for the origin. This value must be unique within the distribution.
|
|
*
|
|
* @default - an originid will be generated for you
|
|
*/
|
|
readonly originId?: string;
|
|
/**
|
|
* The unique identifier of an origin access control for this origin.
|
|
*
|
|
* @default - no origin access control
|
|
*/
|
|
readonly originAccessControlId?: string;
|
|
/**
|
|
* The time that a request from CloudFront to the origin can stay open and wait for a response.
|
|
*
|
|
* If the complete response isn't received from the origin by this time, CloudFront ends the connection.
|
|
*
|
|
* Valid values are 1-3600 seconds, inclusive.
|
|
*
|
|
* @default undefined - AWS CloudFront default is not enforcing a maximum value
|
|
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DownloadDistValuesOrigin.html#response-completion-timeout
|
|
*/
|
|
readonly responseCompletionTimeout?: Duration;
|
|
}
|
|
/**
|
|
* Properties to define an Origin.
|
|
*/
|
|
export interface OriginProps extends OriginOptions {
|
|
/**
|
|
* 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').
|
|
*
|
|
* @default '/'
|
|
*/
|
|
readonly originPath?: string;
|
|
}
|
|
/**
|
|
* Options passed to Origin.bind().
|
|
*/
|
|
export interface OriginBindOptions {
|
|
/**
|
|
* The identifier of this Origin,
|
|
* as assigned by the Distribution this Origin has been used added to.
|
|
*/
|
|
readonly originId: string;
|
|
/**
|
|
* The identifier of the Distribution this Origin is used for.
|
|
* This is used to grant origin access permissions to the distribution for origin access control.
|
|
*
|
|
* @default - no distribution id
|
|
*/
|
|
readonly distributionId?: string;
|
|
}
|
|
/**
|
|
* Represents a distribution origin, that describes the Amazon S3 bucket, HTTP server (for example, a web server),
|
|
* Amazon MediaStore, or other server from which CloudFront gets your files.
|
|
*/
|
|
export declare abstract class OriginBase implements IOrigin {
|
|
private readonly domainName;
|
|
private readonly originPath?;
|
|
private readonly connectionTimeout?;
|
|
private readonly connectionAttempts?;
|
|
private readonly customHeaders?;
|
|
private readonly originShieldRegion?;
|
|
private readonly originShieldEnabled;
|
|
private readonly originId?;
|
|
private readonly originAccessControlId?;
|
|
private readonly responseCompletionTimeout?;
|
|
protected constructor(domainName: string, props?: OriginProps);
|
|
/**
|
|
* Validates that responseCompletionTimeout is greater than or equal to readTimeout
|
|
* when both are specified. This method should be called by subclasses that support readTimeout.
|
|
*/
|
|
protected validateResponseCompletionTimeoutWithReadTimeout(responseCompletionTimeout?: Duration, readTimeout?: Duration): void;
|
|
/**
|
|
* Binds the origin to the associated Distribution. Can be used to grant permissions, create dependent resources, etc.
|
|
*/
|
|
bind(scope: Construct, options: OriginBindOptions): OriginBindConfig;
|
|
protected renderS3OriginConfig(): CfnDistribution.S3OriginConfigProperty | undefined;
|
|
protected renderCustomOriginConfig(): CfnDistribution.CustomOriginConfigProperty | undefined;
|
|
protected renderVpcOriginConfig(): CfnDistribution.VpcOriginConfigProperty | undefined;
|
|
private renderCustomHeaders;
|
|
/**
|
|
* If the path is defined, it must start with a '/' and not end with a '/'.
|
|
* This method takes in the originPath, and returns it back (if undefined) or adds/removes the '/' as appropriate.
|
|
*/
|
|
private validateOriginPath;
|
|
/**
|
|
* Takes origin shield region and converts to CfnDistribution.OriginShieldProperty
|
|
*/
|
|
private renderOriginShield;
|
|
}
|