sst 2.40.7 → 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.
@@ -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.5";
23
+ const DEFAULT_OPEN_NEXT_VERSION = "2.3.7";
24
24
  const DEFAULT_CACHE_POLICY_ALLOWED_HEADERS = [
25
25
  "accept",
26
26
  "rsc",
@@ -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 { Cluster, ContainerDefinitionOptions, CpuArchitecture, FargateService, FargateTaskDefinition, FargateServiceProps } from "aws-cdk-lib/aws-ecs";
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
- * Runs codebuild job in the specified VPC. Note this will only work once deployed.
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: Cluster | undefined;
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;
@@ -175,7 +175,8 @@ export class Service extends Construct {
175
175
  }
176
176
  // Create ECS cluster
177
177
  const vpc = this.createVpc();
178
- const { cluster, container, taskDefinition, service } = this.createService(vpc);
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
- createService(vpc) {
402
- const { architecture, cpu, memory, storage, port, logRetention, cdk } = this.props;
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.7",
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.7",
121
+ "astro-sst": "2.40.8",
122
122
  "async": "^3.2.4",
123
123
  "tsx": "^3.12.1",
124
124
  "typescript": "^5.2.2",