sst 2.41.5 → 2.43.0

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.
@@ -7,6 +7,7 @@ import { ISDK } from "sst-aws-cdk/lib/api/aws-auth/sdk.js";
7
7
  import { SdkProvider } from "sst-aws-cdk/lib/api/aws-auth/sdk-provider.js";
8
8
  import { DeployStackResult, DeploymentMethod } from "./deploy-stack.js";
9
9
  import { EnvironmentResources } from "sst-aws-cdk/lib/api/environment-resources.js";
10
+ import { RootTemplateWithNestedStacks } from "sst-aws-cdk/lib/api/nested-stack-helpers.js";
10
11
  import { Template, ResourcesToImport, ResourceIdentifierSummaries } from "sst-aws-cdk/lib/api/util/cloudformation.js";
11
12
  import { StackActivityProgress } from "sst-aws-cdk/lib/api/util/cloudformation/stack-activity-monitor.js";
12
13
  import { HotswapMode } from "sst-aws-cdk/lib/api/hotswap/common.js";
@@ -219,6 +220,7 @@ export interface DestroyStackOptions {
219
220
  export interface StackExistsOptions {
220
221
  stack: cxapi.CloudFormationStackArtifact;
221
222
  deployName?: string;
223
+ tryLookupRole?: boolean;
222
224
  }
223
225
  export interface DeploymentsProps {
224
226
  sdkProvider: SdkProvider;
@@ -266,7 +268,7 @@ export declare class Deployments {
266
268
  * Resolves the environment for a stack.
267
269
  */
268
270
  resolveEnvironment(stack: cxapi.CloudFormationStackArtifact): Promise<cxapi.Environment>;
269
- readCurrentTemplateWithNestedStacks(rootStackArtifact: cxapi.CloudFormationStackArtifact, retrieveProcessedTemplate?: boolean): Promise<Template>;
271
+ readCurrentTemplateWithNestedStacks(rootStackArtifact: cxapi.CloudFormationStackArtifact, retrieveProcessedTemplate?: boolean): Promise<RootTemplateWithNestedStacks>;
270
272
  readCurrentTemplate(stackArtifact: cxapi.CloudFormationStackArtifact): Promise<Template>;
271
273
  resourceIdentifierSummaries(stackArtifact: cxapi.CloudFormationStackArtifact): Promise<ResourceIdentifierSummaries>;
272
274
  deployStack(options: DeployStackOptions): Promise<DeployStackResult | undefined>;
@@ -2,12 +2,12 @@
2
2
  import * as cxapi from "@aws-cdk/cx-api";
3
3
  import * as cdk_assets from "cdk-assets";
4
4
  import { AssetManifest } from "cdk-assets";
5
- import { debug, warning } from "sst-aws-cdk/lib/logging.js";
5
+ import { debug, warning, error } from "sst-aws-cdk/lib/logging.js";
6
6
  import { buildAssets, publishAssets, PublishingAws, EVENT_TO_LOGGER, } from "sst-aws-cdk/lib/util/asset-publishing.js";
7
7
  import { Mode } from "sst-aws-cdk/lib/api/aws-auth/credentials.js";
8
8
  import { deployStack, destroyStack, } from "./deploy-stack.js";
9
9
  import { EnvironmentResourcesRegistry, } from "sst-aws-cdk/lib/api/environment-resources.js";
10
- import { loadCurrentTemplateWithNestedStacks, loadCurrentTemplate, flattenNestedStackNames, } from "sst-aws-cdk/lib/api/nested-stack-helpers.js";
10
+ import { loadCurrentTemplateWithNestedStacks, loadCurrentTemplate, } from "sst-aws-cdk/lib/api/nested-stack-helpers.js";
11
11
  import { CloudFormationStack, } from "sst-aws-cdk/lib/api/util/cloudformation.js";
12
12
  import { replaceEnvPlaceholders } from "sst-aws-cdk/lib/api/util/placeholders.js";
13
13
  import { makeBodyParameterAndUpload } from "sst-aws-cdk/lib/api/util/template-body-parameter.js";
@@ -36,11 +36,7 @@ export class Deployments {
36
36
  async readCurrentTemplateWithNestedStacks(rootStackArtifact, retrieveProcessedTemplate = false) {
37
37
  const sdk = (await this.prepareSdkWithLookupOrDeployRole(rootStackArtifact))
38
38
  .stackSdk;
39
- const templateWithNestedStacks = await loadCurrentTemplateWithNestedStacks(rootStackArtifact, sdk, retrieveProcessedTemplate);
40
- return {
41
- deployedTemplate: templateWithNestedStacks.deployedTemplate,
42
- nestedStackCount: flattenNestedStackNames(templateWithNestedStacks.nestedStackNames).length,
43
- };
39
+ return loadCurrentTemplateWithNestedStacks(rootStackArtifact, sdk, retrieveProcessedTemplate);
44
40
  }
45
41
  async readCurrentTemplate(stackArtifact) {
46
42
  debug(`Reading existing template for stack ${stackArtifact.displayName}.`);
@@ -126,7 +122,14 @@ export class Deployments {
126
122
  });
127
123
  }
128
124
  async stackExists(options) {
129
- const { stackSdk } = await this.prepareSdkFor(options.stack, undefined, Mode.ForReading);
125
+ let stackSdk;
126
+ if (options.tryLookupRole) {
127
+ stackSdk = (await this.prepareSdkWithLookupOrDeployRole(options.stack))
128
+ .stackSdk;
129
+ }
130
+ else {
131
+ stackSdk = (await this.prepareSdkFor(options.stack, undefined, Mode.ForReading)).stackSdk;
132
+ }
130
133
  const stack = await CloudFormationStack.lookup(stackSdk.cloudFormation(), options.deployName ?? options.stack.stackName);
131
134
  return stack.exists;
132
135
  }
@@ -206,8 +209,8 @@ export class Deployments {
206
209
  }, resolvedEnvironment, this.sdkProvider);
207
210
  // try to assume the lookup role
208
211
  const warningMessage = `Could not assume ${arns.lookupRoleArn}, proceeding anyway.`;
209
- const upgradeMessage = `(To get rid of this warning, please upgrade to bootstrap version >= ${stack.lookupRole?.requiresBootstrapStackVersion})`;
210
212
  try {
213
+ // Trying to assume lookup role and cache the sdk for the environment
211
214
  const stackSdk = await this.cachedSdkForEnvironment(resolvedEnvironment, Mode.ForReading, {
212
215
  assumeRoleArn: arns.lookupRoleArn,
213
216
  assumeRoleExternalId: stack.lookupRole?.assumeRoleExternalId,
@@ -219,24 +222,24 @@ export class Deployments {
219
222
  stack.lookupRole.requiresBootstrapStackVersion) {
220
223
  const version = await envResources.versionFromSsmParameter(stack.lookupRole.bootstrapStackVersionSsmParameter);
221
224
  if (version < stack.lookupRole.requiresBootstrapStackVersion) {
222
- throw new Error(`Bootstrap stack version '${stack.lookupRole.requiresBootstrapStackVersion}' is required, found version '${version}'.`);
225
+ throw new Error(`Bootstrap stack version '${stack.lookupRole.requiresBootstrapStackVersion}' is required, found version '${version}'. To get rid of this error, please upgrade to bootstrap version >= ${stack.lookupRole.requiresBootstrapStackVersion}`);
223
226
  }
224
- // we may not have assumed the lookup role because one was not provided
225
- // if that is the case then don't print the upgrade warning
226
227
  }
227
- else if (!stackSdk.didAssumeRole &&
228
- stack.lookupRole?.requiresBootstrapStackVersion) {
229
- warning(upgradeMessage);
228
+ else if (!stackSdk.didAssumeRole) {
229
+ const lookUpRoleExists = stack.lookupRole ? true : false;
230
+ warning(`Lookup role ${lookUpRoleExists ? "exists but" : "does not exist, hence"} was not assumed. Proceeding with default credentials.`);
230
231
  }
231
232
  return { ...stackSdk, resolvedEnvironment, envResources };
232
233
  }
233
234
  catch (e) {
234
235
  debug(e);
235
- // only print out the warnings if the lookupRole exists AND there is a required
236
- // bootstrap version, otherwise the warnings will print `undefined`
237
- if (stack.lookupRole && stack.lookupRole.requiresBootstrapStackVersion) {
236
+ // only print out the warnings if the lookupRole exists
237
+ if (stack.lookupRole) {
238
238
  warning(warningMessage);
239
- warning(upgradeMessage);
239
+ }
240
+ // This error should be shown even if debug mode is off
241
+ if (e instanceof Error && e.message.includes("Bootstrap stack version")) {
242
+ error(e.message);
240
243
  }
241
244
  throw e;
242
245
  }
@@ -18,38 +18,9 @@ export declare class AstroSite extends SsrSite {
18
18
  private static getBuildMeta;
19
19
  private static getCFRoutingFunction;
20
20
  protected plan(): {
21
- cloudFrontFunctions?: Record<string, {
22
- constructId: string;
23
- injections: string[];
24
- }> | undefined;
25
- edgeFunctions?: Record<string, {
26
- constructId: string;
27
- function: import("./EdgeFunction.js").EdgeFunctionProps;
28
- }> | undefined;
29
- origins: Record<string, {
30
- type: "function";
31
- constructId: string;
32
- function: import("./SsrFunction.js").SsrFunctionProps;
33
- injections?: string[] | undefined;
34
- streaming?: boolean | undefined;
35
- } | {
36
- type: "image-optimization-function";
37
- function: import("aws-cdk-lib/aws-lambda").FunctionProps;
38
- } | {
39
- type: "s3";
40
- originPath?: string | undefined;
41
- copy: {
42
- from: string;
43
- to: string;
44
- cached: boolean;
45
- versionedSubDir?: string | undefined;
46
- }[];
47
- } | {
48
- type: "group";
49
- primaryOriginName: string;
50
- fallbackOriginName: string;
51
- fallbackStatusCodes?: number[] | undefined;
52
- }>;
21
+ cloudFrontFunctions?: Record<string, import("./SsrSite.js").CloudFrontFunctionConfig> | undefined;
22
+ edgeFunctions?: Record<string, import("./SsrSite.js").EdgeFunctionConfig> | undefined;
23
+ origins: Record<string, import("./SsrSite.js").FunctionOriginConfig | import("./SsrSite.js").ImageOptimizationFunctionOriginConfig | import("./SsrSite.js").S3OriginConfig | import("./SsrSite.js").OriginGroupConfig>;
53
24
  edge: boolean;
54
25
  behaviors: {
55
26
  cacheType: "server" | "static";
@@ -64,6 +35,9 @@ export declare class AstroSite extends SsrSite {
64
35
  allowedHeaders?: string[] | undefined;
65
36
  } | undefined;
66
37
  buildId?: string | undefined;
38
+ warmer?: {
39
+ function: string;
40
+ } | undefined;
67
41
  };
68
42
  getConstructMetadata(): {
69
43
  data: {
@@ -49,8 +49,8 @@ const supportedRuntimes = {
49
49
  java11: CDKRuntime.JAVA_11,
50
50
  java17: CDKRuntime.JAVA_17,
51
51
  java21: CDKRuntime.JAVA_21,
52
- "go1.x": CDKRuntime.PROVIDED_AL2,
53
- go: CDKRuntime.PROVIDED_AL2,
52
+ "go1.x": CDKRuntime.PROVIDED_AL2023,
53
+ go: CDKRuntime.PROVIDED_AL2023,
54
54
  };
55
55
  /**
56
56
  * The `Function` construct is a higher level CDK construct that makes it easy to create a Lambda Function with support for Live Lambda Development.
@@ -1,9 +1,18 @@
1
1
  import { Construct } from "constructs";
2
- import { Runtime, FunctionProps, Architecture } from "aws-cdk-lib/aws-lambda";
3
- import { SsrSite, SsrSiteNormalizedProps, SsrSiteProps } from "./SsrSite.js";
2
+ import { Runtime, FunctionProps as CdkFunctionProps, Architecture } from "aws-cdk-lib/aws-lambda";
3
+ import { EdgeFunctionConfig, FunctionOriginConfig, SsrSite, SsrSiteNormalizedProps, SsrSiteProps } from "./SsrSite.js";
4
4
  import { Size } from "./util/size.js";
5
5
  import { Bucket } from "aws-cdk-lib/aws-s3";
6
- import { CachePolicyProps } from "aws-cdk-lib/aws-cloudfront";
6
+ type OpenNextS3Origin = {
7
+ type: "s3";
8
+ originPath: string;
9
+ copy: {
10
+ from: string;
11
+ to: string;
12
+ cached: boolean;
13
+ versionedSubDir?: string;
14
+ }[];
15
+ };
7
16
  export interface NextjsSiteProps extends Omit<SsrSiteProps, "nodejs"> {
8
17
  /**
9
18
  * OpenNext version for building the Next.js site.
@@ -14,17 +23,6 @@ export interface NextjsSiteProps extends Omit<SsrSiteProps, "nodejs"> {
14
23
  * ```
15
24
  */
16
25
  openNextVersion?: string;
17
- /**
18
- * How the logs are stored in CloudWatch
19
- * - "combined" - Logs from all routes are stored in the same log group.
20
- * - "per-route" - Logs from each route are stored in a separate log group.
21
- * @default "per-route"
22
- * @example
23
- * ```js
24
- * logging: "combined",
25
- * ```
26
- */
27
- logging?: "combined" | "per-route";
28
26
  /**
29
27
  * The server function is deployed to Lambda in a single region. Alternatively, you can enable this option to deploy to Lambda@Edge.
30
28
  * @default false
@@ -42,59 +40,20 @@ export interface NextjsSiteProps extends Omit<SsrSiteProps, "nodejs"> {
42
40
  * ```
43
41
  */
44
42
  memorySize?: number | Size;
45
- };
46
- openNext?: {
47
- /**
48
- * Specify a custom build output path for cases when running OpenNext from
49
- * a monorepo with decentralized build output. This is passed to the
50
- * `--build-output-path` flag of OpenNext.
51
- * @default Default build output path
52
- * @example
53
- * ```js
54
- * buildOutputPath: "dist/apps/example-app"
55
- * ```
56
- */
57
- buildOutputPath?: string;
58
- };
59
- experimental?: {
60
- /**
61
- * Enable streaming. Currently an experimental feature in OpenNext.
62
- * @default false
63
- * @example
64
- * ```js
65
- * experimental: {
66
- * streaming: true,
67
- * }
68
- * ```
69
- */
70
- streaming?: boolean;
71
43
  /**
72
- * Disabling incremental cache will cause the entire page to be revalidated on each request. This can result in ISR and SSG pages to be in an inconsistent state. Specify this option if you are using SSR pages only.
73
- *
74
- * Note that it is possible to disable incremental cache while leaving on-demand revalidation enabled.
44
+ * If set to true, already computed image will return 304 Not Modified.
45
+ * This means that image needs to be immutable, the etag will be computed based on the image href, format and width and the next BUILD_ID.
75
46
  * @default false
76
47
  * @example
77
48
  * ```js
78
- * experimental: {
79
- * disableIncrementalCache: true,
80
- * }
81
- * ```
82
- */
83
- disableIncrementalCache?: boolean;
84
- /**
85
- * Disabling DynamoDB cache will cause on-demand revalidation by path (`revalidatePath`) and by cache tag (`revalidateTag`) to fail silently.
86
- * @default false
87
- * @example
88
- * ```js
89
- * experimental: {
90
- * disableDynamoDBCache: true,
49
+ * imageOptimization: {
50
+ * staticImageOptimization: true,
91
51
  * }
92
- * ```
93
52
  */
94
- disableDynamoDBCache?: boolean;
53
+ staticImageOptimization?: boolean;
95
54
  };
96
55
  cdk?: SsrSiteProps["cdk"] & {
97
- revalidation?: Pick<FunctionProps, "vpc" | "vpcSubnets">;
56
+ revalidation?: Pick<CdkFunctionProps, "vpc" | "vpcSubnets">;
98
57
  /**
99
58
  * Override the CloudFront cache policy properties for responses from the
100
59
  * server rendering Lambda.
@@ -145,8 +104,11 @@ export declare class NextjsSite extends SsrSite {
145
104
  private appPathsManifest?;
146
105
  private pagesManifest?;
147
106
  private prerenderManifest?;
148
- constructor(scope: Construct, id: string, rawProps?: NextjsSiteProps);
149
- static buildDefaultServerCachePolicyProps(): CachePolicyProps;
107
+ private openNextOutput?;
108
+ constructor(scope: Construct, id: string, props?: NextjsSiteProps);
109
+ private createFunctionOrigin;
110
+ private createEcsOrigin;
111
+ private createEdgeOrigin;
150
112
  protected plan(bucket: Bucket): {
151
113
  cloudFrontFunctions?: {
152
114
  serverCfFunction: {
@@ -154,26 +116,11 @@ export declare class NextjsSite extends SsrSite {
154
116
  injections: string[];
155
117
  };
156
118
  } | undefined;
157
- edgeFunctions?: {
158
- edgeServer: {
159
- constructId: string;
160
- function: {
161
- description: string;
162
- bundle: string;
163
- handler: string;
164
- environment: {
165
- CACHE_BUCKET_NAME: string;
166
- CACHE_BUCKET_KEY_PREFIX: string;
167
- CACHE_BUCKET_REGION: string;
168
- };
169
- layers: import("aws-cdk-lib/aws-lambda").ILayerVersion[] | undefined;
170
- };
171
- };
172
- } | undefined;
119
+ edgeFunctions?: Record<string, EdgeFunctionConfig> | undefined;
173
120
  origins: {
121
+ s3: OpenNextS3Origin;
174
122
  imageOptimizer: {
175
123
  type: "image-optimization-function";
176
- constructId: string;
177
124
  function: {
178
125
  description: string;
179
126
  handler: string;
@@ -181,73 +128,39 @@ export declare class NextjsSite extends SsrSite {
181
128
  runtime: Runtime;
182
129
  architecture: Architecture;
183
130
  environment: {
131
+ OPENNEXT_STATIC_ETAG?: string | undefined;
184
132
  BUCKET_NAME: string;
185
133
  BUCKET_KEY_PREFIX: string;
186
134
  };
135
+ permissions: string[];
187
136
  memorySize: number;
188
137
  };
189
138
  };
190
- s3: {
191
- type: "s3";
192
- originPath: string;
193
- copy: ({
194
- from: string;
195
- to: string;
196
- cached: true;
197
- versionedSubDir: string;
198
- } | {
199
- from: string;
200
- to: string;
201
- cached: false;
202
- versionedSubDir?: undefined;
203
- })[];
204
- };
205
- regionalServer?: {
206
- type: "function";
207
- constructId: string;
208
- function: {
209
- description: string;
210
- bundle: string;
211
- handler: string;
212
- environment: {
213
- CACHE_BUCKET_NAME: string;
214
- CACHE_BUCKET_KEY_PREFIX: string;
215
- CACHE_BUCKET_REGION: string;
216
- };
217
- layers: import("aws-cdk-lib/aws-lambda").ILayerVersion[] | undefined;
218
- };
219
- streaming: boolean | undefined;
220
- injections: string[];
221
- } | undefined;
139
+ default: FunctionOriginConfig;
222
140
  };
223
141
  edge: boolean;
224
142
  behaviors: {
225
143
  cacheType: "server" | "static";
226
144
  pattern?: string | undefined;
227
- origin: "s3" | "regionalServer" | "imageOptimizer";
145
+ origin: "default" | "s3" | "imageOptimizer";
228
146
  allowedMethods?: import("aws-cdk-lib/aws-cloudfront").AllowedMethods | undefined;
229
147
  cfFunction?: "serverCfFunction" | undefined;
230
- edgeFunction?: "edgeServer" | undefined;
148
+ edgeFunction?: string | undefined;
231
149
  }[];
232
150
  errorResponses?: import("aws-cdk-lib/aws-cloudfront").ErrorResponse[] | undefined;
233
151
  serverCachePolicy?: {
234
152
  allowedHeaders?: string[] | undefined;
235
153
  } | undefined;
236
154
  buildId?: string | undefined;
155
+ warmer?: {
156
+ function: string;
157
+ } | undefined;
237
158
  };
238
- private prefixPattern;
159
+ private setMiddlewareEnv;
239
160
  private createRevalidationQueue;
240
161
  private createRevalidationTable;
241
162
  getConstructMetadata(): {
242
- type: "NextjsSite";
243
163
  data: {
244
- routes: {
245
- logGroupPrefix: string;
246
- data: {
247
- route: string;
248
- logGroupPath: string;
249
- }[];
250
- } | undefined;
251
164
  mode: "placeholder" | "deployed";
252
165
  path: string;
253
166
  runtime: "nodejs16.x" | "nodejs18.x" | "nodejs20.x";
@@ -258,23 +171,20 @@ export declare class NextjsSite extends SsrSite {
258
171
  secrets: string[];
259
172
  prefetchSecrets: boolean | undefined;
260
173
  };
174
+ type: "NextjsSite";
261
175
  };
262
- private removeSourcemaps;
263
176
  private useRoutes;
264
177
  private useRoutesManifest;
265
178
  private useAppPathRoutesManifest;
266
179
  private useAppPathsManifest;
267
180
  private usePagesManifest;
268
181
  private usePrerenderManifest;
269
- private useServerFunctionPerRouteLoggingInjection;
270
- private useCloudFrontFunctionPrerenderBypassHeaderInjection;
182
+ private useCloudFrontFunctionCacheHeaderKey;
183
+ private useCloudfrontGeoHeadersInjection;
271
184
  private getBuildId;
272
185
  private getSourcemapForAppRoute;
273
186
  private getSourcemapForPagesRoute;
274
- private isPerRouteLoggingEnabled;
275
187
  private handleMissingSourcemap;
276
- private disableDefaultLogging;
277
- private uploadSourcemaps;
278
188
  private static buildCloudWatchRouteName;
279
189
  private static buildCloudWatchRouteHash;
280
190
  static _test: {