1 | import { Duration } from '@aws-cdk/core';
|
2 | import { CfnDistribution } from './cloudfront.generated';
|
3 | import { Construct } from '@aws-cdk/core';
|
4 | /**
|
5 | * The failover configuration used for Origin Groups,
|
6 | * returned in {@link OriginBindConfig.failoverConfig}.
|
7 | */
|
8 | export interface OriginFailoverConfig {
|
9 | /** The origin to use as the fallback origin. */
|
10 | readonly failoverOrigin: IOrigin;
|
11 | /**
|
12 | * The HTTP status codes of the response that trigger querying the failover Origin.
|
13 | *
|
14 | * @default - 500, 502, 503 and 504
|
15 | */
|
16 | readonly statusCodes?: number[];
|
17 | }
|
18 | /** The struct returned from {@link IOrigin.bind}. */
|
19 | export interface OriginBindConfig {
|
20 | /**
|
21 | * The CloudFormation OriginProperty configuration for this Origin.
|
22 | *
|
23 | * @default - nothing is returned
|
24 | */
|
25 | readonly originProperty?: CfnDistribution.OriginProperty;
|
26 | /**
|
27 | * The failover configuration for this Origin.
|
28 | *
|
29 | * @default - nothing is returned
|
30 | */
|
31 | readonly failoverConfig?: OriginFailoverConfig;
|
32 | }
|
33 | /**
|
34 | * Represents the concept of a CloudFront Origin.
|
35 | * You provide one or more origins when creating a Distribution.
|
36 | */
|
37 | export interface IOrigin {
|
38 | /**
|
39 | * The method called when a given Origin is added
|
40 | * (for the first time) to a Distribution.
|
41 | */
|
42 | bind(scope: Construct, options: OriginBindOptions): OriginBindConfig;
|
43 | }
|
44 | /**
|
45 | * Options to define an Origin.
|
46 | */
|
47 | export interface OriginOptions {
|
48 | /**
|
49 | * The number of seconds that CloudFront waits when trying to establish a connection to the origin.
|
50 | * Valid values are 1-10 seconds, inclusive.
|
51 | *
|
52 | * @default Duration.seconds(10)
|
53 | */
|
54 | readonly connectionTimeout?: Duration;
|
55 | /**
|
56 | * The number of times that CloudFront attempts to connect to the origin; valid values are 1, 2, or 3 attempts.
|
57 | *
|
58 | * @default 3
|
59 | */
|
60 | readonly connectionAttempts?: number;
|
61 | /**
|
62 | * A list of HTTP header names and values that CloudFront adds to requests it sends to the origin.
|
63 | *
|
64 | * @default {}
|
65 | */
|
66 | readonly customHeaders?: Record<string, string>;
|
67 | /**
|
68 | * When you enable Origin Shield in the AWS Region that has the lowest latency to your origin, you can get better network performance
|
69 | *
|
70 | * @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/origin-shield.html
|
71 | *
|
72 | * @default - origin shield not enabled
|
73 | */
|
74 | readonly originShieldRegion?: string;
|
75 | }
|
76 | /**
|
77 | * Properties to define an Origin.
|
78 | */
|
79 | export interface OriginProps extends OriginOptions {
|
80 | /**
|
81 | * An optional path that CloudFront appends to the origin domain name when CloudFront requests content from the origin.
|
82 | * Must begin, but not end, with '/' (e.g., '/production/images').
|
83 | *
|
84 | * @default '/'
|
85 | */
|
86 | readonly originPath?: string;
|
87 | }
|
88 | /**
|
89 | * Options passed to Origin.bind().
|
90 | */
|
91 | export interface OriginBindOptions {
|
92 | /**
|
93 | * The identifier of this Origin,
|
94 | * as assigned by the Distribution this Origin has been used added to.
|
95 | */
|
96 | readonly originId: string;
|
97 | }
|
98 | /**
|
99 | * Represents a distribution origin, that describes the Amazon S3 bucket, HTTP server (for example, a web server),
|
100 | * Amazon MediaStore, or other server from which CloudFront gets your files.
|
101 | */
|
102 | export declare abstract class OriginBase implements IOrigin {
|
103 | private readonly domainName;
|
104 | private readonly originPath?;
|
105 | private readonly connectionTimeout?;
|
106 | private readonly connectionAttempts?;
|
107 | private readonly customHeaders?;
|
108 | private readonly originShieldRegion?;
|
109 | protected constructor(domainName: string, props?: OriginProps);
|
110 | /**
|
111 | * Binds the origin to the associated Distribution. Can be used to grant permissions, create dependent resources, etc.
|
112 | */
|
113 | bind(_scope: Construct, options: OriginBindOptions): OriginBindConfig;
|
114 | protected renderS3OriginConfig(): CfnDistribution.S3OriginConfigProperty | undefined;
|
115 | protected renderCustomOriginConfig(): CfnDistribution.CustomOriginConfigProperty | undefined;
|
116 | private renderCustomHeaders;
|
117 | /**
|
118 | * If the path is defined, it must start with a '/' and not end with a '/'.
|
119 | * This method takes in the originPath, and returns it back (if undefined) or adds/removes the '/' as appropriate.
|
120 | */
|
121 | private validateOriginPath;
|
122 | /**
|
123 | * Takes origin shield region and converts to CfnDistribution.OriginShieldProperty
|
124 | */
|
125 | private renderOriginShield;
|
126 | }
|