UNPKG

4.54 kBTypeScriptView Raw
1import * as iam from '@aws-cdk/aws-iam';
2import { Duration, IResource, Resource } from '@aws-cdk/core';
3import { Construct } from 'constructs';
4import { IFunction } from './function-base';
5/**
6 * The auth types for a function url
7 */
8export declare enum FunctionUrlAuthType {
9 /**
10 * Restrict access to authenticated IAM users only
11 */
12 AWS_IAM = "AWS_IAM",
13 /**
14 * Bypass IAM authentication to create a public endpoint
15 */
16 NONE = "NONE"
17}
18/**
19 * All http request methods
20 */
21export declare enum HttpMethod {
22 /**
23 * The GET method requests a representation of the specified resource.
24 */
25 GET = "GET",
26 /**
27 * The PUT method replaces all current representations of the target resource with the request payload.
28 */
29 PUT = "PUT",
30 /**
31 * The HEAD method asks for a response identical to that of a GET request, but without the response body.
32 */
33 HEAD = "HEAD",
34 /**
35 * The POST method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server.
36 */
37 POST = "POST",
38 /**
39 * The DELETE method deletes the specified resource.
40 */
41 DELETE = "DELETE",
42 /**
43 * The PATCH method applies partial modifications to a resource.
44 */
45 PATCH = "PATCH",
46 /**
47 * The OPTIONS method describes the communication options for the target resource.
48 */
49 OPTIONS = "OPTIONS",
50 /**
51 * The wildcard entry to allow all methods.
52 */
53 ALL = "*"
54}
55/**
56 * Specifies a cross-origin access property for a function URL
57 */
58export interface FunctionUrlCorsOptions {
59 /**
60 * Whether to allow cookies or other credentials in requests to your function URL.
61 *
62 * @default false
63 */
64 readonly allowCredentials?: boolean;
65 /**
66 * Headers that are specified in the Access-Control-Request-Headers header.
67 *
68 * @default - No headers allowed.
69 */
70 readonly allowedHeaders?: string[];
71 /**
72 * An HTTP method that you allow the origin to execute.
73 *
74 * @default - [HttpMethod.ALL]
75 */
76 readonly allowedMethods?: HttpMethod[];
77 /**
78 * One or more origins you want customers to be able to access the bucket from.
79 *
80 * @default - No origins allowed.
81 */
82 readonly allowedOrigins?: string[];
83 /**
84 * One or more headers in the response that you want customers to be able to access from their applications.
85 *
86 * @default - No headers exposed.
87 */
88 readonly exposedHeaders?: string[];
89 /**
90 * The time in seconds that your browser is to cache the preflight response for the specified resource.
91 *
92 * @default - Browser default of 5 seconds.
93 */
94 readonly maxAge?: Duration;
95}
96/**
97 * A Lambda function Url
98 */
99export interface IFunctionUrl extends IResource {
100 /**
101 * The url of the Lambda function.
102 *
103 * @attribute FunctionUrl
104 */
105 readonly url: string;
106 /**
107 * The ARN of the function this URL refers to
108 *
109 * @attribute FunctionArn
110 */
111 readonly functionArn: string;
112 /**
113 * Grant the given identity permissions to invoke this Lambda Function URL
114 */
115 grantInvokeUrl(identity: iam.IGrantable): iam.Grant;
116}
117/**
118 * Options to add a url to a Lambda function
119 */
120export interface FunctionUrlOptions {
121 /**
122 * The type of authentication that your function URL uses.
123 *
124 * @default FunctionUrlAuthType.AWS_IAM
125 */
126 readonly authType?: FunctionUrlAuthType;
127 /**
128 * The cross-origin resource sharing (CORS) settings for your function URL.
129 *
130 * @default - No CORS configuration.
131 */
132 readonly cors?: FunctionUrlCorsOptions;
133}
134/**
135 * Properties for a FunctionUrl
136 */
137export interface FunctionUrlProps extends FunctionUrlOptions {
138 /**
139 * The function to which this url refers.
140 * It can also be an `Alias` but not a `Version`.
141 */
142 readonly function: IFunction;
143}
144/**
145 * Defines a Lambda function url
146 *
147 * @resource AWS::Lambda::Url
148 */
149export declare class FunctionUrl extends Resource implements IFunctionUrl {
150 /**
151 * The url of the Lambda function.
152 */
153 readonly url: string;
154 /**
155 * The ARN of the function this URL refers to
156 */
157 readonly functionArn: string;
158 private readonly function;
159 constructor(scope: Construct, id: string, props: FunctionUrlProps);
160 grantInvokeUrl(grantee: iam.IGrantable): iam.Grant;
161 private instanceOfVersion;
162 private instanceOfAlias;
163 private renderCors;
164}