@awsless/cli 0.0.14 → 0.0.16

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/dist/bin.js CHANGED
@@ -5,7 +5,7 @@ import { Command } from "commander";
5
5
 
6
6
  // src/util/aws.ts
7
7
  import { GetCallerIdentityCommand, STSClient } from "@aws-sdk/client-sts";
8
- import { createCredentialChain } from "@aws-sdk/credential-providers";
8
+ import { createCredentialChain, fromNodeProviderChain } from "@aws-sdk/credential-providers";
9
9
 
10
10
  // src/cli/ui/complex/fetch-credentials.ts
11
11
  import { log, prompt } from "@awsless/clui";
@@ -138,7 +138,11 @@ var validateSecretAccessKey = (value) => {
138
138
  };
139
139
 
140
140
  // src/util/aws.ts
141
+ var hasAmbientAwsCredentials = () => !!(process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI || process.env.AWS_CONTAINER_CREDENTIALS_FULL_URI || process.env.AWS_ACCESS_KEY_ID || process.env.AWS_WEB_IDENTITY_TOKEN_FILE);
141
142
  var getCredentials = async (profile) => {
143
+ if (hasAmbientAwsCredentials()) {
144
+ return fromNodeProviderChain();
145
+ }
142
146
  const credentials = await fetchCredentials(profile);
143
147
  return createCredentialChain(async () => {
144
148
  return credentials;
@@ -1175,7 +1179,7 @@ var LogRetentionSchema = DurationSchema.refine(
1175
1179
  (duration) => {
1176
1180
  return validLogRetentionDays.includes(toDays(duration));
1177
1181
  },
1178
- `Invalid log retention. Valid days are: ${validLogRetentionDays.map((days10) => `${days10}`).join(", ")}`
1182
+ `Invalid log retention. Valid days are: ${validLogRetentionDays.map((days11) => `${days11}`).join(", ")}`
1179
1183
  ).describe("The log retention duration.");
1180
1184
  var LogSchema = z15.union([
1181
1185
  z15.boolean().transform((enabled) => ({ retention: enabled ? days(7) : days(0) })),
@@ -1788,7 +1792,7 @@ var LogRetentionSchema2 = DurationSchema.refine(
1788
1792
  (duration) => {
1789
1793
  return validLogRetentionDays2.includes(toDays2(duration));
1790
1794
  },
1791
- `Invalid log retention. Valid days are: ${validLogRetentionDays2.map((days10) => `${days10}`).join(", ")}`
1795
+ `Invalid log retention. Valid days are: ${validLogRetentionDays2.map((days11) => `${days11}`).join(", ")}`
1792
1796
  ).describe("The log retention duration.");
1793
1797
  var LogSchema2 = z26.union([
1794
1798
  z26.boolean().transform((enabled) => ({ retention: enabled ? days4(7) : days4(0) })),
@@ -1929,7 +1933,7 @@ var LogRetentionSchema3 = DurationSchema.refine(
1929
1933
  (duration) => {
1930
1934
  return validLogRetentionDays3.includes(toDays3(duration));
1931
1935
  },
1932
- `Invalid log retention. Valid days are: ${validLogRetentionDays3.map((days10) => `${days10}`).join(", ")}`
1936
+ `Invalid log retention. Valid days are: ${validLogRetentionDays3.map((days11) => `${days11}`).join(", ")}`
1933
1937
  ).describe("The log retention duration.");
1934
1938
  var LogSchema3 = z27.union([
1935
1939
  z27.boolean().transform((enabled) => ({ retention: enabled ? days5(7) : days5(0) })),
@@ -2337,7 +2341,14 @@ var SitesSchema = z38.record(
2337
2341
  ).optional().describe("Define the sites in your stack.");
2338
2342
 
2339
2343
  // src/feature/store/schema.ts
2344
+ import { days as days6 } from "@awsless/duration";
2340
2345
  import { z as z39 } from "zod";
2346
+ var LifecycleRuleSchema = z39.object({
2347
+ prefix: z39.string().optional().describe("Object-key prefix this rule applies to. Omit to apply bucket-wide."),
2348
+ expiration: DurationSchema.refine(durationMin(days6(1)), "Minimum expiration is 1 day").describe(
2349
+ "How long objects matching this rule live before S3 deletes them."
2350
+ )
2351
+ });
2341
2352
  var StoresSchema = z39.union([
2342
2353
  z39.array(ResourceIdSchema).transform((list3) => {
2343
2354
  const stores = {};
@@ -2351,6 +2362,7 @@ var StoresSchema = z39.union([
2351
2362
  z39.object({
2352
2363
  static: LocalDirectorySchema.optional().describe("Specifies the path to the static files directory."),
2353
2364
  versioning: z39.boolean().default(false).describe("Enable versioning of your store."),
2365
+ lifecycle: z39.array(LifecycleRuleSchema).optional().describe("S3 lifecycle rules for this store. Each rule expires objects matching an optional prefix."),
2354
2366
  events: z39.object({
2355
2367
  // create
2356
2368
  "created:*": TaskSchema.optional().describe(
@@ -4574,7 +4586,7 @@ var functionFeature = defineFeature({
4574
4586
  });
4575
4587
 
4576
4588
  // src/feature/function/prebuild.ts
4577
- import { days as days6, seconds as seconds5, toDays as toDays6, toSeconds as toSeconds3 } from "@awsless/duration";
4589
+ import { days as days7, seconds as seconds5, toDays as toDays6, toSeconds as toSeconds3 } from "@awsless/duration";
4578
4590
  import { mebibytes as mebibytes2, toMebibytes as toMebibytes4 } from "@awsless/size";
4579
4591
  import { aws as aws8 } from "@terraforge/aws";
4580
4592
  import { Output as Output4, findInputDeps as findInputDeps2, resolveInputs as resolveInputs2 } from "@terraforge/core";
@@ -4706,7 +4718,7 @@ var createPrebuildLambdaFunction = (group, ctx, ns, id, props) => {
4706
4718
  if (props.log?.retention && props.log?.retention?.value > 0n) {
4707
4719
  const logGroup = new aws8.cloudwatch.LogGroup(group, "log", {
4708
4720
  name: `/aws/lambda/${name}`,
4709
- retentionInDays: toDays6(props.log.retention ?? days6(7))
4721
+ retentionInDays: toDays6(props.log.retention ?? days7(7))
4710
4722
  });
4711
4723
  addPermission({
4712
4724
  actions: ["logs:PutLogEvents", "logs:CreateLogStream"],
@@ -4763,7 +4775,7 @@ import { Group as Group8 } from "@terraforge/core";
4763
4775
  import { aws as aws9 } from "@terraforge/aws";
4764
4776
  import { join as join10 } from "path";
4765
4777
  import { mebibytes as mebibytes3 } from "@awsless/size";
4766
- import { days as days7, seconds as seconds6 } from "@awsless/duration";
4778
+ import { days as days8, seconds as seconds6 } from "@awsless/duration";
4767
4779
  var onErrorLogFeature = defineFeature({
4768
4780
  name: "on-error-log",
4769
4781
  onApp(ctx) {
@@ -4778,7 +4790,7 @@ var onErrorLogFeature = defineFeature({
4778
4790
  log: {
4779
4791
  format: "json",
4780
4792
  level: "warn",
4781
- retention: days7(3),
4793
+ retention: days8(3),
4782
4794
  system: "warn"
4783
4795
  }
4784
4796
  });
@@ -4835,7 +4847,7 @@ import { Group as Group9 } from "@terraforge/core";
4835
4847
  import { aws as aws10 } from "@terraforge/aws";
4836
4848
  import { join as join11 } from "path";
4837
4849
  import { mebibytes as mebibytes4 } from "@awsless/size";
4838
- import { days as days8, toSeconds as toSeconds4 } from "@awsless/duration";
4850
+ import { days as days9, toSeconds as toSeconds4 } from "@awsless/duration";
4839
4851
  var onFailureFeature = defineFeature({
4840
4852
  name: "on-failure",
4841
4853
  onApp(ctx) {
@@ -4846,7 +4858,7 @@ var onFailureFeature = defineFeature({
4846
4858
  resourceType: "on-failure",
4847
4859
  resourceName: "deadletter"
4848
4860
  }),
4849
- messageRetentionSeconds: toSeconds4(days8(14))
4861
+ messageRetentionSeconds: toSeconds4(days9(14))
4850
4862
  });
4851
4863
  const queue2 = new aws10.sqs.Queue(group, "on-failure", {
4852
4864
  name: formatGlobalResourceName({
@@ -4994,7 +5006,7 @@ var onFailureFeature = defineFeature({
4994
5006
  log: {
4995
5007
  format: "json",
4996
5008
  level: "warn",
4997
- retention: days8(3),
5009
+ retention: days9(3),
4998
5010
  system: "warn"
4999
5011
  }
5000
5012
  });
@@ -5986,6 +5998,7 @@ var siteFeature = defineFeature({
5986
5998
 
5987
5999
  // src/feature/store/index.ts
5988
6000
  import { Group as Group16 } from "@terraforge/core";
6001
+ import { toDays as toDays7 } from "@awsless/duration";
5989
6002
  import { kebabCase as kebabCase7 } from "change-case";
5990
6003
  import { aws as aws17 } from "@terraforge/aws";
5991
6004
  import { glob as glob3 } from "glob";
@@ -6087,6 +6100,12 @@ var storeFeature = defineFeature({
6087
6100
  resourceName: id,
6088
6101
  postfix: ctx.appId
6089
6102
  });
6103
+ const lifecycleRule = props.lifecycle?.map((rule, index) => ({
6104
+ id: rule.prefix ? `expire-${kebabCase7(rule.prefix)}` : `expire-rule-${index}`,
6105
+ enabled: true,
6106
+ ...rule.prefix ? { prefix: rule.prefix } : {},
6107
+ expiration: { days: toDays7(rule.expiration) }
6108
+ }));
6090
6109
  const bucket = new aws17.s3.Bucket(
6091
6110
  group,
6092
6111
  "store",
@@ -6104,7 +6123,8 @@ var storeFeature = defineFeature({
6104
6123
  allowedOrigins: ["*"],
6105
6124
  allowedMethods: ["POST"]
6106
6125
  }
6107
- ]
6126
+ ],
6127
+ ...lifecycleRule?.length ? { lifecycleRule } : {}
6108
6128
  },
6109
6129
  {
6110
6130
  retainOnDelete: ctx.appConfig.removal === "retain",
@@ -6893,7 +6913,7 @@ import { Group as Group23 } from "@terraforge/core";
6893
6913
  import { aws as aws24 } from "@terraforge/aws";
6894
6914
  import { join as join15, dirname as dirname7 } from "path";
6895
6915
  import { mebibytes as mebibytes6 } from "@awsless/size";
6896
- import { seconds as seconds8, toDays as toDays7 } from "@awsless/duration";
6916
+ import { seconds as seconds8, toDays as toDays8 } from "@awsless/duration";
6897
6917
  import { fileURLToPath as fileURLToPath2 } from "url";
6898
6918
  import { glob as glob4 } from "glob";
6899
6919
  var __dirname3 = dirname7(fileURLToPath2(import.meta.url));
@@ -6984,7 +7004,7 @@ var imageFeature = defineFeature({
6984
7004
  enabled: true,
6985
7005
  id: "image-cache-duration",
6986
7006
  expiration: {
6987
- days: toDays7(props.cacheDuration)
7007
+ days: toDays8(props.cacheDuration)
6988
7008
  }
6989
7009
  }
6990
7010
  ]
@@ -7090,7 +7110,7 @@ import { Group as Group24 } from "@terraforge/core";
7090
7110
  import { aws as aws25 } from "@terraforge/aws";
7091
7111
  import { join as join16, dirname as dirname8 } from "path";
7092
7112
  import { mebibytes as mebibytes7 } from "@awsless/size";
7093
- import { seconds as seconds9, toDays as toDays8 } from "@awsless/duration";
7113
+ import { seconds as seconds9, toDays as toDays9 } from "@awsless/duration";
7094
7114
  import { fileURLToPath as fileURLToPath3 } from "url";
7095
7115
  import { glob as glob5 } from "glob";
7096
7116
  var __dirname4 = dirname8(fileURLToPath3(import.meta.url));
@@ -7135,7 +7155,7 @@ var iconFeature = defineFeature({
7135
7155
  enabled: true,
7136
7156
  id: "icon-cache-duration",
7137
7157
  expiration: {
7138
- days: toDays8(props.cacheDuration)
7158
+ days: toDays9(props.cacheDuration)
7139
7159
  }
7140
7160
  }
7141
7161
  ]
@@ -7242,7 +7262,7 @@ import { relative as relative8 } from "path";
7242
7262
 
7243
7263
  // src/feature/job/util.ts
7244
7264
  import { createHash as createHash4 } from "crypto";
7245
- import { toDays as toDays9, toSeconds as toSeconds9 } from "@awsless/duration";
7265
+ import { toDays as toDays10, toSeconds as toSeconds9 } from "@awsless/duration";
7246
7266
  import { stringify } from "@awsless/json";
7247
7267
  import { toMebibytes as toMebibytes5 } from "@awsless/size";
7248
7268
  import { generateFileHash as generateFileHash2 } from "@awsless/ts-file-cache";
@@ -7442,7 +7462,7 @@ var createFargateJob = (parentGroup, ctx, ns, id, local) => {
7442
7462
  if (props.log.retention && props.log.retention.value > 0n) {
7443
7463
  logGroup = new aws26.cloudwatch.LogGroup(group, "log", {
7444
7464
  name: `/aws/ecs/${name}`,
7445
- retentionInDays: toDays9(props.log.retention)
7465
+ retentionInDays: toDays10(props.log.retention)
7446
7466
  });
7447
7467
  if (ctx.shared.has("on-error-log", "subscriber-arn")) {
7448
7468
  new aws26.cloudwatch.LogSubscriptionFilter(group, "on-error-log", {
@@ -7818,7 +7838,7 @@ import { Group as Group28 } from "@terraforge/core";
7818
7838
  import { aws as aws29 } from "@terraforge/aws";
7819
7839
 
7820
7840
  // src/feature/instance/util.ts
7821
- import { toDays as toDays10, toSeconds as toSeconds10 } from "@awsless/duration";
7841
+ import { toDays as toDays11, toSeconds as toSeconds10 } from "@awsless/duration";
7822
7842
  import { stringify as stringify2 } from "@awsless/json";
7823
7843
  import { toMebibytes as toMebibytes6 } from "@awsless/size";
7824
7844
  import { generateFileHash as generateFileHash3 } from "@awsless/ts-file-cache";
@@ -8003,7 +8023,7 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
8003
8023
  logGroup = new aws28.cloudwatch.LogGroup(group, "log", {
8004
8024
  name: `/aws/ecs/${name}`,
8005
8025
  // name: `/aws/lambda/${name}`,
8006
- retentionInDays: toDays10(props.log.retention)
8026
+ retentionInDays: toDays11(props.log.retention)
8007
8027
  });
8008
8028
  if (ctx.shared.has("on-error-log", "subscriber-arn")) {
8009
8029
  new aws28.cloudwatch.LogSubscriptionFilter(group, "on-error-log", {
@@ -8390,7 +8410,7 @@ var metricFeature = defineFeature({
8390
8410
  });
8391
8411
 
8392
8412
  // src/feature/router/index.ts
8393
- import { days as days9, seconds as seconds10, toSeconds as toSeconds12, years } from "@awsless/duration";
8413
+ import { days as days10, seconds as seconds10, toSeconds as toSeconds12, years } from "@awsless/duration";
8394
8414
  import { Future, Group as Group30 } from "@terraforge/core";
8395
8415
  import { aws as aws31 } from "@terraforge/aws";
8396
8416
  import { camelCase as camelCase9, constantCase as constantCase15 } from "change-case";
@@ -8685,8 +8705,8 @@ var routerFeature = defineFeature({
8685
8705
  const cache = new aws31.cloudfront.CachePolicy(group, "cache", {
8686
8706
  name,
8687
8707
  minTtl: toSeconds12(seconds10(0)),
8688
- maxTtl: toSeconds12(days9(365)),
8689
- defaultTtl: toSeconds12(days9(0)),
8708
+ maxTtl: toSeconds12(days10(365)),
8709
+ defaultTtl: toSeconds12(days10(0)),
8690
8710
  parametersInCacheKeyAndForwardedToOrigin: {
8691
8711
  enableAcceptEncodingBrotli: true,
8692
8712
  enableAcceptEncodingGzip: true,
@@ -233,7 +233,7 @@ var LogRetentionSchema = DurationSchema.refine(
233
233
  (duration) => {
234
234
  return validLogRetentionDays.includes(toDays(duration));
235
235
  },
236
- `Invalid log retention. Valid days are: ${validLogRetentionDays.map((days6) => `${days6}`).join(", ")}`
236
+ `Invalid log retention. Valid days are: ${validLogRetentionDays.map((days7) => `${days7}`).join(", ")}`
237
237
  ).describe("The log retention duration.");
238
238
  var LogSchema = z11.union([
239
239
  z11.boolean().transform((enabled) => ({ retention: enabled ? days(7) : days(0) })),
@@ -846,7 +846,7 @@ var LogRetentionSchema2 = DurationSchema.refine(
846
846
  (duration) => {
847
847
  return validLogRetentionDays2.includes(toDays2(duration));
848
848
  },
849
- `Invalid log retention. Valid days are: ${validLogRetentionDays2.map((days6) => `${days6}`).join(", ")}`
849
+ `Invalid log retention. Valid days are: ${validLogRetentionDays2.map((days7) => `${days7}`).join(", ")}`
850
850
  ).describe("The log retention duration.");
851
851
  var LogSchema2 = z22.union([
852
852
  z22.boolean().transform((enabled) => ({ retention: enabled ? days4(7) : days4(0) })),
@@ -987,7 +987,7 @@ var LogRetentionSchema3 = DurationSchema.refine(
987
987
  (duration) => {
988
988
  return validLogRetentionDays3.includes(toDays3(duration));
989
989
  },
990
- `Invalid log retention. Valid days are: ${validLogRetentionDays3.map((days6) => `${days6}`).join(", ")}`
990
+ `Invalid log retention. Valid days are: ${validLogRetentionDays3.map((days7) => `${days7}`).join(", ")}`
991
991
  ).describe("The log retention duration.");
992
992
  var LogSchema3 = z23.union([
993
993
  z23.boolean().transform((enabled) => ({ retention: enabled ? days5(7) : days5(0) })),
@@ -1395,7 +1395,14 @@ var SitesSchema = z34.record(
1395
1395
  ).optional().describe("Define the sites in your stack.");
1396
1396
 
1397
1397
  // src/feature/store/schema.ts
1398
+ import { days as days6 } from "@awsless/duration";
1398
1399
  import { z as z35 } from "zod";
1400
+ var LifecycleRuleSchema = z35.object({
1401
+ prefix: z35.string().optional().describe("Object-key prefix this rule applies to. Omit to apply bucket-wide."),
1402
+ expiration: DurationSchema.refine(durationMin(days6(1)), "Minimum expiration is 1 day").describe(
1403
+ "How long objects matching this rule live before S3 deletes them."
1404
+ )
1405
+ });
1399
1406
  var StoresSchema = z35.union([
1400
1407
  z35.array(ResourceIdSchema).transform((list) => {
1401
1408
  const stores = {};
@@ -1409,6 +1416,7 @@ var StoresSchema = z35.union([
1409
1416
  z35.object({
1410
1417
  static: LocalDirectorySchema.optional().describe("Specifies the path to the static files directory."),
1411
1418
  versioning: z35.boolean().default(false).describe("Enable versioning of your store."),
1419
+ lifecycle: z35.array(LifecycleRuleSchema).optional().describe("S3 lifecycle rules for this store. Each rule expires objects matching an optional prefix."),
1412
1420
  events: z35.object({
1413
1421
  // create
1414
1422
  "created:*": TaskSchema.optional().describe(
Binary file
Binary file
Binary file
Binary file