sst 2.11.5 → 2.11.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap.js +1 -1
- package/cli/commands/connect.d.ts +2 -0
- package/cli/commands/connect.js +14 -3
- package/constructs/ApiGatewayV1Api.js +9 -9
- package/constructs/App.d.ts +1 -1
- package/constructs/App.js +1 -1
- package/constructs/Auth.js +1 -1
- package/constructs/BaseSite.js +1 -1
- package/constructs/Bucket.d.ts +2 -2
- package/constructs/Construct.d.ts +3 -3
- package/constructs/EdgeFunction.js +1 -1
- package/constructs/Function.d.ts +1 -1
- package/constructs/Function.js +1 -1
- package/constructs/NextjsSite.js +1 -1
- package/constructs/RDS.js +6 -6
- package/constructs/Script.js +3 -3
- package/constructs/SsrFunction.js +1 -1
- package/constructs/SsrSite.js +1 -1
- package/constructs/Stack.d.ts +4 -4
- package/constructs/Stack.js +6 -6
- package/constructs/StaticSite.js +1 -1
- package/constructs/WebSocketApi.js +3 -3
- package/constructs/cdk/certificate-base.d.ts +1 -1
- package/constructs/cdk/certificate-base.js +1 -1
- package/constructs/cdk/dns-validated-certificate.d.ts +1 -1
- package/constructs/cdk/dns-validated-certificate.js +1 -1
- package/constructs/cdk/website-redirect.js +1 -1
- package/constructs/deprecated/NextjsSite.js +2 -2
- package/constructs/deprecated/cross-region-helper.d.ts +5 -5
- package/constructs/deprecated/cross-region-helper.js +14 -14
- package/constructs/future/Auth.js +1 -1
- package/constructs/util/apiGatewayV2Domain.js +6 -6
- package/constructs/util/appSyncApiDomain.js +2 -2
- package/constructs/util/duration.d.ts +1 -1
- package/constructs/util/duration.js +1 -1
- package/constructs/util/size.d.ts +2 -2
- package/constructs/util/size.js +3 -3
- package/logger.js +1 -1
- package/package.json +1 -1
- package/project.js +6 -2
- package/runtime/handlers/pythonBundling.d.ts +1 -1
- package/runtime/handlers/pythonBundling.js +1 -1
- package/sst.mjs +37 -15
- package/stacks/build.d.ts +1 -1
- package/stacks/build.js +16 -2
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";
|
package/cli/commands/connect.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
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:
|
|
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
|
-
|
|
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}®ion=${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 (
|
|
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 (
|
|
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 && !
|
|
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 (
|
|
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
|
-
:
|
|
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
|
-
:
|
|
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
|
-
:
|
|
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(
|
|
702
|
+
createCdkFunction(_scope, routeKey, routeProps, _postfixName) {
|
|
703
703
|
const lambda = routeProps.cdk?.function;
|
|
704
704
|
this.functions[routeKey] = lambda;
|
|
705
705
|
return lambda;
|
package/constructs/App.d.ts
CHANGED
|
@@ -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";
|
package/constructs/Auth.js
CHANGED
|
@@ -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";
|
package/constructs/BaseSite.js
CHANGED
package/constructs/Bucket.d.ts
CHANGED
|
@@ -170,8 +170,8 @@ export interface BucketProps {
|
|
|
170
170
|
*/
|
|
171
171
|
cors?: boolean | BucketCorsRule[];
|
|
172
172
|
/**
|
|
173
|
-
*
|
|
174
|
-
* Note that setting to `
|
|
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
|
|
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
|
|
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
|
|
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";
|
package/constructs/Function.d.ts
CHANGED
|
@@ -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;
|
package/constructs/Function.js
CHANGED
|
@@ -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";
|
package/constructs/NextjsSite.js
CHANGED
|
@@ -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
|
|
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
|
-
?
|
|
212
|
+
? CDKDuration.minutes(0)
|
|
213
213
|
: scaling?.autoPause === true || scaling?.autoPause === undefined
|
|
214
|
-
?
|
|
215
|
-
:
|
|
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:
|
|
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
|
|
317
|
+
new CustomResource(this, "MigrationResource", {
|
|
318
318
|
serviceToken: handler.functionArn,
|
|
319
319
|
resourceType: "Custom::SSTScript",
|
|
320
320
|
properties: {
|
package/constructs/Script.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import url from "url";
|
|
3
3
|
import { Construct } from "constructs";
|
|
4
|
-
import
|
|
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:
|
|
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
|
|
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";
|
package/constructs/SsrSite.js
CHANGED
|
@@ -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";
|
package/constructs/Stack.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
|
-
import
|
|
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 =
|
|
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
|
|
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 |
|
|
122
|
+
addOutputs(outputs: Record<string, string | CfnOutputProps | undefined>): void;
|
|
123
123
|
private createCustomResourceHandler;
|
|
124
124
|
private static buildSynthesizer;
|
|
125
125
|
private static checkForPropsIsConstruct;
|
package/constructs/Stack.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
186
|
-
: new
|
|
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:
|
|
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
|
|
210
|
+
return new DefaultStackSynthesizer({
|
|
211
211
|
qualifier: config.cdk?.qualifier,
|
|
212
212
|
fileAssetsBucketName: config.cdk?.fileAssetsBucketName,
|
|
213
213
|
});
|
package/constructs/StaticSite.js
CHANGED
|
@@ -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
|
|
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 { 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,
|
|
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
|
|
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):
|
|
5
|
-
export declare function createFunction(scope: Construct, name: string, role: iam.Role, bucketName: string, functionParams: any):
|
|
6
|
-
export declare function createVersion(scope: Construct, name: string, functionArn: string):
|
|
7
|
-
export declare function updateVersionLogicalId(functionCR:
|
|
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
|
|
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 =
|
|
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:
|
|
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
|
|
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 =
|
|
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:
|
|
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
|
|
69
|
+
const resource = new CustomResource(scope, resId, {
|
|
70
70
|
serviceToken: provider.functionArn,
|
|
71
71
|
resourceType: "Custom::SSTEdgeLambda",
|
|
72
72
|
properties: {
|
|
73
|
-
FunctionNamePrefix: `${
|
|
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 =
|
|
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:
|
|
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
|
|
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 =
|
|
118
|
-
cfn.overrideLogicalId(
|
|
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 =
|
|
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
|
|
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 (
|
|
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 (
|
|
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 (!
|
|
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(
|
|
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 (
|
|
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(
|
|
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,3 +1,3 @@
|
|
|
1
|
-
import
|
|
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):
|
|
3
|
+
export declare function toCdkSize(size: Size): CDKSize;
|
package/constructs/util/size.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
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
|
|
6
|
+
return CDKSize.mebibytes(countNum);
|
|
7
7
|
}
|
|
8
8
|
else if (unit === "GB") {
|
|
9
|
-
return
|
|
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
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;
|
|
40
|
-
|
|
42
|
+
// Logger.debug("found sst config");
|
|
43
|
+
const [metafile, config] = await load(file, true);
|
|
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,
|
|
@@ -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
|
|
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
|
|
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;
|
|
@@ -239,7 +239,7 @@ var init_fs = __esm({
|
|
|
239
239
|
import esbuild from "esbuild";
|
|
240
240
|
import fs3 from "fs/promises";
|
|
241
241
|
import path3 from "path";
|
|
242
|
-
async function load(input) {
|
|
242
|
+
async function load(input, shallow) {
|
|
243
243
|
const parsed = path3.parse(input);
|
|
244
244
|
const root = await findAbove(input, "package.json");
|
|
245
245
|
if (!root)
|
|
@@ -248,6 +248,12 @@ async function load(input) {
|
|
|
248
248
|
const pkg = JSON.parse(
|
|
249
249
|
await fs3.readFile(path3.join(root, "package.json")).then((x) => x.toString())
|
|
250
250
|
);
|
|
251
|
+
let contents = await fs3.readFile(input).then((x) => x.toString());
|
|
252
|
+
if (shallow)
|
|
253
|
+
contents = contents.replaceAll(
|
|
254
|
+
/stacks\(.*?\)\s*{[\s\S]*?}\s*[,;]/gs,
|
|
255
|
+
"stacks() {},"
|
|
256
|
+
);
|
|
251
257
|
try {
|
|
252
258
|
const result = await esbuild.build({
|
|
253
259
|
keepNames: true,
|
|
@@ -258,6 +264,9 @@ async function load(input) {
|
|
|
258
264
|
metafile: true,
|
|
259
265
|
format: "esm",
|
|
260
266
|
logLevel: "silent",
|
|
267
|
+
define: {
|
|
268
|
+
"process.env.IS_SHALLOW": shallow ? "true" : "false"
|
|
269
|
+
},
|
|
261
270
|
external: [
|
|
262
271
|
"aws-cdk-lib",
|
|
263
272
|
"sst",
|
|
@@ -275,7 +284,11 @@ async function load(input) {
|
|
|
275
284
|
`const require = topLevelCreateRequire(import.meta.url);`
|
|
276
285
|
].join("")
|
|
277
286
|
},
|
|
278
|
-
|
|
287
|
+
stdin: {
|
|
288
|
+
contents,
|
|
289
|
+
loader: "ts",
|
|
290
|
+
resolveDir: path3.dirname(input)
|
|
291
|
+
}
|
|
279
292
|
});
|
|
280
293
|
const mod = await dynamicImport(outfile);
|
|
281
294
|
await fs3.rm(outfile, {
|
|
@@ -343,7 +356,7 @@ async function initProject(globals) {
|
|
|
343
356
|
file = path4.join(root, "sst" + ext);
|
|
344
357
|
if (!fsSync.existsSync(file))
|
|
345
358
|
continue;
|
|
346
|
-
const [metafile2, config2] = await load(file);
|
|
359
|
+
const [metafile2, config2] = await load(file, true);
|
|
347
360
|
return [metafile2, config2];
|
|
348
361
|
}
|
|
349
362
|
throw new VisibleError(
|
|
@@ -393,6 +406,7 @@ async function initProject(globals) {
|
|
|
393
406
|
artifacts: path4.join(out, "artifacts")
|
|
394
407
|
}
|
|
395
408
|
};
|
|
409
|
+
ProjectContext.provide(project);
|
|
396
410
|
(async function() {
|
|
397
411
|
const files = await fs4.readdir(project.paths.root);
|
|
398
412
|
for (const file2 of files) {
|
|
@@ -406,7 +420,6 @@ async function initProject(globals) {
|
|
|
406
420
|
}
|
|
407
421
|
}
|
|
408
422
|
})();
|
|
409
|
-
ProjectContext.provide(project);
|
|
410
423
|
dotenv.config({
|
|
411
424
|
path: path4.join(project.paths.root, `.env.${project.config.stage}`),
|
|
412
425
|
override: true
|
|
@@ -4645,10 +4658,7 @@ var init_rust = __esm({
|
|
|
4645
4658
|
import fs11 from "fs";
|
|
4646
4659
|
import url5 from "url";
|
|
4647
4660
|
import path11 from "path";
|
|
4648
|
-
import {
|
|
4649
|
-
DockerImage,
|
|
4650
|
-
FileSystem
|
|
4651
|
-
} from "aws-cdk-lib";
|
|
4661
|
+
import { DockerImage, FileSystem } from "aws-cdk-lib/core";
|
|
4652
4662
|
function bundle(options) {
|
|
4653
4663
|
const { entry, runtime, outputPathSuffix, installCommands } = options;
|
|
4654
4664
|
const stagedir = FileSystem.mkdtemp("python-bundling-");
|
|
@@ -5199,7 +5209,7 @@ import {
|
|
|
5199
5209
|
Tags,
|
|
5200
5210
|
Stack,
|
|
5201
5211
|
RemovalPolicy
|
|
5202
|
-
} from "aws-cdk-lib";
|
|
5212
|
+
} from "aws-cdk-lib/core";
|
|
5203
5213
|
import { Function, Runtime as Runtime2, Code } from "aws-cdk-lib/aws-lambda";
|
|
5204
5214
|
import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
|
|
5205
5215
|
import { PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
@@ -8253,10 +8263,15 @@ var telemetry = (program2) => program2.command(
|
|
|
8253
8263
|
);
|
|
8254
8264
|
|
|
8255
8265
|
// src/cli/commands/connect.ts
|
|
8266
|
+
init_colors();
|
|
8256
8267
|
var connect = (program2) => program2.command(
|
|
8257
8268
|
"connect",
|
|
8258
|
-
"",
|
|
8259
|
-
(yargs2) => yargs2,
|
|
8269
|
+
"Connect a stage to SST Console",
|
|
8270
|
+
(yargs2) => yargs2.option("dev", {
|
|
8271
|
+
type: "boolean",
|
|
8272
|
+
default: false,
|
|
8273
|
+
describe: "Connect to SST dev account (probably don't want to do this)"
|
|
8274
|
+
}),
|
|
8260
8275
|
async (args) => {
|
|
8261
8276
|
if (!args.future)
|
|
8262
8277
|
throw new Error("This command is not yet available.");
|
|
@@ -8265,6 +8280,12 @@ var connect = (program2) => program2.command(
|
|
|
8265
8280
|
const { useSTSIdentity: useSTSIdentity2 } = await Promise.resolve().then(() => (init_credentials(), credentials_exports));
|
|
8266
8281
|
const { IAMClient, CreateRoleCommand, AttachRolePolicyCommand } = await import("@aws-sdk/client-iam");
|
|
8267
8282
|
const client = useAWSClient2(IAMClient);
|
|
8283
|
+
if (args.dev) {
|
|
8284
|
+
Colors.line(
|
|
8285
|
+
Colors.warning("\u26A0"),
|
|
8286
|
+
Colors.bold(" Connecting to dev stage")
|
|
8287
|
+
);
|
|
8288
|
+
}
|
|
8268
8289
|
await client.send(
|
|
8269
8290
|
new CreateRoleCommand({
|
|
8270
8291
|
RoleName: "sst",
|
|
@@ -8274,7 +8295,7 @@ var connect = (program2) => program2.command(
|
|
|
8274
8295
|
{
|
|
8275
8296
|
Effect: "Allow",
|
|
8276
8297
|
Principal: {
|
|
8277
|
-
AWS:
|
|
8298
|
+
AWS: `arn:aws:iam::${args.dev ? "917397401067" : "226609089145"}:root`
|
|
8278
8299
|
},
|
|
8279
8300
|
Action: "sts:AssumeRole"
|
|
8280
8301
|
}
|
|
@@ -8294,8 +8315,9 @@ var connect = (program2) => program2.command(
|
|
|
8294
8315
|
);
|
|
8295
8316
|
const project = useProject2();
|
|
8296
8317
|
const identity = await useSTSIdentity2();
|
|
8318
|
+
const host = args.dev ? "http://localhost:3000" : "https://console.production.sst.dev";
|
|
8297
8319
|
console.log(
|
|
8298
|
-
|
|
8320
|
+
`${host}/connect?app=${project.config.name}&stage=${project.config.stage}&aws_account_id=${identity.Account}®ion=${project.config.region}`
|
|
8299
8321
|
);
|
|
8300
8322
|
}
|
|
8301
8323
|
);
|
package/stacks/build.d.ts
CHANGED
package/stacks/build.js
CHANGED
|
@@ -4,14 +4,18 @@ import path from "path";
|
|
|
4
4
|
import { dynamicImport } from "../util/module.js";
|
|
5
5
|
import { findAbove } from "../util/fs.js";
|
|
6
6
|
import { VisibleError } from "../error.js";
|
|
7
|
-
export async function load(input) {
|
|
7
|
+
export async function load(input, shallow) {
|
|
8
8
|
const parsed = path.parse(input);
|
|
9
9
|
const root = await findAbove(input, "package.json");
|
|
10
10
|
if (!root)
|
|
11
11
|
throw new VisibleError("Could not find a package.json file");
|
|
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
|
+
let contents = await fs.readFile(input).then((x) => x.toString());
|
|
15
|
+
if (shallow)
|
|
16
|
+
contents = contents.replaceAll(/stacks\(.*?\)\s*{[\s\S]*?}\s*[,;]/gs, "stacks() {},");
|
|
14
17
|
try {
|
|
18
|
+
// Logger.debug("running esbuild on", input);
|
|
15
19
|
const result = await esbuild.build({
|
|
16
20
|
keepNames: true,
|
|
17
21
|
bundle: true,
|
|
@@ -21,6 +25,9 @@ export async function load(input) {
|
|
|
21
25
|
metafile: true,
|
|
22
26
|
format: "esm",
|
|
23
27
|
logLevel: "silent",
|
|
28
|
+
define: {
|
|
29
|
+
"process.env.IS_SHALLOW": shallow ? "true" : "false",
|
|
30
|
+
},
|
|
24
31
|
external: [
|
|
25
32
|
"aws-cdk-lib",
|
|
26
33
|
"sst",
|
|
@@ -41,9 +48,16 @@ export async function load(input) {
|
|
|
41
48
|
// The entry can have any file name (ie. "stacks/anything.ts"). We want the
|
|
42
49
|
// build output to be always named "lib/index.js". This allow us to always
|
|
43
50
|
// import from "buildDir" without needing to pass "anything" around.
|
|
44
|
-
|
|
51
|
+
stdin: {
|
|
52
|
+
contents,
|
|
53
|
+
loader: "ts",
|
|
54
|
+
resolveDir: path.dirname(input),
|
|
55
|
+
},
|
|
56
|
+
// entryPoints: [input],
|
|
45
57
|
});
|
|
58
|
+
// Logger.debug("built", input);
|
|
46
59
|
const mod = await dynamicImport(outfile);
|
|
60
|
+
// Logger.debug("imported", input);
|
|
47
61
|
await fs.rm(outfile, {
|
|
48
62
|
force: true,
|
|
49
63
|
});
|