sst 2.23.2 → 2.23.3

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.
@@ -4,7 +4,8 @@ import { SSTConstruct } from "./Construct.js";
4
4
  import { Permissions } from "./util/permission.js";
5
5
  import { FunctionBindingProps } from "./util/functionBinding.js";
6
6
  import { ISecurityGroup, IVpc, SubnetSelection } from "aws-cdk-lib/aws-ec2";
7
- import { Cluster } from "aws-cdk-lib/aws-ecs";
7
+ import { Cluster, ContainerDefinitionOptions } from "aws-cdk-lib/aws-ecs";
8
+ import { RetentionDays } from "aws-cdk-lib/aws-logs";
8
9
  declare const supportedCpus: {
9
10
  "0.25 vCPU": number;
10
11
  "0.5 vCPU": number;
@@ -191,6 +192,28 @@ export interface ServiceProps {
191
192
  * ```
192
193
  */
193
194
  environment?: Record<string, string>;
195
+ /**
196
+ * The duration logs are kept in CloudWatch Logs.
197
+ * @default Logs retained indefinitely
198
+ * @example
199
+ * ```js
200
+ * {
201
+ * logRetention: "one_week"
202
+ * }
203
+ * ```
204
+ */
205
+ logRetention?: Lowercase<keyof typeof RetentionDays>;
206
+ /**
207
+ * While deploying, SST waits for the CloudFront cache invalidation process to finish. This ensures that the new content will be served once the deploy command finishes. However, this process can sometimes take more than 5 mins. For non-prod environments it might make sense to pass in `false`. That'll skip waiting for the cache to invalidate and speed up the deploy process.
208
+ * @default false
209
+ * @example
210
+ * ```js
211
+ * {
212
+ * waitForInvalidation: true
213
+ * }
214
+ * ```
215
+ */
216
+ waitForInvalidation?: boolean;
194
217
  dev?: {
195
218
  /**
196
219
  * When running `sst dev, site is not deployed. This is to ensure `sst dev` can start up quickly.
@@ -218,18 +241,23 @@ export interface ServiceProps {
218
241
  */
219
242
  url?: string;
220
243
  };
221
- /**
222
- * While deploying, SST waits for the CloudFront cache invalidation process to finish. This ensures that the new content will be served once the deploy command finishes. However, this process can sometimes take more than 5 mins. For non-prod environments it might make sense to pass in `false`. That'll skip waiting for the cache to invalidate and speed up the deploy process.
223
- * @default false
224
- * @example
225
- * ```js
226
- * {
227
- * waitForInvalidation: true
228
- * }
229
- * ```
230
- */
231
- waitForInvalidation?: boolean;
232
244
  cdk?: {
245
+ /**
246
+ * Customizing the container definition for the ECS task.
247
+ * @example
248
+ * ```js
249
+ * {
250
+ * cdk: {
251
+ * container: {
252
+ * healthCheck: {
253
+ * command: ["CMD-SHELL", "curl -f http://localhost/ || exit 1"],
254
+ * },
255
+ * }
256
+ * }
257
+ * }
258
+ * ```
259
+ */
260
+ container?: Omit<ContainerDefinitionOptions, "image">;
233
261
  /**
234
262
  * Runs codebuild job in the specified VPC. Note this will only work once deployed.
235
263
  *
@@ -288,6 +316,7 @@ type ServiceNormalizedProps = ServiceProps & {
288
316
  cpu: Exclude<ServiceProps["cpu"], undefined>;
289
317
  memory: Exclude<ServiceProps["memory"], undefined>;
290
318
  port: Exclude<ServiceProps["port"], undefined>;
319
+ logRetention: Exclude<ServiceProps["logRetention"], undefined>;
291
320
  waitForInvalidation: Exclude<ServiceProps["waitForInvalidation"], undefined>;
292
321
  };
293
322
  /**
@@ -153,10 +153,11 @@ export class Service extends Construct {
153
153
  this.id = id;
154
154
  this.props = {
155
155
  path: ".",
156
- waitForInvalidation: false,
157
156
  cpu: props?.cpu || "0.25 vCPU",
158
157
  memory: props?.memory || "0.5 GB",
159
158
  port: props?.port || 3000,
159
+ logRetention: props?.logRetention || "infinite",
160
+ waitForInvalidation: false,
160
161
  ...props,
161
162
  };
162
163
  this.doNotDeploy =
@@ -363,12 +364,12 @@ export class Service extends Construct {
363
364
  }));
364
365
  }
365
366
  createService(vpc) {
366
- const { cpu, memory, port } = this.props;
367
+ const { cpu, memory, port, logRetention, cdk } = this.props;
367
368
  const app = this.node.root;
368
369
  const clusterName = app.logicalPrefixedName(this.node.id);
369
370
  const logGroup = new LogGroup(this, "LogGroup", {
370
371
  logGroupName: `/sst/service/${clusterName}`,
371
- retention: RetentionDays.INFINITE,
372
+ retention: RetentionDays[logRetention.toUpperCase()],
372
373
  });
373
374
  const cluster = new Cluster(this, "Cluster", {
374
375
  clusterName,
@@ -380,7 +381,6 @@ export class Service extends Construct {
380
381
  cpu: supportedCpus[cpu],
381
382
  });
382
383
  const container = taskDefinition.addContainer("Container", {
383
- image: { bind: () => ({ imageName: "placeholder" }) },
384
384
  logging: new AwsLogDriver({
385
385
  logGroup,
386
386
  streamPrefix: "service",
@@ -391,6 +391,8 @@ export class Service extends Construct {
391
391
  SST_STAGE: app.stage,
392
392
  SST_SSM_PREFIX: useProject().config.ssmPrefix,
393
393
  },
394
+ ...cdk?.container,
395
+ image: { bind: () => ({ imageName: "placeholder" }) },
394
396
  });
395
397
  const service = new FargateService(this, "Service", {
396
398
  cluster,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.23.2",
4
+ "version": "2.23.3",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },