sst 2.11.5 → 2.11.6

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.
Files changed (44) hide show
  1. package/bootstrap.js +1 -1
  2. package/cli/commands/connect.d.ts +2 -0
  3. package/cli/commands/connect.js +14 -3
  4. package/constructs/ApiGatewayV1Api.js +9 -9
  5. package/constructs/App.d.ts +1 -1
  6. package/constructs/App.js +1 -1
  7. package/constructs/Auth.js +1 -1
  8. package/constructs/BaseSite.js +1 -1
  9. package/constructs/Bucket.d.ts +2 -2
  10. package/constructs/Construct.d.ts +3 -3
  11. package/constructs/EdgeFunction.js +1 -1
  12. package/constructs/Function.d.ts +1 -1
  13. package/constructs/Function.js +1 -1
  14. package/constructs/NextjsSite.js +1 -1
  15. package/constructs/RDS.js +6 -6
  16. package/constructs/Script.js +3 -3
  17. package/constructs/SsrFunction.js +1 -1
  18. package/constructs/SsrSite.js +1 -1
  19. package/constructs/Stack.d.ts +4 -4
  20. package/constructs/Stack.js +6 -6
  21. package/constructs/StaticSite.js +1 -1
  22. package/constructs/WebSocketApi.js +3 -3
  23. package/constructs/cdk/certificate-base.d.ts +1 -1
  24. package/constructs/cdk/certificate-base.js +1 -1
  25. package/constructs/cdk/dns-validated-certificate.d.ts +1 -1
  26. package/constructs/cdk/dns-validated-certificate.js +1 -1
  27. package/constructs/cdk/website-redirect.js +1 -1
  28. package/constructs/deprecated/NextjsSite.js +2 -2
  29. package/constructs/deprecated/cross-region-helper.d.ts +5 -5
  30. package/constructs/deprecated/cross-region-helper.js +14 -14
  31. package/constructs/future/Auth.js +1 -1
  32. package/constructs/util/apiGatewayV2Domain.js +6 -6
  33. package/constructs/util/appSyncApiDomain.js +2 -2
  34. package/constructs/util/duration.d.ts +1 -1
  35. package/constructs/util/duration.js +1 -1
  36. package/constructs/util/size.d.ts +2 -2
  37. package/constructs/util/size.js +3 -3
  38. package/logger.js +1 -1
  39. package/package.json +1 -1
  40. package/project.js +5 -1
  41. package/runtime/handlers/pythonBundling.d.ts +1 -1
  42. package/runtime/handlers/pythonBundling.js +1 -1
  43. package/sst.mjs +21 -12
  44. package/stacks/build.js +3 -0
package/bootstrap.js CHANGED
@@ -3,7 +3,7 @@ import path from "path";
3
3
  import { bold, dim } from "colorette";
4
4
  import { spawn } from "child_process";
5
5
  import { DescribeStacksCommand, CloudFormationClient, } from "@aws-sdk/client-cloudformation";
6
- import { App, DefaultStackSynthesizer, CfnOutput, Duration, Tags, Stack, RemovalPolicy, } from "aws-cdk-lib";
6
+ import { App, DefaultStackSynthesizer, CfnOutput, Duration, Tags, Stack, RemovalPolicy, } from "aws-cdk-lib/core";
7
7
  import { Function, Runtime, Code } from "aws-cdk-lib/aws-lambda";
8
8
  import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
9
9
  import { PolicyStatement } from "aws-cdk-lib/aws-iam";
@@ -12,4 +12,6 @@ export declare const connect: (program: Program) => import("yargs").Argv<{
12
12
  role: string | undefined;
13
13
  } & {
14
14
  future: boolean | undefined;
15
+ } & {
16
+ dev: boolean;
15
17
  }>;
@@ -1,4 +1,9 @@
1
- export const connect = (program) => program.command("connect", "", (yargs) => yargs, async (args) => {
1
+ import { Colors } from "../colors.js";
2
+ export const connect = (program) => program.command("connect", "Connect a stage to SST Console", (yargs) => yargs.option("dev", {
3
+ type: "boolean",
4
+ default: false,
5
+ describe: "Connect to SST dev account (probably don't want to do this)",
6
+ }), async (args) => {
2
7
  if (!args.future)
3
8
  throw new Error("This command is not yet available.");
4
9
  const { useAWSClient } = await import("../../credentials.js");
@@ -6,6 +11,9 @@ export const connect = (program) => program.command("connect", "", (yargs) => ya
6
11
  const { useSTSIdentity } = await import("../../credentials.js");
7
12
  const { IAMClient, CreateRoleCommand, AttachRolePolicyCommand } = await import("@aws-sdk/client-iam");
8
13
  const client = useAWSClient(IAMClient);
14
+ if (args.dev) {
15
+ Colors.line(Colors.warning("⚠"), Colors.bold(" Connecting to dev stage"));
16
+ }
9
17
  await client
10
18
  .send(new CreateRoleCommand({
11
19
  RoleName: "sst",
@@ -15,7 +23,7 @@ export const connect = (program) => program.command("connect", "", (yargs) => ya
15
23
  {
16
24
  Effect: "Allow",
17
25
  Principal: {
18
- AWS: "arn:aws:iam::917397401067:role/*",
26
+ AWS: `arn:aws:iam::${args.dev ? "917397401067" : "226609089145"}:root`,
19
27
  },
20
28
  Action: "sts:AssumeRole",
21
29
  },
@@ -33,5 +41,8 @@ export const connect = (program) => program.command("connect", "", (yargs) => ya
33
41
  }));
34
42
  const project = useProject();
35
43
  const identity = await useSTSIdentity();
36
- console.log(`http://localhost:3000/connect?app=${project.config.name}&stage=${project.config.stage}&aws_account_id=${identity.Account}&region=${project.config.region}`);
44
+ const host = args.dev
45
+ ? "http://localhost:3000"
46
+ : "https://console.production.sst.dev";
47
+ console.log(`${host}/connect?app=${project.config.name}&stage=${project.config.stage}&aws_account_id=${identity.Account}&region=${project.config.region}`);
37
48
  });
@@ -1,5 +1,4 @@
1
1
  import { Construct } from "constructs";
2
- import * as cdk from "aws-cdk-lib";
3
2
  import * as route53 from "aws-cdk-lib/aws-route53";
4
3
  import * as route53Targets from "aws-cdk-lib/aws-route53-targets";
5
4
  import * as acm from "aws-cdk-lib/aws-certificatemanager";
@@ -11,6 +10,7 @@ import { toCdkDuration } from "./util/duration.js";
11
10
  import { getFunctionRef, isCDKConstruct } from "./Construct.js";
12
11
  import { DnsValidatedCertificate } from "./cdk/dns-validated-certificate.js";
13
12
  import { Function as Fn, } from "./Function.js";
13
+ import { Duration as CDKDuration, Token } from "aws-cdk-lib/core";
14
14
  const allowedMethods = [
15
15
  "ANY",
16
16
  "GET",
@@ -370,7 +370,7 @@ export class ApiGatewayV1Api extends Construct {
370
370
  if (typeof customDomain === "string") {
371
371
  // validate: customDomain is a TOKEN string
372
372
  // ie. imported SSM value: ssm.StringParameter.valueForStringParameter()
373
- if (cdk.Token.isUnresolved(customDomain)) {
373
+ if (Token.isUnresolved(customDomain)) {
374
374
  throw new Error(`You also need to specify the "hostedZone" if the "domainName" is passed in as a reference.`);
375
375
  }
376
376
  domainName = customDomain;
@@ -381,7 +381,7 @@ export class ApiGatewayV1Api extends Construct {
381
381
  else if (customDomain.domainName) {
382
382
  domainName = customDomain.domainName;
383
383
  // parse customDomain.domainName
384
- if (cdk.Token.isUnresolved(customDomain.domainName)) {
384
+ if (Token.isUnresolved(customDomain.domainName)) {
385
385
  // If customDomain is a TOKEN string, "hostedZone" has to be passed in. This
386
386
  // is because "hostedZone" cannot be parsed from a TOKEN value.
387
387
  if (!customDomain.hostedZone && !customDomain.cdk?.hostedZone) {
@@ -500,7 +500,7 @@ export class ApiGatewayV1Api extends Construct {
500
500
  }
501
501
  // Note: We only know the full custom domain if domainName is a string.
502
502
  // _customDomainUrl will be undefined if apigDomainName is imported.
503
- if (domainName && !cdk.Token.isUnresolved(domainName)) {
503
+ if (domainName && !Token.isUnresolved(domainName)) {
504
504
  this._customDomainUrl = basePath
505
505
  ? `https://${domainName}/${basePath}/`
506
506
  : `https://${domainName}`;
@@ -522,7 +522,7 @@ export class ApiGatewayV1Api extends Construct {
522
522
  // This is because the construct tries to check if the record name
523
523
  // ends with the domain name. If not, it will append the domain name.
524
524
  // So, we need remove this behavior.
525
- if (cdk.Token.isUnresolved(domainName)) {
525
+ if (Token.isUnresolved(domainName)) {
526
526
  records.forEach((record) => {
527
527
  const cfnRecord = record.node.defaultChild;
528
528
  cfnRecord.name = domainName;
@@ -578,7 +578,7 @@ export class ApiGatewayV1Api extends Construct {
578
578
  identitySource: value.identitySource,
579
579
  resultsCacheTtl: value.resultsCacheTtl
580
580
  ? toCdkDuration(value.resultsCacheTtl)
581
- : cdk.Duration.seconds(0),
581
+ : CDKDuration.seconds(0),
582
582
  });
583
583
  }
584
584
  }
@@ -598,7 +598,7 @@ export class ApiGatewayV1Api extends Construct {
598
598
  assumeRole: value.cdk?.assumeRole,
599
599
  resultsCacheTtl: value.resultsCacheTtl
600
600
  ? toCdkDuration(value.resultsCacheTtl)
601
- : cdk.Duration.seconds(0),
601
+ : CDKDuration.seconds(0),
602
602
  });
603
603
  }
604
604
  }
@@ -620,7 +620,7 @@ export class ApiGatewayV1Api extends Construct {
620
620
  assumeRole: value.cdk?.assumeRole,
621
621
  resultsCacheTtl: value.resultsCacheTtl
622
622
  ? toCdkDuration(value.resultsCacheTtl)
623
- : cdk.Duration.seconds(0),
623
+ : CDKDuration.seconds(0),
624
624
  });
625
625
  }
626
626
  }
@@ -699,7 +699,7 @@ export class ApiGatewayV1Api extends Construct {
699
699
  this._deployment.node.addDependency(apigMethod);
700
700
  }
701
701
  }
702
- createCdkFunction(scope, routeKey, routeProps, postfixName) {
702
+ createCdkFunction(_scope, routeKey, routeProps, _postfixName) {
703
703
  const lambda = routeProps.cdk?.function;
704
704
  this.functions[routeKey] = lambda;
705
705
  return lambda;
@@ -4,7 +4,7 @@ import { FunctionProps } from "./Function.js";
4
4
  import { Permissions } from "./util/permission.js";
5
5
  import { StackProps } from "./Stack.js";
6
6
  import { FunctionalStack } from "./FunctionalStack.js";
7
- import { AppProps as CDKAppProps, App as CDKApp, Stack as CDKStack, RemovalPolicy } from "aws-cdk-lib";
7
+ import { AppProps as CDKAppProps, App as CDKApp, Stack as CDKStack, RemovalPolicy } from "aws-cdk-lib/core";
8
8
  import { ILayerVersion } from "aws-cdk-lib/aws-lambda";
9
9
  /**
10
10
  * @internal
package/constructs/App.js CHANGED
@@ -11,7 +11,7 @@ import { useDeferredTasks } from "./deferred_task.js";
11
11
  import { AppContext } from "./context.js";
12
12
  import { useProject } from "../project.js";
13
13
  import { Logger } from "../logger.js";
14
- import { App as CDKApp, Tags, CfnResource, RemovalPolicy, CustomResourceProvider, CustomResourceProviderRuntime, CustomResource, Aspects, } from "aws-cdk-lib";
14
+ import { App as CDKApp, Tags, CfnResource, RemovalPolicy, CustomResourceProvider, CustomResourceProviderRuntime, CustomResource, Aspects, } from "aws-cdk-lib/core";
15
15
  import { CfnFunction } from "aws-cdk-lib/aws-lambda";
16
16
  import { Bucket } from "aws-cdk-lib/aws-s3";
17
17
  import { ArnPrincipal, PolicyStatement } from "aws-cdk-lib/aws-iam";
@@ -3,7 +3,7 @@ import { Effect, Policy, PolicyStatement } from "aws-cdk-lib/aws-iam";
3
3
  import { Construct } from "constructs";
4
4
  import { Stack } from "./Stack.js";
5
5
  import { getEnvironmentKey, getParameterPath, placeholderSecretValue, } from "./util/functionBinding.js";
6
- import { CustomResource } from "aws-cdk-lib";
6
+ import { CustomResource } from "aws-cdk-lib/core";
7
7
  const PUBLIC_KEY_PROP = "publicKey";
8
8
  const PRIVATE_KEY_PROP = "privateKey";
9
9
  const PREFIX_PROP = "prefix";
@@ -1,4 +1,4 @@
1
- import { Token } from "aws-cdk-lib";
1
+ import { Token } from "aws-cdk-lib/core";
2
2
  export function buildErrorResponsesForRedirectToIndex(indexPage) {
3
3
  return [
4
4
  {
@@ -170,8 +170,8 @@ export interface BucketProps {
170
170
  */
171
171
  cors?: boolean | BucketCorsRule[];
172
172
  /**
173
- * Block public access to this bucket. Setting this to `true` alllows uploading objects with public ACLs.
174
- * Note that setting to `true` does not necessarily mean that the bucket is completely accessible to the public. Rather, it enables the granting of public permissions through public ACLs.
173
+ * Prevent any files from being uploaded with public access configured. Setting this to `true` prevents uploading objects with public ACLs.
174
+ * Note that setting to `false` does not necessarily mean that the bucket is completely accessible to the public. Rather, it enables the granting of public permissions on a per file basis.
175
175
  * @default false
176
176
  * @example
177
177
  * ```js
@@ -1,5 +1,5 @@
1
1
  import { Construct } from "constructs";
2
- import * as cdk from "aws-cdk-lib";
2
+ import { Stack as CDKStack } from "aws-cdk-lib/core";
3
3
  import { FunctionBindingProps } from "./util/functionBinding.js";
4
4
  export interface SSTConstructMetadata<T extends string = string, D extends Record<string, any> = Record<string, any>, L extends Record<string, any> = Record<string, any>> {
5
5
  type: T;
@@ -16,8 +16,8 @@ export declare function getFunctionRef(fn?: any): {
16
16
  stack: string;
17
17
  } | undefined;
18
18
  export declare function isConstruct(construct: any): boolean;
19
- export declare function isStackConstruct(construct: any): construct is cdk.Stack;
19
+ export declare function isStackConstruct(construct: any): construct is CDKStack;
20
20
  export declare function isSSTConstruct(construct: any): construct is SSTConstruct;
21
- export declare function isSSTDebugStack(construct: any): construct is cdk.Stack;
21
+ export declare function isSSTDebugStack(construct: any): construct is CDKStack;
22
22
  export declare function isCDKConstructOf(construct: any, moduleName: string): construct is Construct;
23
23
  export declare function isCDKConstruct(construct: any): construct is Construct;
@@ -7,7 +7,7 @@ import { Construct } from "constructs";
7
7
  import { Effect, Role, Policy, PolicyStatement, CompositePrincipal, ServicePrincipal, ManagedPolicy, } from "aws-cdk-lib/aws-iam";
8
8
  import { Version, Code, Runtime, Function as CdkFunction, } from "aws-cdk-lib/aws-lambda";
9
9
  import { Asset } from "aws-cdk-lib/aws-s3-assets";
10
- import { Lazy, Duration as CdkDuration, CustomResource, } from "aws-cdk-lib";
10
+ import { Lazy, Duration as CdkDuration, CustomResource, } from "aws-cdk-lib/core";
11
11
  import { useProject } from "../project.js";
12
12
  import { useRuntimeHandlers } from "../runtime/handlers.js";
13
13
  import { Stack } from "./Stack.js";
@@ -9,7 +9,7 @@ import { Permissions } from "./util/permission.js";
9
9
  import * as functionUrlCors from "./util/functionUrlCors.js";
10
10
  import { Architecture, Function as CDKFunction, FunctionOptions, ILayerVersion, Runtime as CDKRuntime, Tracing } from "aws-cdk-lib/aws-lambda";
11
11
  import { RetentionDays } from "aws-cdk-lib/aws-logs";
12
- import { Size as CDKSize, Duration as CDKDuration } from "aws-cdk-lib";
12
+ import { Size as CDKSize, Duration as CDKDuration } from "aws-cdk-lib/core";
13
13
  declare const supportedRuntimes: {
14
14
  rust: CDKRuntime;
15
15
  nodejs: CDKRuntime;
@@ -17,7 +17,7 @@ import { createAppContext } from "./context.js";
17
17
  import { useWarning } from "./util/warning.js";
18
18
  import { Architecture, AssetCode, Code, Function as CDKFunction, FunctionUrlAuthType, LayerVersion, Runtime as CDKRuntime, Tracing, } from "aws-cdk-lib/aws-lambda";
19
19
  import { RetentionDays } from "aws-cdk-lib/aws-logs";
20
- import { Token, Size as CDKSize, Duration as CDKDuration } from "aws-cdk-lib";
20
+ import { Token, Size as CDKSize, Duration as CDKDuration, } from "aws-cdk-lib/core";
21
21
  import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
22
22
  import { StringParameter } from "aws-cdk-lib/aws-ssm";
23
23
  import { useBootstrap } from "../bootstrap.js";
@@ -1,7 +1,7 @@
1
1
  import fs from "fs";
2
2
  import url from "url";
3
3
  import path from "path";
4
- import { Fn, Duration as CdkDuration, RemovalPolicy, CustomResource, } from "aws-cdk-lib";
4
+ import { Fn, Duration as CdkDuration, RemovalPolicy, CustomResource, } from "aws-cdk-lib/core";
5
5
  import { Effect, Policy, PolicyStatement } from "aws-cdk-lib/aws-iam";
6
6
  import { RetentionDays } from "aws-cdk-lib/aws-logs";
7
7
  import { Function as CdkFunction, Code, Runtime, Architecture, FunctionUrlAuthType, } from "aws-cdk-lib/aws-lambda";
package/constructs/RDS.js CHANGED
@@ -4,7 +4,7 @@ import fs from "fs";
4
4
  import url from "url";
5
5
  import * as crypto from "crypto";
6
6
  import { Construct } from "constructs";
7
- import * as cdk from "aws-cdk-lib";
7
+ import { Duration as CDKDuration, CustomResource } from "aws-cdk-lib/core";
8
8
  import * as ec2 from "aws-cdk-lib/aws-ec2";
9
9
  import * as rds from "aws-cdk-lib/aws-rds";
10
10
  import * as lambda from "aws-cdk-lib/aws-lambda";
@@ -209,10 +209,10 @@ export class RDS extends Construct {
209
209
  getScaling(scaling) {
210
210
  return {
211
211
  autoPause: scaling?.autoPause === false
212
- ? cdk.Duration.minutes(0)
212
+ ? CDKDuration.minutes(0)
213
213
  : scaling?.autoPause === true || scaling?.autoPause === undefined
214
- ? cdk.Duration.minutes(5)
215
- : cdk.Duration.minutes(scaling?.autoPause),
214
+ ? CDKDuration.minutes(5)
215
+ : CDKDuration.minutes(scaling?.autoPause),
216
216
  minCapacity: rds.AuroraCapacityUnit[scaling?.minCapacity || "ACU_2"],
217
217
  maxCapacity: rds.AuroraCapacityUnit[scaling?.maxCapacity || "ACU_16"],
218
218
  };
@@ -301,7 +301,7 @@ export class RDS extends Construct {
301
301
  code: lambda.Code.fromAsset(path.join(__dirname, "../support/script-function")),
302
302
  runtime: lambda.Runtime.NODEJS_16_X,
303
303
  handler: "index.handler",
304
- timeout: cdk.Duration.minutes(15),
304
+ timeout: CDKDuration.minutes(15),
305
305
  memorySize: 1024,
306
306
  });
307
307
  this.migratorFunction?.grantInvoke(handler);
@@ -314,7 +314,7 @@ export class RDS extends Construct {
314
314
  // rebuilding infrastructure b/c the "BuildAt" property changes on
315
315
  // each build.
316
316
  const hash = app.mode === "dev" ? 0 : this.generateMigrationsHash(migrations);
317
- new cdk.CustomResource(this, "MigrationResource", {
317
+ new CustomResource(this, "MigrationResource", {
318
318
  serviceToken: handler.functionArn,
319
319
  resourceType: "Custom::SSTScript",
320
320
  properties: {
@@ -1,7 +1,7 @@
1
1
  import path from "path";
2
2
  import url from "url";
3
3
  import { Construct } from "constructs";
4
- import * as cdk from "aws-cdk-lib";
4
+ import { CustomResource, Duration } from "aws-cdk-lib/core";
5
5
  import * as lambda from "aws-cdk-lib/aws-lambda";
6
6
  import { Function as Fn, } from "./Function.js";
7
7
  const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
@@ -116,7 +116,7 @@ export class Script extends Construct {
116
116
  code: lambda.Code.fromAsset(path.join(__dirname, "../support/script-function")),
117
117
  runtime: lambda.Runtime.NODEJS_16_X,
118
118
  handler: "index.handler",
119
- timeout: cdk.Duration.minutes(15),
119
+ timeout: Duration.minutes(15),
120
120
  memorySize: 1024,
121
121
  });
122
122
  this.createFunction?.grantInvoke(handler);
@@ -136,7 +136,7 @@ export class Script extends Construct {
136
136
  const version = app.mode === "dev"
137
137
  ? app.debugStartedAt
138
138
  : this.props.version ?? Date.now().toString();
139
- new cdk.CustomResource(this, "ScriptResource", {
139
+ new CustomResource(this, "ScriptResource", {
140
140
  serviceToken: crFunction.functionArn,
141
141
  resourceType: "Custom::SSTScript",
142
142
  properties: {
@@ -7,7 +7,7 @@ import { RetentionDays } from "aws-cdk-lib/aws-logs";
7
7
  import { Architecture, AssetCode, Runtime, Code, Function as CdkFunction, } from "aws-cdk-lib/aws-lambda";
8
8
  import { Bucket } from "aws-cdk-lib/aws-s3";
9
9
  import { Asset } from "aws-cdk-lib/aws-s3-assets";
10
- import { Duration as CdkDuration, CustomResource, } from "aws-cdk-lib";
10
+ import { Duration as CdkDuration, CustomResource, } from "aws-cdk-lib/core";
11
11
  import { useProject } from "../project.js";
12
12
  import { useRuntimeHandlers } from "../runtime/handlers.js";
13
13
  import { useFunctions, } from "./Function.js";
@@ -6,7 +6,7 @@ import crypto from "crypto";
6
6
  import spawn from "cross-spawn";
7
7
  import { execSync } from "child_process";
8
8
  import { Construct } from "constructs";
9
- import { Fn, Token, Duration as CdkDuration, RemovalPolicy, CustomResource, } from "aws-cdk-lib";
9
+ import { Fn, Token, Duration as CdkDuration, RemovalPolicy, CustomResource, } from "aws-cdk-lib/core";
10
10
  import { BlockPublicAccess, Bucket, } from "aws-cdk-lib/aws-s3";
11
11
  import { Role, Effect, Policy, PolicyStatement, AccountPrincipal, ServicePrincipal, CompositePrincipal, } from "aws-cdk-lib/aws-iam";
12
12
  import { Function as CdkFunction, Code, Runtime, FunctionUrlAuthType, } from "aws-cdk-lib/aws-lambda";
@@ -1,10 +1,10 @@
1
1
  import { Construct } from "constructs";
2
- import * as cdk from "aws-cdk-lib";
2
+ import { StackProps as CDKStackProps, Stack as CDKStack, CfnOutputProps } from "aws-cdk-lib/core";
3
3
  import * as lambda from "aws-cdk-lib/aws-lambda";
4
4
  import { FunctionProps, Function as Fn } from "./Function.js";
5
5
  import { SSTConstruct } from "./Construct.js";
6
6
  import { Permissions } from "./util/permission.js";
7
- export type StackProps = cdk.StackProps;
7
+ export type StackProps = CDKStackProps;
8
8
  /**
9
9
  * The Stack construct extends cdk.Stack. It automatically prefixes the stack names with the stage and app name to ensure that they can be deployed to multiple regions in the same AWS account. It also ensure that the stack uses the same AWS profile and region as the app. They're defined using functions that return resources that can be imported by other stacks.
10
10
  *
@@ -18,7 +18,7 @@ export type StackProps = cdk.StackProps;
18
18
  * }
19
19
  * ```
20
20
  */
21
- export declare class Stack extends cdk.Stack {
21
+ export declare class Stack extends CDKStack {
22
22
  /**
23
23
  * The current stage of the stack.
24
24
  */
@@ -119,7 +119,7 @@ export declare class Stack extends cdk.Stack {
119
119
  * });
120
120
  * ```
121
121
  */
122
- addOutputs(outputs: Record<string, string | cdk.CfnOutputProps | undefined>): void;
122
+ addOutputs(outputs: Record<string, string | CfnOutputProps | undefined>): void;
123
123
  private createCustomResourceHandler;
124
124
  private static buildSynthesizer;
125
125
  private static checkForPropsIsConstruct;
@@ -1,7 +1,7 @@
1
1
  import fs from "fs";
2
2
  import url from "url";
3
3
  import * as path from "path";
4
- import * as cdk from "aws-cdk-lib";
4
+ import { Stack as CDKStack, CfnOutput, Duration as CDKDuration, DefaultStackSynthesizer, } from "aws-cdk-lib/core";
5
5
  import * as lambda from "aws-cdk-lib/aws-lambda";
6
6
  import { useProject } from "../project.js";
7
7
  import { Function as Fn } from "./Function.js";
@@ -20,7 +20,7 @@ const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
20
20
  * }
21
21
  * ```
22
22
  */
23
- export class Stack extends cdk.Stack {
23
+ export class Stack extends CDKStack {
24
24
  /**
25
25
  * The current stage of the stack.
26
26
  */
@@ -182,8 +182,8 @@ export class Stack extends cdk.Stack {
182
182
  // And then we override the logical id so the actual output name is
183
183
  // still "myTable".
184
184
  const output = typeof value === "string"
185
- ? new cdk.CfnOutput(this, `SSTStackOutput${key}`, { value })
186
- : new cdk.CfnOutput(this, `SSTStackOutput${key}`, value);
185
+ ? new CfnOutput(this, `SSTStackOutput${key}`, { value })
186
+ : new CfnOutput(this, `SSTStackOutput${key}`, value);
187
187
  // CloudFormation only allows alphanumeric characters in the output name.
188
188
  output.overrideLogicalId(key.replace(/[^A-Za-z0-9]/g, ""));
189
189
  });
@@ -197,7 +197,7 @@ export class Stack extends cdk.Stack {
197
197
  }),
198
198
  handler: "index.handler",
199
199
  runtime: lambda.Runtime.NODEJS_16_X,
200
- timeout: cdk.Duration.seconds(900),
200
+ timeout: CDKDuration.seconds(900),
201
201
  memorySize: 1024,
202
202
  });
203
203
  }
@@ -207,7 +207,7 @@ export class Stack extends cdk.Stack {
207
207
  if (customSynethesizerKeys.length === 0) {
208
208
  return;
209
209
  }
210
- return new cdk.DefaultStackSynthesizer({
210
+ return new DefaultStackSynthesizer({
211
211
  qualifier: config.cdk?.qualifier,
212
212
  fileAssetsBucketName: config.cdk?.fileAssetsBucketName,
213
213
  });
@@ -4,7 +4,7 @@ import fs from "fs";
4
4
  import crypto from "crypto";
5
5
  import { execSync } from "child_process";
6
6
  import { Construct } from "constructs";
7
- import { Token, Duration, RemovalPolicy, CustomResource, } from "aws-cdk-lib";
7
+ import { Token, Duration, RemovalPolicy, CustomResource, } from "aws-cdk-lib/core";
8
8
  import { BlockPublicAccess, Bucket, } from "aws-cdk-lib/aws-s3";
9
9
  import { Asset } from "aws-cdk-lib/aws-s3-assets";
10
10
  import { Effect, Policy, PolicyStatement } from "aws-cdk-lib/aws-iam";
@@ -1,15 +1,15 @@
1
1
  import { Construct } from "constructs";
2
- import { CustomResource } from "aws-cdk-lib";
2
+ import { CustomResource } from "aws-cdk-lib/core";
3
3
  import * as iam from "aws-cdk-lib/aws-iam";
4
4
  import * as apig from "@aws-cdk/aws-apigatewayv2-alpha";
5
5
  import * as apigAuthorizers from "@aws-cdk/aws-apigatewayv2-authorizers-alpha";
6
- import * as apigIntegrations from "@aws-cdk/aws-apigatewayv2-integrations-alpha";
7
6
  import { Effect, Policy, PolicyStatement } from "aws-cdk-lib/aws-iam";
8
7
  import { Stack } from "./Stack.js";
9
8
  import { getFunctionRef, isCDKConstruct } from "./Construct.js";
10
9
  import { Function as Fn, } from "./Function.js";
11
10
  import * as apigV2Domain from "./util/apiGatewayV2Domain.js";
12
11
  import * as apigV2AccessLog from "./util/apiGatewayV2AccessLog.js";
12
+ import { WebSocketLambdaIntegration } from "@aws-cdk/aws-apigatewayv2-integrations-alpha/lib/websocket/index.js";
13
13
  /////////////////////
14
14
  // Construct
15
15
  /////////////////////
@@ -358,7 +358,7 @@ export class WebSocketApi extends Construct {
358
358
  const route = new apig.WebSocketRoute(scope, `Route_${routeKey}`, {
359
359
  webSocketApi: this.cdk.webSocketApi,
360
360
  routeKey,
361
- integration: new apigIntegrations.WebSocketLambdaIntegration(`Integration_${routeKey}`, lambda),
361
+ integration: new WebSocketLambdaIntegration(`Integration_${routeKey}`, lambda),
362
362
  authorizer: routeKey === "$connect" ? authorizer : undefined,
363
363
  });
364
364
  ///////////////////
@@ -1,5 +1,5 @@
1
1
  import { Metric, MetricOptions } from "aws-cdk-lib/aws-cloudwatch";
2
- import { Resource } from "aws-cdk-lib";
2
+ import { Resource } from "aws-cdk-lib/core";
3
3
  import { ICertificate } from "aws-cdk-lib/aws-certificatemanager";
4
4
  /**
5
5
  * Shared implementation details of ICertificate implementations.
@@ -1,5 +1,5 @@
1
1
  import { Metric, Stats } from "aws-cdk-lib/aws-cloudwatch";
2
- import { Duration, Resource } from "aws-cdk-lib";
2
+ import { Duration, Resource } from "aws-cdk-lib/core";
3
3
  /**
4
4
  * Shared implementation details of ICertificate implementations.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  import { Construct } from "constructs";
2
- import { ITaggable, TagManager, RemovalPolicy } from "aws-cdk-lib";
2
+ import { ITaggable, TagManager, RemovalPolicy } from "aws-cdk-lib/core";
3
3
  import { CertificateProps, ICertificate } from "aws-cdk-lib/aws-certificatemanager";
4
4
  import * as iam from "aws-cdk-lib/aws-iam";
5
5
  import * as route53 from "aws-cdk-lib/aws-route53";
@@ -1,6 +1,6 @@
1
1
  import url from "url";
2
2
  import * as path from "path";
3
- import { Token, TagManager, TagType, Duration, Stack, CustomResource, Lazy, } from "aws-cdk-lib";
3
+ import { Token, TagManager, TagType, Duration, Stack, CustomResource, Lazy, } from "aws-cdk-lib/core";
4
4
  import * as iam from "aws-cdk-lib/aws-iam";
5
5
  import * as lambda from "aws-cdk-lib/aws-lambda";
6
6
  import { CertificateBase } from "./certificate-base.js";
@@ -2,7 +2,7 @@ import { CloudFrontWebDistribution, OriginProtocolPolicy, PriceClass, ViewerCert
2
2
  import { ARecord, AaaaRecord, RecordTarget, } from "aws-cdk-lib/aws-route53";
3
3
  import { CloudFrontTarget } from "aws-cdk-lib/aws-route53-targets";
4
4
  import { BlockPublicAccess, Bucket, RedirectProtocol, } from "aws-cdk-lib/aws-s3";
5
- import { ArnFormat, RemovalPolicy, Stack, Token } from "aws-cdk-lib";
5
+ import { ArnFormat, RemovalPolicy, Stack, Token } from "aws-cdk-lib/core";
6
6
  import cdkHelpers from "aws-cdk-lib/core/lib/helpers-internal";
7
7
  import { Construct } from "constructs";
8
8
  import { DnsValidatedCertificate } from "./dns-validated-certificate.js";
@@ -4,7 +4,7 @@ import fs from "fs";
4
4
  import spawn from "cross-spawn";
5
5
  import { execSync } from "child_process";
6
6
  import { Construct } from "constructs";
7
- import { Token, Duration, RemovalPolicy, CustomResource, } from "aws-cdk-lib";
7
+ import { Token, Duration, RemovalPolicy, CustomResource, } from "aws-cdk-lib/core";
8
8
  import * as s3 from "aws-cdk-lib/aws-s3";
9
9
  import { Role, Effect, PolicyStatement, CompositePrincipal, ServicePrincipal, ManagedPolicy, } from "aws-cdk-lib/aws-iam";
10
10
  import * as sqs from "aws-cdk-lib/aws-sqs";
@@ -353,7 +353,7 @@ export class NextjsSite extends Construct {
353
353
  }
354
354
  return fn.currentVersion;
355
355
  }
356
- createEdgeFunctionInNonUE1(name, assetPath, asset, hasRealCode) {
356
+ createEdgeFunctionInNonUE1(name, _assetPath, asset, hasRealCode) {
357
357
  const { defaults } = this.props;
358
358
  // If app region is NOT us-east-1, create a Function in us-east-1
359
359
  // using a Custom Resource
@@ -1,7 +1,7 @@
1
1
  import { Construct } from "constructs";
2
- import * as cdk from "aws-cdk-lib";
2
+ import { CustomResource } from "aws-cdk-lib/core";
3
3
  import * as iam from "aws-cdk-lib/aws-iam";
4
- export declare function getOrCreateBucket(scope: Construct): cdk.CustomResource;
5
- export declare function createFunction(scope: Construct, name: string, role: iam.Role, bucketName: string, functionParams: any): cdk.CustomResource;
6
- export declare function createVersion(scope: Construct, name: string, functionArn: string): cdk.CustomResource;
7
- export declare function updateVersionLogicalId(functionCR: cdk.CustomResource, versionCR: cdk.CustomResource): void;
4
+ export declare function getOrCreateBucket(scope: Construct): CustomResource;
5
+ export declare function createFunction(scope: Construct, name: string, role: iam.Role, bucketName: string, functionParams: any): CustomResource;
6
+ export declare function createVersion(scope: Construct, name: string, functionArn: string): CustomResource;
7
+ export declare function updateVersionLogicalId(functionCR: CustomResource, versionCR: CustomResource): void;
@@ -1,7 +1,7 @@
1
1
  import path from "path";
2
2
  import crypto from "crypto";
3
3
  import url from "url";
4
- import * as cdk from "aws-cdk-lib";
4
+ import { CustomResource, Duration, Lazy, Stack, } from "aws-cdk-lib/core";
5
5
  import * as iam from "aws-cdk-lib/aws-iam";
6
6
  import * as lambda from "aws-cdk-lib/aws-lambda";
7
7
  const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
@@ -9,7 +9,7 @@ export function getOrCreateBucket(scope) {
9
9
  // Do not recreate if exist
10
10
  const providerId = "EdgeLambdaBucketProvider";
11
11
  const resId = "EdgeLambdaBucket";
12
- const stack = cdk.Stack.of(scope);
12
+ const stack = Stack.of(scope);
13
13
  const existingResource = stack.node.tryFindChild(resId);
14
14
  if (existingResource) {
15
15
  return existingResource;
@@ -19,7 +19,7 @@ export function getOrCreateBucket(scope) {
19
19
  code: lambda.Code.fromAsset(path.join(__dirname, "../../support/edge-function")),
20
20
  handler: "s3-bucket.handler",
21
21
  runtime: lambda.Runtime.NODEJS_16_X,
22
- timeout: cdk.Duration.minutes(15),
22
+ timeout: Duration.minutes(15),
23
23
  memorySize: 1024,
24
24
  initialPolicy: [
25
25
  new iam.PolicyStatement({
@@ -30,7 +30,7 @@ export function getOrCreateBucket(scope) {
30
30
  ],
31
31
  });
32
32
  // Create custom resource
33
- const resource = new cdk.CustomResource(stack, resId, {
33
+ const resource = new CustomResource(stack, resId, {
34
34
  serviceToken: provider.functionArn,
35
35
  resourceType: "Custom::SSTEdgeLambdaBucket",
36
36
  properties: {
@@ -43,7 +43,7 @@ export function createFunction(scope, name, role, bucketName, functionParams) {
43
43
  // Do not recreate if exist
44
44
  const providerId = "EdgeLambdaProvider";
45
45
  const resId = `${name}EdgeLambda`;
46
- const stack = cdk.Stack.of(scope);
46
+ const stack = Stack.of(scope);
47
47
  let provider = stack.node.tryFindChild(providerId);
48
48
  // Create provider if not already created
49
49
  if (!provider) {
@@ -51,7 +51,7 @@ export function createFunction(scope, name, role, bucketName, functionParams) {
51
51
  code: lambda.Code.fromAsset(path.join(__dirname, "../../support/edge-function")),
52
52
  handler: "edge-lambda.handler",
53
53
  runtime: lambda.Runtime.NODEJS_16_X,
54
- timeout: cdk.Duration.minutes(15),
54
+ timeout: Duration.minutes(15),
55
55
  memorySize: 1024,
56
56
  initialPolicy: [
57
57
  new iam.PolicyStatement({
@@ -66,11 +66,11 @@ export function createFunction(scope, name, role, bucketName, functionParams) {
66
66
  }
67
67
  }
68
68
  // Create custom resource
69
- const resource = new cdk.CustomResource(scope, resId, {
69
+ const resource = new CustomResource(scope, resId, {
70
70
  serviceToken: provider.functionArn,
71
71
  resourceType: "Custom::SSTEdgeLambda",
72
72
  properties: {
73
- FunctionNamePrefix: `${cdk.Stack.of(scope).stackName}-${resId}`,
73
+ FunctionNamePrefix: `${Stack.of(scope).stackName}-${resId}`,
74
74
  FunctionBucket: bucketName,
75
75
  FunctionParams: functionParams,
76
76
  },
@@ -81,7 +81,7 @@ export function createVersion(scope, name, functionArn) {
81
81
  // Do not recreate if exist
82
82
  const providerId = "EdgeLambdaVersionProvider";
83
83
  const resId = `${name}EdgeLambdaVersion`;
84
- const stack = cdk.Stack.of(scope);
84
+ const stack = Stack.of(scope);
85
85
  let provider = stack.node.tryFindChild(providerId);
86
86
  // Create provider if not already created
87
87
  if (!provider) {
@@ -89,7 +89,7 @@ export function createVersion(scope, name, functionArn) {
89
89
  code: lambda.Code.fromAsset(path.join(__dirname, "../../support/edge-function")),
90
90
  handler: "edge-lambda-version.handler",
91
91
  runtime: lambda.Runtime.NODEJS_16_X,
92
- timeout: cdk.Duration.minutes(15),
92
+ timeout: Duration.minutes(15),
93
93
  memorySize: 1024,
94
94
  initialPolicy: [
95
95
  new iam.PolicyStatement({
@@ -101,7 +101,7 @@ export function createVersion(scope, name, functionArn) {
101
101
  });
102
102
  }
103
103
  // Create custom resource
104
- return new cdk.CustomResource(scope, resId, {
104
+ return new CustomResource(scope, resId, {
105
105
  serviceToken: provider.functionArn,
106
106
  resourceType: "Custom::SSTEdgeLambdaVersion",
107
107
  properties: {
@@ -114,8 +114,8 @@ export function updateVersionLogicalId(functionCR, versionCR) {
114
114
  // hash of the function itself, so a new version resource is created when
115
115
  // the function configuration changes.
116
116
  const cfn = versionCR.node.defaultChild;
117
- const originalLogicalId = cdk.Stack.of(versionCR).resolve(cfn.logicalId);
118
- cfn.overrideLogicalId(cdk.Lazy.uncachedString({
117
+ const originalLogicalId = Stack.of(versionCR).resolve(cfn.logicalId);
118
+ cfn.overrideLogicalId(Lazy.uncachedString({
119
119
  produce: () => {
120
120
  const hash = calculateHash(functionCR);
121
121
  const logicalId = trimFromStart(originalLogicalId, 255 - 32);
@@ -138,7 +138,7 @@ function calculateHash(resource) {
138
138
  // Properties: { ... }
139
139
  // }}}
140
140
  const cfnResource = resource.node.defaultChild;
141
- const config = cdk.Stack.of(resource).resolve(cfnResource._toCloudFormation());
141
+ const config = Stack.of(resource).resolve(cfnResource._toCloudFormation());
142
142
  const resources = config.Resources;
143
143
  const resourceKeys = Object.keys(resources);
144
144
  if (resourceKeys.length !== 1) {
@@ -4,7 +4,7 @@ import { Api } from "../Api.js";
4
4
  import { Stack } from "../Stack.js";
5
5
  import { Secret } from "../Secret.js";
6
6
  import { getParameterPath, } from "../util/functionBinding.js";
7
- import { CustomResource } from "aws-cdk-lib";
7
+ import { CustomResource } from "aws-cdk-lib/core";
8
8
  /**
9
9
  * SST Auth is a lightweight authentication solution for your applications. With a simple set of configuration you can deploy a function attached to your API that can handle various authentication flows. *
10
10
  * @example
@@ -1,4 +1,4 @@
1
- import * as cdk from "aws-cdk-lib";
1
+ import { Token } from "aws-cdk-lib/core";
2
2
  import * as apig from "@aws-cdk/aws-apigatewayv2-alpha";
3
3
  import * as route53 from "aws-cdk-lib/aws-route53";
4
4
  import * as route53Targets from "aws-cdk-lib/aws-route53-targets";
@@ -27,7 +27,7 @@ export function buildCustomDomainData(scope, customDomain) {
27
27
  function buildDataForStringInput(scope, customDomain) {
28
28
  // validate: customDomain is a TOKEN string
29
29
  // ie. imported SSM value: ssm.StringParameter.valueForStringParameter()
30
- if (cdk.Token.isUnresolved(customDomain)) {
30
+ if (Token.isUnresolved(customDomain)) {
31
31
  throw new Error(`You also need to specify the "hostedZone" if the "domainName" is passed in as a reference.`);
32
32
  }
33
33
  assertDomainNameIsLowerCase(customDomain);
@@ -48,7 +48,7 @@ function buildDataForStringInput(scope, customDomain) {
48
48
  function buildDataForInternalDomainInput(scope, customDomain) {
49
49
  // If customDomain is a TOKEN string, "hostedZone" has to be passed in. This
50
50
  // is because "hostedZone" cannot be parsed from a TOKEN value.
51
- if (cdk.Token.isUnresolved(customDomain.domainName)) {
51
+ if (Token.isUnresolved(customDomain.domainName)) {
52
52
  if (!customDomain.hostedZone && !customDomain.cdk?.hostedZone) {
53
53
  throw new Error(`You also need to specify the "hostedZone" if the "domainName" is passed in as a reference.`);
54
54
  }
@@ -109,7 +109,7 @@ function buildDataForExternalDomainInput(scope, customDomain) {
109
109
  throw new Error(`Hosted zones can only be configured for domains hosted on Amazon Route 53. Do not set the "hostedZone" when "isExternalDomain" is enabled.`);
110
110
  }
111
111
  // If domain is not a token, ensure it is lower case
112
- if (!cdk.Token.isUnresolved(customDomain.domainName)) {
112
+ if (!Token.isUnresolved(customDomain.domainName)) {
113
113
  assertDomainNameIsLowerCase(customDomain.domainName);
114
114
  }
115
115
  const domainName = customDomain.domainName;
@@ -125,7 +125,7 @@ function buildDataForExternalDomainInput(scope, customDomain) {
125
125
  url: buildDomainUrl(domainName, mappingKey),
126
126
  };
127
127
  }
128
- function buildDataForConstructInput(scope, customDomain) {
128
+ function buildDataForConstructInput(_scope, customDomain) {
129
129
  // Allow user passing in `apigDomain` object. The use case is a user creates
130
130
  // multiple API endpoints, and is mapping them under the same custom domain.
131
131
  // `sst.Api` needs to expose the `apigDomain` construct created in the first
@@ -181,7 +181,7 @@ function createARecords(scope, hostedZone, domainName, apigDomain) {
181
181
  // This is because the construct tries to check if the record name
182
182
  // ends with the domain name. If not, it will append the domain name.
183
183
  // So, we need remove this behavior.
184
- if (cdk.Token.isUnresolved(domainName)) {
184
+ if (Token.isUnresolved(domainName)) {
185
185
  records.forEach((record) => {
186
186
  const cfnRecord = record.node.defaultChild;
187
187
  cfnRecord.name = domainName;
@@ -1,4 +1,4 @@
1
- import { Token } from "aws-cdk-lib";
1
+ import { Token } from "aws-cdk-lib/core";
2
2
  import * as route53 from "aws-cdk-lib/aws-route53";
3
3
  import * as route53Targets from "aws-cdk-lib/aws-route53-targets";
4
4
  import * as acm from "aws-cdk-lib/aws-certificatemanager";
@@ -85,7 +85,7 @@ function buildDataForInternalDomainInput(scope, customDomain) {
85
85
  recordType: customDomain.recordType,
86
86
  };
87
87
  }
88
- function buildDataForExternalDomainInput(scope, customDomain) {
88
+ function buildDataForExternalDomainInput(_scope, customDomain) {
89
89
  // if it is external, then a certificate is required
90
90
  if (!customDomain.cdk?.certificate) {
91
91
  throw new Error(`A valid certificate is required when "isExternalDomain" is set to "true".`);
@@ -1,3 +1,3 @@
1
- import { Duration as CDKDuration } from "aws-cdk-lib";
1
+ import { Duration as CDKDuration } from "aws-cdk-lib/core";
2
2
  export type Duration = `${number} ${"second" | "seconds" | "minute" | "minutes" | "hour" | "hours" | "day" | "days"}`;
3
3
  export declare function toCdkDuration(duration: Duration): CDKDuration;
@@ -1,4 +1,4 @@
1
- import { Duration as CDKDuration } from "aws-cdk-lib";
1
+ import { Duration as CDKDuration } from "aws-cdk-lib/core";
2
2
  export function toCdkDuration(duration) {
3
3
  const [count, unit] = duration.split(" ");
4
4
  const countNum = parseInt(count);
@@ -1,3 +1,3 @@
1
- import * as cdk from "aws-cdk-lib";
1
+ import { Size as CDKSize } from "aws-cdk-lib/core";
2
2
  export type Size = `${number} ${"MB" | "GB"}`;
3
- export declare function toCdkSize(size: Size): cdk.Size;
3
+ export declare function toCdkSize(size: Size): CDKSize;
@@ -1,12 +1,12 @@
1
- import * as cdk from "aws-cdk-lib";
1
+ import { Size as CDKSize } from "aws-cdk-lib/core";
2
2
  export function toCdkSize(size) {
3
3
  const [count, unit] = size.split(" ");
4
4
  const countNum = parseInt(count);
5
5
  if (unit === "MB") {
6
- return cdk.Size.mebibytes(countNum);
6
+ return CDKSize.mebibytes(countNum);
7
7
  }
8
8
  else if (unit === "GB") {
9
- return cdk.Size.gibibytes(countNum);
9
+ return CDKSize.gibibytes(countNum);
10
10
  }
11
11
  throw new Error(`Invalid size ${size}`);
12
12
  }
package/logger.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import fs from "fs/promises";
2
2
  import path from "path";
3
3
  import { Context } from "./context/context.js";
4
+ import { useProject } from "./project.js";
4
5
  let previous = new Date();
5
6
  const useFile = Context.memo(async () => {
6
- const { useProject } = await import("./project.js");
7
7
  const project = useProject();
8
8
  const filePath = path.join(project.paths.out, "debug.log");
9
9
  const file = await fs.open(filePath, "w");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.11.5",
4
+ "version": "2.11.6",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },
package/project.js CHANGED
@@ -26,18 +26,22 @@ const CONFIG_EXTENSIONS = [
26
26
  ".config.js",
27
27
  ];
28
28
  export async function initProject(globals) {
29
+ // Logger.debug("initing project");
29
30
  const root = globals.root || (await findRoot());
30
31
  const out = path.join(root, ".sst");
31
32
  await fs.mkdir(out, {
32
33
  recursive: true,
33
34
  });
35
+ // Logger.debug("made out dir");
34
36
  let file;
35
37
  const [metafile, sstConfig] = await (async function () {
36
38
  for (const ext of CONFIG_EXTENSIONS) {
37
39
  file = path.join(root, "sst" + ext);
38
40
  if (!fsSync.existsSync(file))
39
41
  continue;
42
+ // Logger.debug("found sst config");
40
43
  const [metafile, config] = await load(file);
44
+ // Logger.debug("loaded sst config");
41
45
  return [metafile, config];
42
46
  }
43
47
  throw new VisibleError("Could not found a configuration file", "Make sure one of the following exists", ...CONFIG_EXTENSIONS.map((x) => ` - sst${x}`));
@@ -87,6 +91,7 @@ export async function initProject(globals) {
87
91
  artifacts: path.join(out, "artifacts"),
88
92
  },
89
93
  };
94
+ ProjectContext.provide(project);
90
95
  // Cleanup old config files
91
96
  (async function () {
92
97
  const files = await fs.readdir(project.paths.root);
@@ -103,7 +108,6 @@ export async function initProject(globals) {
103
108
  }
104
109
  }
105
110
  })();
106
- ProjectContext.provide(project);
107
111
  dotenv.config({
108
112
  path: path.join(project.paths.root, `.env.${project.config.stage}`),
109
113
  override: true,
@@ -1,5 +1,5 @@
1
1
  import { Runtime } from "aws-cdk-lib/aws-lambda";
2
- import { AssetHashType } from "aws-cdk-lib";
2
+ import { AssetHashType } from "aws-cdk-lib/core";
3
3
  /**
4
4
  * Dependency files to exclude from the asset hash.
5
5
  */
@@ -4,7 +4,7 @@
4
4
  import fs from "fs";
5
5
  import url from "url";
6
6
  import path from "path";
7
- import { DockerImage, FileSystem, } from "aws-cdk-lib";
7
+ import { DockerImage, FileSystem } from "aws-cdk-lib/core";
8
8
  const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
9
9
  /**
10
10
  * Dependency files to exclude from the asset hash.
package/sst.mjs CHANGED
@@ -118,10 +118,10 @@ var init_logger = __esm({
118
118
  "src/logger.ts"() {
119
119
  "use strict";
120
120
  init_context();
121
+ init_project();
121
122
  previous = new Date();
122
123
  useFile = Context.memo(async () => {
123
- const { useProject: useProject2 } = await Promise.resolve().then(() => (init_project(), project_exports));
124
- const project = useProject2();
124
+ const project = useProject();
125
125
  const filePath = path.join(project.paths.out, "debug.log");
126
126
  const file = await fs.open(filePath, "w");
127
127
  return file;
@@ -393,6 +393,7 @@ async function initProject(globals) {
393
393
  artifacts: path4.join(out, "artifacts")
394
394
  }
395
395
  };
396
+ ProjectContext.provide(project);
396
397
  (async function() {
397
398
  const files = await fs4.readdir(project.paths.root);
398
399
  for (const file2 of files) {
@@ -406,7 +407,6 @@ async function initProject(globals) {
406
407
  }
407
408
  }
408
409
  })();
409
- ProjectContext.provide(project);
410
410
  dotenv.config({
411
411
  path: path4.join(project.paths.root, `.env.${project.config.stage}`),
412
412
  override: true
@@ -4645,10 +4645,7 @@ var init_rust = __esm({
4645
4645
  import fs11 from "fs";
4646
4646
  import url5 from "url";
4647
4647
  import path11 from "path";
4648
- import {
4649
- DockerImage,
4650
- FileSystem
4651
- } from "aws-cdk-lib";
4648
+ import { DockerImage, FileSystem } from "aws-cdk-lib/core";
4652
4649
  function bundle(options) {
4653
4650
  const { entry, runtime, outputPathSuffix, installCommands } = options;
4654
4651
  const stagedir = FileSystem.mkdtemp("python-bundling-");
@@ -5199,7 +5196,7 @@ import {
5199
5196
  Tags,
5200
5197
  Stack,
5201
5198
  RemovalPolicy
5202
- } from "aws-cdk-lib";
5199
+ } from "aws-cdk-lib/core";
5203
5200
  import { Function, Runtime as Runtime2, Code } from "aws-cdk-lib/aws-lambda";
5204
5201
  import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
5205
5202
  import { PolicyStatement } from "aws-cdk-lib/aws-iam";
@@ -8253,10 +8250,15 @@ var telemetry = (program2) => program2.command(
8253
8250
  );
8254
8251
 
8255
8252
  // src/cli/commands/connect.ts
8253
+ init_colors();
8256
8254
  var connect = (program2) => program2.command(
8257
8255
  "connect",
8258
- "",
8259
- (yargs2) => yargs2,
8256
+ "Connect a stage to SST Console",
8257
+ (yargs2) => yargs2.option("dev", {
8258
+ type: "boolean",
8259
+ default: false,
8260
+ describe: "Connect to SST dev account (probably don't want to do this)"
8261
+ }),
8260
8262
  async (args) => {
8261
8263
  if (!args.future)
8262
8264
  throw new Error("This command is not yet available.");
@@ -8265,6 +8267,12 @@ var connect = (program2) => program2.command(
8265
8267
  const { useSTSIdentity: useSTSIdentity2 } = await Promise.resolve().then(() => (init_credentials(), credentials_exports));
8266
8268
  const { IAMClient, CreateRoleCommand, AttachRolePolicyCommand } = await import("@aws-sdk/client-iam");
8267
8269
  const client = useAWSClient2(IAMClient);
8270
+ if (args.dev) {
8271
+ Colors.line(
8272
+ Colors.warning("\u26A0"),
8273
+ Colors.bold(" Connecting to dev stage")
8274
+ );
8275
+ }
8268
8276
  await client.send(
8269
8277
  new CreateRoleCommand({
8270
8278
  RoleName: "sst",
@@ -8274,7 +8282,7 @@ var connect = (program2) => program2.command(
8274
8282
  {
8275
8283
  Effect: "Allow",
8276
8284
  Principal: {
8277
- AWS: "arn:aws:iam::917397401067:role/*"
8285
+ AWS: `arn:aws:iam::${args.dev ? "917397401067" : "226609089145"}:root`
8278
8286
  },
8279
8287
  Action: "sts:AssumeRole"
8280
8288
  }
@@ -8294,8 +8302,9 @@ var connect = (program2) => program2.command(
8294
8302
  );
8295
8303
  const project = useProject2();
8296
8304
  const identity = await useSTSIdentity2();
8305
+ const host = args.dev ? "http://localhost:3000" : "https://console.production.sst.dev";
8297
8306
  console.log(
8298
- `http://localhost:3000/connect?app=${project.config.name}&stage=${project.config.stage}&aws_account_id=${identity.Account}&region=${project.config.region}`
8307
+ `${host}/connect?app=${project.config.name}&stage=${project.config.stage}&aws_account_id=${identity.Account}&region=${project.config.region}`
8299
8308
  );
8300
8309
  }
8301
8310
  );
package/stacks/build.js CHANGED
@@ -12,6 +12,7 @@ export async function load(input) {
12
12
  const outfile = path.join(parsed.dir, `.${parsed.name}.${Date.now()}.mjs`);
13
13
  const pkg = JSON.parse(await fs.readFile(path.join(root, "package.json")).then((x) => x.toString()));
14
14
  try {
15
+ // Logger.debug("running esbuild on", input);
15
16
  const result = await esbuild.build({
16
17
  keepNames: true,
17
18
  bundle: true,
@@ -43,7 +44,9 @@ export async function load(input) {
43
44
  // import from "buildDir" without needing to pass "anything" around.
44
45
  entryPoints: [input],
45
46
  });
47
+ // Logger.debug("built", input);
46
48
  const mod = await dynamicImport(outfile);
49
+ // Logger.debug("imported", input);
47
50
  await fs.rm(outfile, {
48
51
  force: true,
49
52
  });