sst 2.40.6 → 2.40.8
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/cli/commands/types.js
CHANGED
|
@@ -21,7 +21,7 @@ export const types = (program) => program.command("types", "Generate resource ty
|
|
|
21
21
|
name: project.config.name,
|
|
22
22
|
region: project.config.region,
|
|
23
23
|
});
|
|
24
|
-
sstConfig.stacks(app);
|
|
24
|
+
await sstConfig.stacks(app);
|
|
25
25
|
Colors.line(Colors.success(`✔ `), `Types generated in ${path.resolve(project.paths.out, "types")}`);
|
|
26
26
|
await exit();
|
|
27
27
|
}
|
package/constructs/Function.js
CHANGED
|
@@ -149,11 +149,15 @@ export class Function extends CDKFunction {
|
|
|
149
149
|
timeout: toCdkDuration("900 second"),
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
+
// Ensure descriptions fits the 256 chars limit
|
|
153
|
+
const description = props.description
|
|
154
|
+
? `${props.description.substring(0, 240)} (live)`
|
|
155
|
+
: `live`;
|
|
152
156
|
super(scope, id, {
|
|
153
157
|
...props,
|
|
154
158
|
...(props.runtime === "container"
|
|
155
159
|
? {
|
|
156
|
-
description
|
|
160
|
+
description,
|
|
157
161
|
code: Code.fromAssetImage(path.resolve(__dirname, "../support/bridge"), {
|
|
158
162
|
...(architecture?.dockerPlatform
|
|
159
163
|
? { platform: Platform.custom(architecture.dockerPlatform) }
|
|
@@ -164,7 +168,7 @@ export class Function extends CDKFunction {
|
|
|
164
168
|
layers: undefined,
|
|
165
169
|
}
|
|
166
170
|
: {
|
|
167
|
-
description
|
|
171
|
+
description,
|
|
168
172
|
runtime: CDKRuntime.NODEJS_18_X,
|
|
169
173
|
code: Code.fromAsset(path.resolve(__dirname, "../support/bridge")),
|
|
170
174
|
handler: "live-lambda.handler",
|
package/constructs/NextjsSite.js
CHANGED
|
@@ -20,7 +20,7 @@ import { useFunctions } from "./Function.js";
|
|
|
20
20
|
import { useDeferredTasks } from "./deferred_task.js";
|
|
21
21
|
import { Logger } from "../logger.js";
|
|
22
22
|
const LAYER_VERSION = "2";
|
|
23
|
-
const DEFAULT_OPEN_NEXT_VERSION = "2.3.
|
|
23
|
+
const DEFAULT_OPEN_NEXT_VERSION = "2.3.7";
|
|
24
24
|
const DEFAULT_CACHE_POLICY_ALLOWED_HEADERS = [
|
|
25
25
|
"accept",
|
|
26
26
|
"rsc",
|
package/constructs/Service.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { SSTConstruct } from "./Construct.js";
|
|
|
6
6
|
import { Permissions } from "./util/permission.js";
|
|
7
7
|
import { BindingProps, BindingResource } from "./util/binding.js";
|
|
8
8
|
import { IVpc } from "aws-cdk-lib/aws-ec2";
|
|
9
|
-
import {
|
|
9
|
+
import { ContainerDefinitionOptions, CpuArchitecture, FargateService, FargateTaskDefinition, FargateServiceProps, ICluster } from "aws-cdk-lib/aws-ecs";
|
|
10
10
|
import { RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
11
11
|
import { ApplicationLoadBalancer, ApplicationLoadBalancerProps, ApplicationTargetGroupProps } from "aws-cdk-lib/aws-elasticloadbalancingv2";
|
|
12
12
|
declare const supportedCpus: {
|
|
@@ -399,7 +399,22 @@ export interface ServiceProps {
|
|
|
399
399
|
image?: ContainerDefinitionOptions["image"];
|
|
400
400
|
};
|
|
401
401
|
/**
|
|
402
|
-
*
|
|
402
|
+
* Create the service in an existing ECS cluster.
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```js
|
|
406
|
+
* import { Cluster } from "aws-cdk-lib/aws-ecs";
|
|
407
|
+
*
|
|
408
|
+
* {
|
|
409
|
+
* cdk: {
|
|
410
|
+
* cluster: Cluster.fromClusterArn(stack, "Cluster", "arn:aws:ecs:us-east-1:123456789012:cluster/my-cluster"),
|
|
411
|
+
* }
|
|
412
|
+
* }
|
|
413
|
+
* ```
|
|
414
|
+
*/
|
|
415
|
+
cluster?: ICluster;
|
|
416
|
+
/**
|
|
417
|
+
* Create the service in the specified VPC. Note this will only work once deployed.
|
|
403
418
|
*
|
|
404
419
|
* @example
|
|
405
420
|
* ```js
|
|
@@ -463,7 +478,7 @@ export declare class Service extends Construct implements SSTConstruct {
|
|
|
463
478
|
*/
|
|
464
479
|
get cdk(): {
|
|
465
480
|
vpc: IVpc | undefined;
|
|
466
|
-
cluster:
|
|
481
|
+
cluster: ICluster | undefined;
|
|
467
482
|
fargateService: FargateService | undefined;
|
|
468
483
|
taskDefinition: FargateTaskDefinition | undefined;
|
|
469
484
|
distribution: import("aws-cdk-lib/aws-cloudfront").IDistribution | undefined;
|
|
@@ -519,6 +534,7 @@ export declare class Service extends Construct implements SSTConstruct {
|
|
|
519
534
|
private validateServiceExists;
|
|
520
535
|
private validateMemoryCpuAndStorage;
|
|
521
536
|
private createVpc;
|
|
537
|
+
private createCluster;
|
|
522
538
|
private createService;
|
|
523
539
|
private createLoadBalancer;
|
|
524
540
|
private createAutoScaling;
|
package/constructs/Service.js
CHANGED
|
@@ -175,7 +175,8 @@ export class Service extends Construct {
|
|
|
175
175
|
}
|
|
176
176
|
// Create ECS cluster
|
|
177
177
|
const vpc = this.createVpc();
|
|
178
|
-
const
|
|
178
|
+
const cluster = this.createCluster(vpc);
|
|
179
|
+
const { container, taskDefinition, service } = this.createService(cluster);
|
|
179
180
|
const { alb, target } = this.createLoadBalancer(vpc, service);
|
|
180
181
|
this.createAutoScaling(service, target);
|
|
181
182
|
this.alb = alb;
|
|
@@ -398,21 +399,26 @@ export class Service extends Construct {
|
|
|
398
399
|
natGateways: 1,
|
|
399
400
|
}));
|
|
400
401
|
}
|
|
401
|
-
|
|
402
|
-
|
|
402
|
+
createCluster(vpc) {
|
|
403
|
+
if (this.props.cdk?.cluster)
|
|
404
|
+
return this.props.cdk.cluster;
|
|
403
405
|
const app = this.node.root;
|
|
404
406
|
const clusterName = app.logicalPrefixedName(this.node.id);
|
|
407
|
+
return new Cluster(this, "Cluster", {
|
|
408
|
+
clusterName,
|
|
409
|
+
vpc,
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
createService(cluster) {
|
|
413
|
+
const { architecture, cpu, memory, storage, port, logRetention, cdk } = this.props;
|
|
414
|
+
const app = this.node.root;
|
|
405
415
|
const logGroup = new LogRetention(this, "LogRetention", {
|
|
406
|
-
logGroupName: `/sst/service/${clusterName}`,
|
|
416
|
+
logGroupName: `/sst/service/${cluster.clusterName}`,
|
|
407
417
|
retention: RetentionDays[logRetention.toUpperCase()],
|
|
408
418
|
logRetentionRetryOptions: {
|
|
409
419
|
maxRetries: 100,
|
|
410
420
|
},
|
|
411
421
|
});
|
|
412
|
-
const cluster = new Cluster(this, "Cluster", {
|
|
413
|
-
clusterName,
|
|
414
|
-
vpc,
|
|
415
|
-
});
|
|
416
422
|
const ephemeralStorageGiB = toCdkSize(storage).toGibibytes();
|
|
417
423
|
const taskDefinition = new FargateTaskDefinition(this, `TaskDefinition`, {
|
|
418
424
|
// @ts-expect-error
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"sideEffects": false,
|
|
3
3
|
"name": "sst",
|
|
4
|
-
"version": "2.40.
|
|
4
|
+
"version": "2.40.8",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sst": "cli/sst.js"
|
|
7
7
|
},
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"@types/ws": "^8.5.3",
|
|
119
119
|
"@types/yargs": "^17.0.13",
|
|
120
120
|
"archiver": "^5.3.1",
|
|
121
|
-
"astro-sst": "2.40.
|
|
121
|
+
"astro-sst": "2.40.8",
|
|
122
122
|
"async": "^3.2.4",
|
|
123
123
|
"tsx": "^3.12.1",
|
|
124
124
|
"typescript": "^5.2.2",
|
|
@@ -147118,7 +147118,7 @@ function safeHandler(block) {
|
|
|
147118
147118
|
}
|
|
147119
147119
|
}
|
|
147120
147120
|
const reason = [
|
|
147121
|
-
e.message,
|
|
147121
|
+
e.message.slice(0, 3e3),
|
|
147122
147122
|
`Logs: https://${process.env.AWS_REGION}.console.aws.amazon.com/cloudwatch/home?region=${process.env.AWS_REGION}#logsV2:log-groups/log-group/${encodeURIComponent(
|
|
147123
147123
|
process.env.AWS_LAMBDA_LOG_GROUP_NAME
|
|
147124
147124
|
)}/log-events/${encodeURIComponent(
|
|
@@ -153756,7 +153756,7 @@ function storeVariable(variablesAcc, variable, value) {
|
|
|
153756
153756
|
}
|
|
153757
153757
|
|
|
153758
153758
|
// support/custom-resources/secret-prefetcher.ts
|
|
153759
|
-
var lambda3 =
|
|
153759
|
+
var lambda3 = useAWSClient(import_client_lambda3.LambdaClient);
|
|
153760
153760
|
async function SecretPrefetcher(cfnRequest) {
|
|
153761
153761
|
switch (cfnRequest.RequestType) {
|
|
153762
153762
|
case "Create":
|
|
@@ -153764,10 +153764,12 @@ async function SecretPrefetcher(cfnRequest) {
|
|
|
153764
153764
|
const props = cfnRequest.ResourceProperties;
|
|
153765
153765
|
const processEnvBackup = { ...process.env };
|
|
153766
153766
|
try {
|
|
153767
|
-
const ret = await
|
|
153768
|
-
|
|
153769
|
-
|
|
153770
|
-
|
|
153767
|
+
const ret = await retryOnAccessDenied(
|
|
153768
|
+
() => lambda3.send(
|
|
153769
|
+
new import_client_lambda3.GetFunctionCommand({
|
|
153770
|
+
FunctionName: props.functionName
|
|
153771
|
+
})
|
|
153772
|
+
)
|
|
153771
153773
|
);
|
|
153772
153774
|
const envs = ret.Configuration?.Environment?.Variables ?? {};
|
|
153773
153775
|
Object.entries(envs).filter(
|
|
@@ -153779,13 +153781,15 @@ async function SecretPrefetcher(cfnRequest) {
|
|
|
153779
153781
|
Object.entries(allVariables2["Secret"] ?? {}).map(([key, value]) => {
|
|
153780
153782
|
envs[`SST_Secret_value_${key}`] = value.value.toString();
|
|
153781
153783
|
});
|
|
153782
|
-
await
|
|
153783
|
-
|
|
153784
|
-
|
|
153785
|
-
|
|
153786
|
-
|
|
153787
|
-
|
|
153788
|
-
|
|
153784
|
+
await retryOnAccessDenied(
|
|
153785
|
+
() => lambda3.send(
|
|
153786
|
+
new import_client_lambda3.UpdateFunctionConfigurationCommand({
|
|
153787
|
+
FunctionName: props.functionName,
|
|
153788
|
+
Environment: {
|
|
153789
|
+
Variables: envs
|
|
153790
|
+
}
|
|
153791
|
+
})
|
|
153792
|
+
)
|
|
153789
153793
|
);
|
|
153790
153794
|
} finally {
|
|
153791
153795
|
process.env = processEnvBackup;
|
|
@@ -153797,6 +153801,17 @@ async function SecretPrefetcher(cfnRequest) {
|
|
|
153797
153801
|
throw new Error("Unsupported request type");
|
|
153798
153802
|
}
|
|
153799
153803
|
}
|
|
153804
|
+
async function retryOnAccessDenied(cb, attempt = 0) {
|
|
153805
|
+
try {
|
|
153806
|
+
return await cb();
|
|
153807
|
+
} catch (e) {
|
|
153808
|
+
if ((e.name === "AccessDenied" || e.name === "AccessDeniedException") && e.message.includes("is not authorized to perform") && attempt < 10) {
|
|
153809
|
+
await new Promise((resolve) => setTimeout(resolve, 5e3));
|
|
153810
|
+
return retryOnAccessDenied(cb, attempt + 1);
|
|
153811
|
+
}
|
|
153812
|
+
throw e;
|
|
153813
|
+
}
|
|
153814
|
+
}
|
|
153800
153815
|
|
|
153801
153816
|
// support/custom-resources/index.ts
|
|
153802
153817
|
var handler = (event) => {
|