sst 2.1.31 → 2.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constructs/Api.d.ts +22 -22
- package/constructs/Api.js +34 -37
- package/constructs/App.d.ts +9 -8
- package/constructs/App.js +22 -22
- package/constructs/AppSyncApi.d.ts +17 -17
- package/constructs/AppSyncApi.js +6 -6
- package/constructs/Bucket.d.ts +5 -5
- package/constructs/Bucket.js +14 -14
- package/constructs/Cognito.d.ts +10 -10
- package/constructs/Cognito.js +31 -33
- package/constructs/Function.d.ts +37 -37
- package/constructs/Function.js +57 -58
- package/constructs/Topic.d.ts +7 -7
- package/constructs/Topic.js +6 -6
- package/credentials.js +1 -2
- package/iot.js +42 -14
- package/node/future/auth/handler.js +10 -1
- package/package.json +1 -1
- package/sst.mjs +959 -932
- package/support/base-site-archiver.mjs +16 -16
- package/support/bridge/bridge.mjs +70 -45
- package/support/ssr-site-function-archiver.mjs +15 -15
package/constructs/Api.d.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
|
-
import * as acm from "aws-cdk-lib/aws-certificatemanager";
|
|
3
|
-
import * as apig from "@aws-cdk/aws-apigatewayv2-alpha";
|
|
4
|
-
import * as apigAuthorizers from "@aws-cdk/aws-apigatewayv2-authorizers-alpha";
|
|
5
2
|
import { HttpUrlIntegrationProps, HttpAlbIntegrationProps, HttpNlbIntegrationProps } from "@aws-cdk/aws-apigatewayv2-integrations-alpha";
|
|
6
|
-
import * as elb from "aws-cdk-lib/aws-elasticloadbalancingv2";
|
|
7
|
-
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
8
|
-
import * as logs from "aws-cdk-lib/aws-logs";
|
|
9
3
|
import { HttpAwsIntegrationProps } from "./cdk/HttpAwsIntegration.js";
|
|
10
4
|
import { SSTConstruct } from "./Construct.js";
|
|
11
5
|
import { Function as Fn, FunctionProps, FunctionInlineDefinition, FunctionDefinition } from "./Function.js";
|
|
@@ -15,6 +9,12 @@ import { Permissions } from "./util/permission.js";
|
|
|
15
9
|
import * as apigV2Cors from "./util/apiGatewayV2Cors.js";
|
|
16
10
|
import * as apigV2Domain from "./util/apiGatewayV2Domain.js";
|
|
17
11
|
import * as apigV2AccessLog from "./util/apiGatewayV2AccessLog.js";
|
|
12
|
+
import { DomainName, HttpApi, HttpApiProps, HttpRouteIntegration, HttpStageProps, IHttpApi } from "@aws-cdk/aws-apigatewayv2-alpha";
|
|
13
|
+
import { HttpJwtAuthorizer, HttpLambdaAuthorizer, HttpLambdaResponseType, HttpUserPoolAuthorizer } from "@aws-cdk/aws-apigatewayv2-authorizers-alpha";
|
|
14
|
+
import { IFunction } from "aws-cdk-lib/aws-lambda";
|
|
15
|
+
import { IApplicationListener, INetworkListener } from "aws-cdk-lib/aws-elasticloadbalancingv2";
|
|
16
|
+
import { LogGroup } from "aws-cdk-lib/aws-logs";
|
|
17
|
+
import { Certificate } from "aws-cdk-lib/aws-certificatemanager";
|
|
18
18
|
declare const PayloadFormatVersions: readonly ["1.0", "2.0"];
|
|
19
19
|
export type ApiPayloadFormatVersion = (typeof PayloadFormatVersions)[number];
|
|
20
20
|
export interface CdkHttpAwsIntegrationProps extends HttpAwsIntegrationProps {
|
|
@@ -72,7 +72,7 @@ export interface ApiUserPoolAuthorizer extends ApiBaseAuthorizer {
|
|
|
72
72
|
/**
|
|
73
73
|
* This allows you to override the default settings this construct uses internally to create the authorizer.
|
|
74
74
|
*/
|
|
75
|
-
authorizer:
|
|
75
|
+
authorizer: HttpUserPoolAuthorizer;
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
@@ -112,7 +112,7 @@ export interface ApiJwtAuthorizer extends ApiBaseAuthorizer {
|
|
|
112
112
|
/**
|
|
113
113
|
* This allows you to override the default settings this construct uses internally to create the authorizer.
|
|
114
114
|
*/
|
|
115
|
-
authorizer:
|
|
115
|
+
authorizer: HttpJwtAuthorizer;
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
@@ -147,7 +147,7 @@ export interface ApiLambdaAuthorizer extends ApiBaseAuthorizer {
|
|
|
147
147
|
* If `simple` is included then response format 2.0 will be used.
|
|
148
148
|
* @default ["iam"]
|
|
149
149
|
*/
|
|
150
|
-
responseTypes?: Lowercase<keyof typeof
|
|
150
|
+
responseTypes?: Lowercase<keyof typeof HttpLambdaResponseType>[];
|
|
151
151
|
/**
|
|
152
152
|
* The amount of time the results are cached.
|
|
153
153
|
* @default Not cached
|
|
@@ -157,7 +157,7 @@ export interface ApiLambdaAuthorizer extends ApiBaseAuthorizer {
|
|
|
157
157
|
/**
|
|
158
158
|
* This allows you to override the default settings this construct uses internally to create the authorizer.
|
|
159
159
|
*/
|
|
160
|
-
authorizer:
|
|
160
|
+
authorizer: HttpLambdaAuthorizer;
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
163
|
export interface ApiCorsProps extends apigV2Cors.CorsProps {
|
|
@@ -374,7 +374,7 @@ export interface ApiProps<Authorizers extends Record<string, ApiAuthorizer> = Re
|
|
|
374
374
|
* });
|
|
375
375
|
* ```
|
|
376
376
|
*/
|
|
377
|
-
httpApi?:
|
|
377
|
+
httpApi?: IHttpApi | HttpApiProps;
|
|
378
378
|
/**
|
|
379
379
|
* Configures the stages to create for the HTTP API.
|
|
380
380
|
*
|
|
@@ -394,7 +394,7 @@ export interface ApiProps<Authorizers extends Record<string, ApiAuthorizer> = Re
|
|
|
394
394
|
* });
|
|
395
395
|
* ```
|
|
396
396
|
*/
|
|
397
|
-
httpStages?: Omit<
|
|
397
|
+
httpStages?: Omit<HttpStageProps, "httpApi">[];
|
|
398
398
|
};
|
|
399
399
|
}
|
|
400
400
|
export type ApiRouteProps<AuthorizerKeys> = FunctionInlineDefinition | ApiFunctionRouteProps<AuthorizerKeys> | ApiAwsRouteProps<AuthorizerKeys> | ApiHttpRouteProps<AuthorizerKeys> | ApiAlbRouteProps<AuthorizerKeys> | ApiNlbRouteProps<AuthorizerKeys> | ApiGraphQLRouteProps<AuthorizerKeys>;
|
|
@@ -432,7 +432,7 @@ export interface ApiFunctionRouteProps<AuthorizersKeys = string> extends ApiBase
|
|
|
432
432
|
/**
|
|
433
433
|
* Use an existing Lambda function.
|
|
434
434
|
*/
|
|
435
|
-
function?:
|
|
435
|
+
function?: IFunction;
|
|
436
436
|
};
|
|
437
437
|
}
|
|
438
438
|
/**
|
|
@@ -516,7 +516,7 @@ export interface ApiAlbRouteProps<AuthorizersKeys> extends ApiBaseRouteProps<Aut
|
|
|
516
516
|
/**
|
|
517
517
|
* The listener to the application load balancer used for the integration.
|
|
518
518
|
*/
|
|
519
|
-
albListener:
|
|
519
|
+
albListener: IApplicationListener;
|
|
520
520
|
integration?: HttpAlbIntegrationProps;
|
|
521
521
|
};
|
|
522
522
|
}
|
|
@@ -541,7 +541,7 @@ export interface ApiNlbRouteProps<AuthorizersKeys> extends ApiBaseRouteProps<Aut
|
|
|
541
541
|
/**
|
|
542
542
|
* The listener to the application load balancer used for the integration.
|
|
543
543
|
*/
|
|
544
|
-
nlbListener:
|
|
544
|
+
nlbListener: INetworkListener;
|
|
545
545
|
integration?: HttpNlbIntegrationProps;
|
|
546
546
|
};
|
|
547
547
|
}
|
|
@@ -613,19 +613,19 @@ export declare class Api<Authorizers extends Record<string, ApiAuthorizer> = Rec
|
|
|
613
613
|
/**
|
|
614
614
|
* The internally created CDK HttpApi instance.
|
|
615
615
|
*/
|
|
616
|
-
httpApi:
|
|
616
|
+
httpApi: HttpApi;
|
|
617
617
|
/**
|
|
618
618
|
* If access logs are enabled, this is the internally created CDK LogGroup instance.
|
|
619
619
|
*/
|
|
620
|
-
accessLogGroup?:
|
|
620
|
+
accessLogGroup?: LogGroup;
|
|
621
621
|
/**
|
|
622
622
|
* If custom domain is enabled, this is the internally created CDK DomainName instance.
|
|
623
623
|
*/
|
|
624
|
-
domainName?:
|
|
624
|
+
domainName?: DomainName;
|
|
625
625
|
/**
|
|
626
626
|
* If custom domain is enabled, this is the internally created CDK Certificate instance.
|
|
627
627
|
*/
|
|
628
|
-
certificate?:
|
|
628
|
+
certificate?: Certificate;
|
|
629
629
|
};
|
|
630
630
|
private props;
|
|
631
631
|
private _customDomainUrl?;
|
|
@@ -784,9 +784,9 @@ export declare class Api<Authorizers extends Record<string, ApiAuthorizer> = Rec
|
|
|
784
784
|
private createHttpIntegration;
|
|
785
785
|
private createAlbIntegration;
|
|
786
786
|
private createNlbIntegration;
|
|
787
|
-
protected createGraphQLIntegration(scope: Construct, routeKey: string, routeProps: ApiGraphQLRouteProps<keyof Authorizers>, postfixName: string):
|
|
788
|
-
protected createCdkFunctionIntegration(
|
|
789
|
-
protected createFunctionIntegration(scope: Construct, routeKey: string, routeProps: ApiFunctionRouteProps<keyof Authorizers>, postfixName: string):
|
|
787
|
+
protected createGraphQLIntegration(scope: Construct, routeKey: string, routeProps: ApiGraphQLRouteProps<keyof Authorizers>, postfixName: string): HttpRouteIntegration;
|
|
788
|
+
protected createCdkFunctionIntegration(_scope: Construct, routeKey: string, routeProps: ApiFunctionRouteProps<keyof Authorizers>, postfixName: string): HttpRouteIntegration;
|
|
789
|
+
protected createFunctionIntegration(scope: Construct, routeKey: string, routeProps: ApiFunctionRouteProps<keyof Authorizers>, postfixName: string): HttpRouteIntegration;
|
|
790
790
|
private buildRouteAuth;
|
|
791
791
|
private normalizeRouteKey;
|
|
792
792
|
/**
|
package/constructs/Api.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
|
-
import * as cdkLib from "aws-cdk-lib";
|
|
3
|
-
import * as cognito from "aws-cdk-lib/aws-cognito";
|
|
4
2
|
import { Role, ServicePrincipal, PolicyDocument, PolicyStatement, } from "aws-cdk-lib/aws-iam";
|
|
5
|
-
import * as apig from "@aws-cdk/aws-apigatewayv2-alpha";
|
|
6
|
-
import * as apigAuthorizers from "@aws-cdk/aws-apigatewayv2-authorizers-alpha";
|
|
7
3
|
import { HttpUrlIntegration, HttpAlbIntegration, HttpNlbIntegration, HttpLambdaIntegration, } from "@aws-cdk/aws-apigatewayv2-integrations-alpha";
|
|
8
4
|
import { HttpAwsIntegration, } from "./cdk/HttpAwsIntegration.js";
|
|
9
5
|
import { Stack } from "./Stack.js";
|
|
@@ -13,6 +9,9 @@ import { toCdkDuration } from "./util/duration.js";
|
|
|
13
9
|
import * as apigV2Cors from "./util/apiGatewayV2Cors.js";
|
|
14
10
|
import * as apigV2Domain from "./util/apiGatewayV2Domain.js";
|
|
15
11
|
import * as apigV2AccessLog from "./util/apiGatewayV2AccessLog.js";
|
|
12
|
+
import { HttpApi, HttpMethod, HttpNoneAuthorizer, HttpRoute, HttpRouteKey, HttpStage, IntegrationCredentials, PayloadFormatVersion, } from "@aws-cdk/aws-apigatewayv2-alpha";
|
|
13
|
+
import { HttpIamAuthorizer, HttpJwtAuthorizer, HttpLambdaAuthorizer, HttpLambdaResponseType, HttpUserPoolAuthorizer, } from "@aws-cdk/aws-apigatewayv2-authorizers-alpha";
|
|
14
|
+
import { UserPool, UserPoolClient } from "aws-cdk-lib/aws-cognito";
|
|
16
15
|
const PayloadFormatVersions = ["1.0", "2.0"];
|
|
17
16
|
/////////////////////
|
|
18
17
|
// Construct
|
|
@@ -61,7 +60,7 @@ export class Api extends Construct {
|
|
|
61
60
|
*/
|
|
62
61
|
get url() {
|
|
63
62
|
const app = this.node.root;
|
|
64
|
-
return this.cdk.httpApi instanceof
|
|
63
|
+
return this.cdk.httpApi instanceof HttpApi
|
|
65
64
|
? this.cdk.httpApi.apiEndpoint
|
|
66
65
|
: `https://${this.cdk.httpApi.apiId}.execute-api.${app.region}.amazonaws.com`;
|
|
67
66
|
}
|
|
@@ -289,8 +288,7 @@ export class Api extends Construct {
|
|
|
289
288
|
this.cdk.domainName = customDomainData.apigDomain;
|
|
290
289
|
}
|
|
291
290
|
if (customDomainData.isCertificatedCreated) {
|
|
292
|
-
this.cdk.certificate =
|
|
293
|
-
customDomainData.certificate;
|
|
291
|
+
this.cdk.certificate = customDomainData.certificate;
|
|
294
292
|
}
|
|
295
293
|
defaultDomainMapping = {
|
|
296
294
|
domainName: customDomainData.apigDomain,
|
|
@@ -298,7 +296,7 @@ export class Api extends Construct {
|
|
|
298
296
|
};
|
|
299
297
|
this._customDomainUrl = `https://${customDomainData.url}`;
|
|
300
298
|
}
|
|
301
|
-
this.cdk.httpApi = new
|
|
299
|
+
this.cdk.httpApi = new HttpApi(this, "Api", {
|
|
302
300
|
apiName: app.logicalPrefixedName(id),
|
|
303
301
|
corsPreflight: apigV2Cors.buildCorsConfig(cors),
|
|
304
302
|
defaultDomainMapping,
|
|
@@ -316,7 +314,7 @@ export class Api extends Construct {
|
|
|
316
314
|
}
|
|
317
315
|
// Configure access log
|
|
318
316
|
for (const def of cdk?.httpStages || []) {
|
|
319
|
-
const stage = new
|
|
317
|
+
const stage = new HttpStage(this, "Stage" + def.stageName, {
|
|
320
318
|
...def,
|
|
321
319
|
httpApi: this.cdk.httpApi,
|
|
322
320
|
});
|
|
@@ -342,16 +340,15 @@ export class Api extends Construct {
|
|
|
342
340
|
if (!value.userPool) {
|
|
343
341
|
throw new Error(`Missing "userPool" for "${key}" authorizer`);
|
|
344
342
|
}
|
|
345
|
-
const userPool =
|
|
343
|
+
const userPool = UserPool.fromUserPoolId(this, `Api-${this.node.id}-Authorizer-${key}-UserPool`, value.userPool.id);
|
|
346
344
|
const userPoolClients = value.userPool.clientIds &&
|
|
347
|
-
value.userPool.clientIds.map((clientId, i) =>
|
|
348
|
-
this.authorizersData[key] =
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
});
|
|
345
|
+
value.userPool.clientIds.map((clientId, i) => UserPoolClient.fromUserPoolClientId(this, `Api-${this.node.id}-Authorizer-${key}-UserPoolClient-${i}`, clientId));
|
|
346
|
+
this.authorizersData[key] = new HttpUserPoolAuthorizer(key, userPool, {
|
|
347
|
+
authorizerName: value.name,
|
|
348
|
+
identitySource: value.identitySource,
|
|
349
|
+
userPoolClients,
|
|
350
|
+
userPoolRegion: value.userPool.region,
|
|
351
|
+
});
|
|
355
352
|
}
|
|
356
353
|
}
|
|
357
354
|
else if (value.type === "jwt") {
|
|
@@ -362,7 +359,7 @@ export class Api extends Construct {
|
|
|
362
359
|
if (!value.jwt) {
|
|
363
360
|
throw new Error(`Missing "jwt" for "${key}" authorizer`);
|
|
364
361
|
}
|
|
365
|
-
this.authorizersData[key] = new
|
|
362
|
+
this.authorizersData[key] = new HttpJwtAuthorizer(key, value.jwt.issuer, {
|
|
366
363
|
authorizerName: value.name,
|
|
367
364
|
identitySource: value.identitySource,
|
|
368
365
|
jwtAudience: value.jwt.audience,
|
|
@@ -377,14 +374,14 @@ export class Api extends Construct {
|
|
|
377
374
|
if (!value.function) {
|
|
378
375
|
throw new Error(`Missing "function" for "${key}" authorizer`);
|
|
379
376
|
}
|
|
380
|
-
this.authorizersData[key] = new
|
|
377
|
+
this.authorizersData[key] = new HttpLambdaAuthorizer(key, value.function, {
|
|
381
378
|
authorizerName: value.name,
|
|
382
379
|
identitySource: value.identitySource,
|
|
383
380
|
responseTypes: value.responseTypes &&
|
|
384
|
-
value.responseTypes.map((type) =>
|
|
381
|
+
value.responseTypes.map((type) => HttpLambdaResponseType[type.toUpperCase()]),
|
|
385
382
|
resultsCacheTtl: value.resultsCacheTtl
|
|
386
383
|
? toCdkDuration(value.resultsCacheTtl)
|
|
387
|
-
:
|
|
384
|
+
: toCdkDuration("0 seconds"),
|
|
388
385
|
});
|
|
389
386
|
}
|
|
390
387
|
}
|
|
@@ -407,7 +404,7 @@ export class Api extends Construct {
|
|
|
407
404
|
let path;
|
|
408
405
|
if (routeKey === "$default") {
|
|
409
406
|
postfixName = "default";
|
|
410
|
-
httpRouteKey =
|
|
407
|
+
httpRouteKey = HttpRouteKey.DEFAULT;
|
|
411
408
|
method = "ANY";
|
|
412
409
|
path = routeKey;
|
|
413
410
|
}
|
|
@@ -417,7 +414,7 @@ export class Api extends Construct {
|
|
|
417
414
|
throw new Error(`Invalid route ${routeKey}`);
|
|
418
415
|
}
|
|
419
416
|
method = routeKeyParts[0].toUpperCase();
|
|
420
|
-
if (!
|
|
417
|
+
if (!HttpMethod[method]) {
|
|
421
418
|
throw new Error(`Invalid method defined for "${routeKey}"`);
|
|
422
419
|
}
|
|
423
420
|
path = routeKeyParts[1];
|
|
@@ -425,7 +422,7 @@ export class Api extends Construct {
|
|
|
425
422
|
throw new Error(`Invalid path defined for "${routeKey}"`);
|
|
426
423
|
}
|
|
427
424
|
postfixName = `${method}_${path}`;
|
|
428
|
-
httpRouteKey =
|
|
425
|
+
httpRouteKey = HttpRouteKey.with(path, HttpMethod[method]);
|
|
429
426
|
}
|
|
430
427
|
///////////////////
|
|
431
428
|
// Create route
|
|
@@ -487,7 +484,7 @@ export class Api extends Construct {
|
|
|
487
484
|
throw new Error(`Invalid route type "${routeValue.type}" for "${routeKey}".`);
|
|
488
485
|
})();
|
|
489
486
|
const { authorizationType, authorizer, authorizationScopes } = this.buildRouteAuth(routeProps);
|
|
490
|
-
const route = new
|
|
487
|
+
const route = new HttpRoute(scope, `Route_${postfixName}`, {
|
|
491
488
|
httpApi: this.cdk.httpApi,
|
|
492
489
|
routeKey: httpRouteKey,
|
|
493
490
|
integration,
|
|
@@ -536,7 +533,7 @@ export class Api extends Construct {
|
|
|
536
533
|
// Create integration
|
|
537
534
|
const integration = new HttpAwsIntegration(`Integration_${postfixName}`, {
|
|
538
535
|
...routeProps.cdk.integration,
|
|
539
|
-
credentials:
|
|
536
|
+
credentials: IntegrationCredentials.fromRole(role),
|
|
540
537
|
});
|
|
541
538
|
// Store route
|
|
542
539
|
this.routesData[routeKey] = {
|
|
@@ -544,7 +541,7 @@ export class Api extends Construct {
|
|
|
544
541
|
};
|
|
545
542
|
return integration;
|
|
546
543
|
}
|
|
547
|
-
createHttpIntegration(
|
|
544
|
+
createHttpIntegration(_scope, routeKey, routeProps, postfixName) {
|
|
548
545
|
///////////////////
|
|
549
546
|
// Create integration
|
|
550
547
|
///////////////////
|
|
@@ -556,7 +553,7 @@ export class Api extends Construct {
|
|
|
556
553
|
};
|
|
557
554
|
return integration;
|
|
558
555
|
}
|
|
559
|
-
createAlbIntegration(
|
|
556
|
+
createAlbIntegration(_scope, routeKey, routeProps, postfixName) {
|
|
560
557
|
///////////////////
|
|
561
558
|
// Create integration
|
|
562
559
|
///////////////////
|
|
@@ -568,7 +565,7 @@ export class Api extends Construct {
|
|
|
568
565
|
};
|
|
569
566
|
return integration;
|
|
570
567
|
}
|
|
571
|
-
createNlbIntegration(
|
|
568
|
+
createNlbIntegration(_scope, routeKey, routeProps, postfixName) {
|
|
572
569
|
///////////////////
|
|
573
570
|
// Create integration
|
|
574
571
|
///////////////////
|
|
@@ -598,7 +595,7 @@ export class Api extends Construct {
|
|
|
598
595
|
}
|
|
599
596
|
return result;
|
|
600
597
|
}
|
|
601
|
-
createCdkFunctionIntegration(
|
|
598
|
+
createCdkFunctionIntegration(_scope, routeKey, routeProps, postfixName) {
|
|
602
599
|
///////////////////
|
|
603
600
|
// Get payload format
|
|
604
601
|
///////////////////
|
|
@@ -609,8 +606,8 @@ export class Api extends Construct {
|
|
|
609
606
|
throw new Error(`PayloadFormatVersion: sst.Api does not currently support ${payloadFormatVersion} payload format version. Only "V1" and "V2" are currently supported.`);
|
|
610
607
|
}
|
|
611
608
|
const integrationPayloadFormatVersion = payloadFormatVersion === "1.0"
|
|
612
|
-
?
|
|
613
|
-
:
|
|
609
|
+
? PayloadFormatVersion.VERSION_1_0
|
|
610
|
+
: PayloadFormatVersion.VERSION_2_0;
|
|
614
611
|
///////////////////
|
|
615
612
|
// Create Function
|
|
616
613
|
///////////////////
|
|
@@ -639,8 +636,8 @@ export class Api extends Construct {
|
|
|
639
636
|
throw new Error(`PayloadFormatVersion: sst.Api does not currently support ${payloadFormatVersion} payload format version. Only "V1" and "V2" are currently supported.`);
|
|
640
637
|
}
|
|
641
638
|
const integrationPayloadFormatVersion = payloadFormatVersion === "1.0"
|
|
642
|
-
?
|
|
643
|
-
:
|
|
639
|
+
? PayloadFormatVersion.VERSION_1_0
|
|
640
|
+
: PayloadFormatVersion.VERSION_2_0;
|
|
644
641
|
///////////////////
|
|
645
642
|
// Create Function
|
|
646
643
|
///////////////////
|
|
@@ -675,13 +672,13 @@ export class Api extends Construct {
|
|
|
675
672
|
if (authorizerKey === "none") {
|
|
676
673
|
return {
|
|
677
674
|
authorizationType: "none",
|
|
678
|
-
authorizer: new
|
|
675
|
+
authorizer: new HttpNoneAuthorizer(),
|
|
679
676
|
};
|
|
680
677
|
}
|
|
681
678
|
else if (authorizerKey === "iam") {
|
|
682
679
|
return {
|
|
683
680
|
authorizationType: "iam",
|
|
684
|
-
authorizer: new
|
|
681
|
+
authorizer: new HttpIamAuthorizer(),
|
|
685
682
|
};
|
|
686
683
|
}
|
|
687
684
|
if (!this.props.authorizers ||
|
package/constructs/App.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
1
|
+
import { Stack } from "./Stack.js";
|
|
3
2
|
import { SSTConstruct } from "./Construct.js";
|
|
4
3
|
import { FunctionProps } from "./Function.js";
|
|
5
4
|
import { Permissions } from "./util/permission.js";
|
|
6
5
|
import { StackProps } from "./Stack.js";
|
|
7
6
|
import { FunctionalStack } from "./FunctionalStack.js";
|
|
7
|
+
import { AppProps as CDKAppProps, App as CDKApp, Stack as CDKStack, RemovalPolicy } from "aws-cdk-lib";
|
|
8
|
+
import { ILayerVersion } from "aws-cdk-lib/aws-lambda";
|
|
8
9
|
/**
|
|
9
10
|
* @internal
|
|
10
11
|
*/
|
|
@@ -38,12 +39,12 @@ export interface AppDeployProps {
|
|
|
38
39
|
readonly debugIncreaseTimeout?: boolean;
|
|
39
40
|
readonly mode: "deploy" | "dev" | "remove";
|
|
40
41
|
}
|
|
41
|
-
type AppRemovalPolicy = Lowercase<
|
|
42
|
-
export type AppProps =
|
|
42
|
+
type AppRemovalPolicy = Lowercase<RemovalPolicy>;
|
|
43
|
+
export type AppProps = CDKAppProps;
|
|
43
44
|
/**
|
|
44
45
|
* The App construct extends cdk.App and is used internally by SST.
|
|
45
46
|
*/
|
|
46
|
-
export declare class App extends
|
|
47
|
+
export declare class App extends CDKApp {
|
|
47
48
|
/**
|
|
48
49
|
* Whether or not the app is running locally under `sst start`
|
|
49
50
|
*/
|
|
@@ -83,7 +84,7 @@ export declare class App extends cdk.App {
|
|
|
83
84
|
/** @internal */
|
|
84
85
|
readonly appPath: string;
|
|
85
86
|
/** @internal */
|
|
86
|
-
defaultFunctionProps: (FunctionProps | ((stack:
|
|
87
|
+
defaultFunctionProps: (FunctionProps | ((stack: Stack) => FunctionProps))[];
|
|
87
88
|
private _defaultRemovalPolicy?;
|
|
88
89
|
/** @internal */
|
|
89
90
|
get defaultRemovalPolicy(): "destroy" | "retain" | "snapshot" | undefined;
|
|
@@ -137,7 +138,7 @@ export declare class App extends cdk.App {
|
|
|
137
138
|
* })
|
|
138
139
|
* ```
|
|
139
140
|
*/
|
|
140
|
-
setDefaultFunctionProps(props: FunctionProps | ((stack:
|
|
141
|
+
setDefaultFunctionProps(props: FunctionProps | ((stack: CDKStack) => FunctionProps)): void;
|
|
141
142
|
/**
|
|
142
143
|
* Adds additional default Permissions to be applied to all Lambda functions in the app.
|
|
143
144
|
*
|
|
@@ -170,7 +171,7 @@ export declare class App extends cdk.App {
|
|
|
170
171
|
/**
|
|
171
172
|
* Adds additional default layers to be applied to all Lambda functions in the stack.
|
|
172
173
|
*/
|
|
173
|
-
addDefaultFunctionLayers(layers:
|
|
174
|
+
addDefaultFunctionLayers(layers: ILayerVersion[]): void;
|
|
174
175
|
private isFinished;
|
|
175
176
|
finish(): Promise<void>;
|
|
176
177
|
isRunningSSTTest(): boolean;
|
package/constructs/App.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
|
-
import * as cdk from "aws-cdk-lib";
|
|
4
|
-
import * as s3 from "aws-cdk-lib/aws-s3";
|
|
5
|
-
import * as iam from "aws-cdk-lib/aws-iam";
|
|
6
|
-
import * as logs from "aws-cdk-lib/aws-logs";
|
|
7
|
-
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
8
3
|
import { Stack } from "./Stack.js";
|
|
9
4
|
import { isSSTConstruct, isStackConstruct, } from "./Construct.js";
|
|
10
5
|
import { Function } from "./Function.js";
|
|
@@ -17,6 +12,11 @@ import { AppContext } from "./context.js";
|
|
|
17
12
|
import { useProject } from "../project.js";
|
|
18
13
|
import { Logger } from "../logger.js";
|
|
19
14
|
import { SiteEnv } from "../site-env.js";
|
|
15
|
+
import { App as CDKApp, Tags, CfnResource, RemovalPolicy, CustomResourceProvider, CustomResourceProviderRuntime, CustomResource, Aspects, } from "aws-cdk-lib";
|
|
16
|
+
import { CfnFunction } from "aws-cdk-lib/aws-lambda";
|
|
17
|
+
import { Bucket } from "aws-cdk-lib/aws-s3";
|
|
18
|
+
import { ArnPrincipal, PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
19
|
+
import { CfnLogGroup } from "aws-cdk-lib/aws-logs";
|
|
20
20
|
const require = createRequire(import.meta.url);
|
|
21
21
|
function exitWithMessage(message) {
|
|
22
22
|
console.error(message);
|
|
@@ -25,7 +25,7 @@ function exitWithMessage(message) {
|
|
|
25
25
|
/**
|
|
26
26
|
* The App construct extends cdk.App and is used internally by SST.
|
|
27
27
|
*/
|
|
28
|
-
export class App extends
|
|
28
|
+
export class App extends CDKApp {
|
|
29
29
|
/**
|
|
30
30
|
* Whether or not the app is running locally under `sst start`
|
|
31
31
|
*/
|
|
@@ -217,8 +217,8 @@ export class App extends cdk.App {
|
|
|
217
217
|
for (const child of this.node.children) {
|
|
218
218
|
if (isStackConstruct(child)) {
|
|
219
219
|
// Tag stacks
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
Tags.of(child).add("sst:app", this.name);
|
|
221
|
+
Tags.of(child).add("sst:stage", this.stage);
|
|
222
222
|
// Set removal policy
|
|
223
223
|
if (this._defaultRemovalPolicy)
|
|
224
224
|
this.applyRemovalPolicy(child, this._defaultRemovalPolicy);
|
|
@@ -257,7 +257,7 @@ export class App extends cdk.App {
|
|
|
257
257
|
bindParameters(c);
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
|
|
260
|
+
Aspects.of(this).add(new CreateSsmParameters());
|
|
261
261
|
}
|
|
262
262
|
buildConstructsMetadata() {
|
|
263
263
|
const constructs = this.buildConstructsMetadata_collectConstructs(this);
|
|
@@ -302,22 +302,22 @@ export class App extends cdk.App {
|
|
|
302
302
|
].filter((c) => Boolean(c));
|
|
303
303
|
}
|
|
304
304
|
applyRemovalPolicy(current, policy) {
|
|
305
|
-
if (current instanceof
|
|
306
|
-
current.applyRemovalPolicy(
|
|
305
|
+
if (current instanceof CfnResource) {
|
|
306
|
+
current.applyRemovalPolicy(RemovalPolicy[policy.toUpperCase()]);
|
|
307
307
|
}
|
|
308
308
|
// Had to copy this in to enable deleting objects in bucket
|
|
309
309
|
// https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-s3/lib/bucket.ts#L1910
|
|
310
|
-
if (current instanceof
|
|
310
|
+
if (current instanceof Bucket &&
|
|
311
311
|
!current.node.tryFindChild("AutoDeleteObjectsCustomResource")) {
|
|
312
312
|
const AUTO_DELETE_OBJECTS_RESOURCE_TYPE = "Custom::S3AutoDeleteObjects";
|
|
313
|
-
const provider =
|
|
313
|
+
const provider = CustomResourceProvider.getOrCreateProvider(current, AUTO_DELETE_OBJECTS_RESOURCE_TYPE, {
|
|
314
314
|
codeDirectory: path.join(require.resolve("aws-cdk-lib/aws-s3"), "../lib/auto-delete-objects-handler"),
|
|
315
|
-
runtime:
|
|
315
|
+
runtime: CustomResourceProviderRuntime.NODEJS_16_X,
|
|
316
316
|
description: `Lambda function for auto-deleting objects in ${current.bucketName} S3 bucket.`,
|
|
317
317
|
});
|
|
318
318
|
// Use a bucket policy to allow the custom resource to delete
|
|
319
319
|
// objects in the bucket
|
|
320
|
-
current.addToResourcePolicy(new
|
|
320
|
+
current.addToResourcePolicy(new PolicyStatement({
|
|
321
321
|
actions: [
|
|
322
322
|
// list objects
|
|
323
323
|
"s3:GetBucket*",
|
|
@@ -326,9 +326,9 @@ export class App extends cdk.App {
|
|
|
326
326
|
"s3:DeleteObject*",
|
|
327
327
|
],
|
|
328
328
|
resources: [current.bucketArn, current.arnForObjects("*")],
|
|
329
|
-
principals: [new
|
|
329
|
+
principals: [new ArnPrincipal(provider.roleArn)],
|
|
330
330
|
}));
|
|
331
|
-
const customResource = new
|
|
331
|
+
const customResource = new CustomResource(current, "AutoDeleteObjectsCustomResource", {
|
|
332
332
|
resourceType: AUTO_DELETE_OBJECTS_RESOURCE_TYPE,
|
|
333
333
|
serviceToken: provider.serviceToken,
|
|
334
334
|
properties: {
|
|
@@ -350,15 +350,15 @@ export class App extends cdk.App {
|
|
|
350
350
|
}
|
|
351
351
|
class RemoveGovCloudUnsupportedResourceProperties {
|
|
352
352
|
visit(node) {
|
|
353
|
-
if (node instanceof
|
|
353
|
+
if (node instanceof CfnFunction) {
|
|
354
354
|
node.addPropertyDeletionOverride("EphemeralStorage");
|
|
355
355
|
}
|
|
356
|
-
else if (node instanceof
|
|
356
|
+
else if (node instanceof CfnLogGroup) {
|
|
357
357
|
node.addPropertyDeletionOverride("Tags");
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
|
-
|
|
361
|
+
Aspects.of(this).add(new RemoveGovCloudUnsupportedResourceProperties());
|
|
362
362
|
}
|
|
363
363
|
ensureUniqueConstructIds() {
|
|
364
364
|
// "ids" has the shape of:
|
|
@@ -426,7 +426,7 @@ export class App extends cdk.App {
|
|
|
426
426
|
ids[className] = existingIds;
|
|
427
427
|
}
|
|
428
428
|
}
|
|
429
|
-
|
|
429
|
+
Aspects.of(this).add(new EnsureUniqueConstructIds());
|
|
430
430
|
}
|
|
431
431
|
codegenTypes() {
|
|
432
432
|
const project = useProject();
|
|
@@ -484,7 +484,7 @@ export class App extends cdk.App {
|
|
|
484
484
|
]).join("\n"));
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
|
-
|
|
487
|
+
Aspects.of(this).add(new CodegenTypes());
|
|
488
488
|
}
|
|
489
489
|
// Functional Stack
|
|
490
490
|
// This is a magical global to avoid having to pass app everywhere.
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
export declare function weakImport(pkg: string): Promise<any>;
|
|
2
2
|
import { Construct } from "constructs";
|
|
3
|
-
import * as rds from "aws-cdk-lib/aws-rds";
|
|
4
|
-
import * as appsync from "aws-cdk-lib/aws-appsync";
|
|
5
|
-
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
|
|
6
|
-
import * as acm from "aws-cdk-lib/aws-certificatemanager";
|
|
7
|
-
import * as secretsmanager from "aws-cdk-lib/aws-secretsmanager";
|
|
8
3
|
import { Table } from "./Table.js";
|
|
9
4
|
import { RDS } from "./RDS.js";
|
|
10
5
|
import * as appSyncApiDomain from "./util/appSyncApiDomain.js";
|
|
@@ -12,6 +7,11 @@ import { SSTConstruct } from "./Construct.js";
|
|
|
12
7
|
import { Function as Fn, FunctionProps, FunctionInlineDefinition, FunctionDefinition } from "./Function.js";
|
|
13
8
|
import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
14
9
|
import { Permissions } from "./util/permission.js";
|
|
10
|
+
import { Table as CDKTable } from "aws-cdk-lib/aws-dynamodb";
|
|
11
|
+
import { IServerlessCluster } from "aws-cdk-lib/aws-rds";
|
|
12
|
+
import { ISecret } from "aws-cdk-lib/aws-secretsmanager";
|
|
13
|
+
import { AwsIamConfig, BaseDataSource, CfnDomainName, GraphqlApi, GraphqlApiProps, IGraphqlApi, Resolver, ResolverProps } from "aws-cdk-lib/aws-appsync";
|
|
14
|
+
import { ICertificate } from "aws-cdk-lib/aws-certificatemanager";
|
|
15
15
|
export interface AppSyncApiDomainProps extends appSyncApiDomain.CustomDomainProps {
|
|
16
16
|
}
|
|
17
17
|
interface AppSyncApiBaseDataSourceProps {
|
|
@@ -76,7 +76,7 @@ export interface AppSyncApiDynamoDbDataSourceProps extends AppSyncApiBaseDataSou
|
|
|
76
76
|
table?: Table;
|
|
77
77
|
cdk?: {
|
|
78
78
|
dataSource?: {
|
|
79
|
-
table:
|
|
79
|
+
table: CDKTable;
|
|
80
80
|
};
|
|
81
81
|
};
|
|
82
82
|
}
|
|
@@ -110,8 +110,8 @@ export interface AppSyncApiRdsDataSourceProps extends AppSyncApiBaseDataSourcePr
|
|
|
110
110
|
databaseName?: string;
|
|
111
111
|
cdk?: {
|
|
112
112
|
dataSource?: {
|
|
113
|
-
serverlessCluster:
|
|
114
|
-
secretStore:
|
|
113
|
+
serverlessCluster: IServerlessCluster;
|
|
114
|
+
secretStore: ISecret;
|
|
115
115
|
databaseName?: string;
|
|
116
116
|
};
|
|
117
117
|
};
|
|
@@ -142,7 +142,7 @@ export interface AppSyncApiHttpDataSourceProps extends AppSyncApiBaseDataSourceP
|
|
|
142
142
|
endpoint: string;
|
|
143
143
|
cdk?: {
|
|
144
144
|
dataSource?: {
|
|
145
|
-
authorizationConfig?:
|
|
145
|
+
authorizationConfig?: AwsIamConfig;
|
|
146
146
|
};
|
|
147
147
|
};
|
|
148
148
|
}
|
|
@@ -231,7 +231,7 @@ export interface AppSyncApiResolverProps {
|
|
|
231
231
|
/**
|
|
232
232
|
* This allows you to override the default settings this construct uses internally to create the resolver.
|
|
233
233
|
*/
|
|
234
|
-
resolver: Omit<
|
|
234
|
+
resolver: Omit<ResolverProps, "api" | "fieldName" | "typeName" | "dataSource">;
|
|
235
235
|
};
|
|
236
236
|
}
|
|
237
237
|
export interface AppSyncApiProps {
|
|
@@ -328,10 +328,10 @@ export interface AppSyncApiProps {
|
|
|
328
328
|
/**
|
|
329
329
|
* Allows you to override default settings this construct uses internally to create the AppSync API.
|
|
330
330
|
*/
|
|
331
|
-
graphqlApi?:
|
|
331
|
+
graphqlApi?: IGraphqlApi | AppSyncApiCdkGraphqlProps;
|
|
332
332
|
};
|
|
333
333
|
}
|
|
334
|
-
export interface AppSyncApiCdkGraphqlProps extends Omit<
|
|
334
|
+
export interface AppSyncApiCdkGraphqlProps extends Omit<GraphqlApiProps, "name" | "schema"> {
|
|
335
335
|
name?: string;
|
|
336
336
|
}
|
|
337
337
|
/**
|
|
@@ -364,15 +364,15 @@ export declare class AppSyncApi extends Construct implements SSTConstruct {
|
|
|
364
364
|
/**
|
|
365
365
|
* The internally created appsync api
|
|
366
366
|
*/
|
|
367
|
-
graphqlApi:
|
|
367
|
+
graphqlApi: GraphqlApi;
|
|
368
368
|
/**
|
|
369
369
|
* If custom domain is enabled, this is the internally created CDK Certificate instance.
|
|
370
370
|
*/
|
|
371
|
-
certificate?:
|
|
371
|
+
certificate?: ICertificate;
|
|
372
372
|
};
|
|
373
373
|
private readonly props;
|
|
374
374
|
private _customDomainUrl?;
|
|
375
|
-
_cfnDomainName?:
|
|
375
|
+
_cfnDomainName?: CfnDomainName;
|
|
376
376
|
private readonly functionsByDsKey;
|
|
377
377
|
private readonly dataSourcesByDsKey;
|
|
378
378
|
private readonly dsKeysByResKey;
|
|
@@ -442,7 +442,7 @@ export declare class AppSyncApi extends Construct implements SSTConstruct {
|
|
|
442
442
|
* api.getDataSource("billingDS");
|
|
443
443
|
* ```
|
|
444
444
|
*/
|
|
445
|
-
getDataSource(key: string):
|
|
445
|
+
getDataSource(key: string): BaseDataSource | undefined;
|
|
446
446
|
/**
|
|
447
447
|
* Get a resolver
|
|
448
448
|
*
|
|
@@ -451,7 +451,7 @@ export declare class AppSyncApi extends Construct implements SSTConstruct {
|
|
|
451
451
|
* api.getResolver("Mutation charge");
|
|
452
452
|
* ```
|
|
453
453
|
*/
|
|
454
|
-
getResolver(key: string):
|
|
454
|
+
getResolver(key: string): Resolver | undefined;
|
|
455
455
|
/**
|
|
456
456
|
* Binds the given list of resources to all function data sources.
|
|
457
457
|
*
|