1 | import { IResource, Resource } from '@aws-cdk/core';
|
2 | import { Construct } from 'constructs';
|
3 | /**
|
4 | * Represents the function's source code
|
5 | */
|
6 | export declare abstract class FunctionCode {
|
7 | /**
|
8 | * Inline code for function
|
9 | * @returns code object with inline code.
|
10 | * @param code The actual function code
|
11 | */
|
12 | static fromInline(code: string): FunctionCode;
|
13 | /**
|
14 | * Code from external file for function
|
15 | * @returns code object with contents from file.
|
16 | * @param options the options for the external file
|
17 | */
|
18 | static fromFile(options: FileCodeOptions): FunctionCode;
|
19 | /**
|
20 | * renders the function code
|
21 | */
|
22 | abstract render(): string;
|
23 | }
|
24 | /**
|
25 | * Options when reading the function's code from an external file
|
26 | */
|
27 | export interface FileCodeOptions {
|
28 | /**
|
29 | * The path of the file to read the code from
|
30 | */
|
31 | readonly filePath: string;
|
32 | }
|
33 | /**
|
34 | * Represents a CloudFront Function
|
35 | */
|
36 | export interface IFunction extends IResource {
|
37 | /**
|
38 | * The name of the function.
|
39 | * @attribute
|
40 | */
|
41 | readonly functionName: string;
|
42 | /**
|
43 | * The ARN of the function.
|
44 | * @attribute
|
45 | */
|
46 | readonly functionArn: string;
|
47 | }
|
48 | /**
|
49 | * Attributes of an existing CloudFront Function to import it
|
50 | */
|
51 | export interface FunctionAttributes {
|
52 | /**
|
53 | * The name of the function.
|
54 | */
|
55 | readonly functionName: string;
|
56 | /**
|
57 | * The ARN of the function.
|
58 | */
|
59 | readonly functionArn: string;
|
60 | }
|
61 | /**
|
62 | * Properties for creating a CloudFront Function
|
63 | */
|
64 | export interface FunctionProps {
|
65 | /**
|
66 | * A name to identify the function.
|
67 | * @default - generated from the `id`
|
68 | */
|
69 | readonly functionName?: string;
|
70 | /**
|
71 | * A comment to describe the function.
|
72 | * @default - same as `functionName`
|
73 | */
|
74 | readonly comment?: string;
|
75 | /**
|
76 | * The source code of the function.
|
77 | */
|
78 | readonly code: FunctionCode;
|
79 | }
|
80 | /**
|
81 | * A CloudFront Function
|
82 | *
|
83 | * @resource AWS::CloudFront::Function
|
84 | */
|
85 | export declare class Function extends Resource implements IFunction {
|
86 | /** Imports a function by its name and ARN */
|
87 | static fromFunctionAttributes(scope: Construct, id: string, attrs: FunctionAttributes): IFunction;
|
88 | /**
|
89 | * the name of the CloudFront function
|
90 | * @attribute
|
91 | */
|
92 | readonly functionName: string;
|
93 | /**
|
94 | * the ARN of the CloudFront function
|
95 | * @attribute
|
96 | */
|
97 | readonly functionArn: string;
|
98 | /**
|
99 | * the deployment stage of the CloudFront function
|
100 | * @attribute
|
101 | */
|
102 | readonly functionStage: string;
|
103 | constructor(scope: Construct, id: string, props: FunctionProps);
|
104 | private generateName;
|
105 | }
|
106 | /**
|
107 | * The type of events that a CloudFront function can be invoked in response to.
|
108 | */
|
109 | export declare enum FunctionEventType {
|
110 | /**
|
111 | * The viewer-request specifies the incoming request
|
112 | */
|
113 | VIEWER_REQUEST = "viewer-request",
|
114 | /**
|
115 | * The viewer-response specifies the outgoing response
|
116 | */
|
117 | VIEWER_RESPONSE = "viewer-response"
|
118 | }
|
119 | /**
|
120 | * Represents a CloudFront function and event type when using CF Functions.
|
121 | * The type of the {@link AddBehaviorOptions.functionAssociations} property.
|
122 | */
|
123 | export interface FunctionAssociation {
|
124 | /**
|
125 | * The CloudFront function that will be invoked.
|
126 | */
|
127 | readonly function: IFunction;
|
128 | /** The type of event which should invoke the function. */
|
129 | readonly eventType: FunctionEventType;
|
130 | }
|