sst 2.1.30 → 2.1.32

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.
@@ -1,9 +1,11 @@
1
1
  import * as trpc from "@trpc/server";
2
2
  import { DendriformPatch } from "dendriform-immer-patch-optimiser";
3
+ import { useProject } from "../../project.js";
3
4
  export type State = {
4
5
  app: string;
5
6
  stage: string;
6
7
  functions: Record<string, FunctionState>;
8
+ bootstrap: ReturnType<typeof useProject>["config"]["bootstrap"];
7
9
  live: boolean;
8
10
  stacks: {
9
11
  status: any;
@@ -29,6 +29,7 @@ export async function useLocalServer(opts) {
29
29
  let state = {
30
30
  app: project.config.name,
31
31
  stage: project.config.stage,
32
+ bootstrap: project.config.bootstrap,
32
33
  live: opts.live,
33
34
  stacks: {
34
35
  status: "idle",
@@ -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: apigAuthorizers.HttpUserPoolAuthorizer;
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: apigAuthorizers.HttpJwtAuthorizer;
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 apigAuthorizers.HttpLambdaResponseType>[];
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: apigAuthorizers.HttpLambdaAuthorizer;
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?: apig.IHttpApi | apig.HttpApiProps;
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<apig.HttpStageProps, "httpApi">[];
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?: lambda.IFunction;
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: elb.IApplicationListener;
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: elb.INetworkListener;
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: apig.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?: logs.LogGroup;
620
+ accessLogGroup?: LogGroup;
621
621
  /**
622
622
  * If custom domain is enabled, this is the internally created CDK DomainName instance.
623
623
  */
624
- domainName?: apig.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?: acm.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): apig.HttpRouteIntegration;
788
- protected createCdkFunctionIntegration(scope: Construct, routeKey: string, routeProps: ApiFunctionRouteProps<keyof Authorizers>, postfixName: string): apig.HttpRouteIntegration;
789
- protected createFunctionIntegration(scope: Construct, routeKey: string, routeProps: ApiFunctionRouteProps<keyof Authorizers>, postfixName: string): apig.HttpRouteIntegration;
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 apig.HttpApi
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 apig.HttpApi(this, "Api", {
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 apig.HttpStage(this, "Stage" + def.stageName, {
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 = cognito.UserPool.fromUserPoolId(this, `Api-${this.node.id}-Authorizer-${key}-UserPool`, value.userPool.id);
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) => cognito.UserPoolClient.fromUserPoolClientId(this, `Api-${this.node.id}-Authorizer-${key}-UserPoolClient-${i}`, clientId));
348
- this.authorizersData[key] =
349
- new apigAuthorizers.HttpUserPoolAuthorizer(key, userPool, {
350
- authorizerName: value.name,
351
- identitySource: value.identitySource,
352
- userPoolClients,
353
- userPoolRegion: value.userPool.region,
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 apigAuthorizers.HttpJwtAuthorizer(key, value.jwt.issuer, {
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 apigAuthorizers.HttpLambdaAuthorizer(key, value.function, {
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) => apigAuthorizers.HttpLambdaResponseType[type.toUpperCase()]),
381
+ value.responseTypes.map((type) => HttpLambdaResponseType[type.toUpperCase()]),
385
382
  resultsCacheTtl: value.resultsCacheTtl
386
383
  ? toCdkDuration(value.resultsCacheTtl)
387
- : cdkLib.Duration.seconds(0),
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 = apig.HttpRouteKey.DEFAULT;
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 (!apig.HttpMethod[method]) {
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 = apig.HttpRouteKey.with(path, apig.HttpMethod[method]);
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 apig.HttpRoute(scope, `Route_${postfixName}`, {
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: apig.IntegrationCredentials.fromRole(role),
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(scope, routeKey, routeProps, postfixName) {
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(scope, routeKey, routeProps, postfixName) {
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(scope, routeKey, routeProps, postfixName) {
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(scope, routeKey, routeProps, postfixName) {
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
- ? apig.PayloadFormatVersion.VERSION_1_0
613
- : apig.PayloadFormatVersion.VERSION_2_0;
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
- ? apig.PayloadFormatVersion.VERSION_1_0
643
- : apig.PayloadFormatVersion.VERSION_2_0;
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 apig.HttpNoneAuthorizer(),
675
+ authorizer: new HttpNoneAuthorizer(),
679
676
  };
680
677
  }
681
678
  else if (authorizerKey === "iam") {
682
679
  return {
683
680
  authorizationType: "iam",
684
- authorizer: new apigAuthorizers.HttpIamAuthorizer(),
681
+ authorizer: new HttpIamAuthorizer(),
685
682
  };
686
683
  }
687
684
  if (!this.props.authorizers ||
@@ -1,10 +1,11 @@
1
- import * as cdk from "aws-cdk-lib";
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<keyof typeof cdk.RemovalPolicy>;
42
- export type AppProps = cdk.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 cdk.App {
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: cdk.Stack) => FunctionProps))[];
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: cdk.Stack) => FunctionProps)): void;
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: lambda.ILayerVersion[]): void;
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 cdk.App {
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
- cdk.Tags.of(child).add("sst:app", this.name);
221
- cdk.Tags.of(child).add("sst:stage", this.stage);
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
- cdk.Aspects.of(this).add(new CreateSsmParameters());
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 cdk.CfnResource) {
306
- current.applyRemovalPolicy(cdk.RemovalPolicy[policy.toUpperCase()]);
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 s3.Bucket &&
310
+ if (current instanceof Bucket &&
311
311
  !current.node.tryFindChild("AutoDeleteObjectsCustomResource")) {
312
312
  const AUTO_DELETE_OBJECTS_RESOURCE_TYPE = "Custom::S3AutoDeleteObjects";
313
- const provider = cdk.CustomResourceProvider.getOrCreateProvider(current, AUTO_DELETE_OBJECTS_RESOURCE_TYPE, {
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: cdk.CustomResourceProviderRuntime.NODEJS_16_X,
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 iam.PolicyStatement({
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 iam.ArnPrincipal(provider.roleArn)],
329
+ principals: [new ArnPrincipal(provider.roleArn)],
330
330
  }));
331
- const customResource = new cdk.CustomResource(current, "AutoDeleteObjectsCustomResource", {
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 lambda.CfnFunction) {
353
+ if (node instanceof CfnFunction) {
354
354
  node.addPropertyDeletionOverride("EphemeralStorage");
355
355
  }
356
- else if (node instanceof logs.CfnLogGroup) {
356
+ else if (node instanceof CfnLogGroup) {
357
357
  node.addPropertyDeletionOverride("Tags");
358
358
  }
359
359
  }
360
360
  }
361
- cdk.Aspects.of(this).add(new RemoveGovCloudUnsupportedResourceProperties());
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
- cdk.Aspects.of(this).add(new EnsureUniqueConstructIds());
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
- cdk.Aspects.of(this).add(new CodegenTypes());
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.