@awsless/awsless 0.0.227 → 0.0.229

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.
Files changed (2) hide show
  1. package/dist/bin.js +45 -43
  2. package/package.json +5 -5
package/dist/bin.js CHANGED
@@ -2113,6 +2113,17 @@ var build = (type, name, builder) => {
2113
2113
  });
2114
2114
  };
2115
2115
 
2116
+ // src/feature/on-failure/util.ts
2117
+ var getGlobalOnFailure = (ctx) => {
2118
+ return hasOnFailure(ctx.stackConfigs) ? ctx.shared.get("on-failure-queue-arn") : void 0;
2119
+ };
2120
+ var hasOnFailure = (stacks) => {
2121
+ const onFailure = stacks.find((stack) => {
2122
+ return typeof stack.onFailure !== "undefined";
2123
+ });
2124
+ return !!onFailure;
2125
+ };
2126
+
2116
2127
  // src/feature/function/util.ts
2117
2128
  var createLambdaFunction = (group, ctx, ns, id, local2) => {
2118
2129
  let name;
@@ -2233,7 +2244,7 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
2233
2244
  "ec2:AssignPrivateIpAddresses",
2234
2245
  "ec2:UnassignPrivateIpAddresses"
2235
2246
  ],
2236
- resources: ["arn:aws:ec2:*:*:*"]
2247
+ resources: ["*"]
2237
2248
  });
2238
2249
  }
2239
2250
  return {
@@ -2242,6 +2253,24 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
2242
2253
  code
2243
2254
  };
2244
2255
  };
2256
+ var createAsyncLambdaFunction = (group, ctx, ns, id, local2) => {
2257
+ const result = createLambdaFunction(group, ctx, ns, id, local2);
2258
+ const props = deepmerge(ctx.appConfig.defaults.function, local2);
2259
+ result.lambda.addEnvironment("LOG_VIEWABLE_ERROR", "1");
2260
+ const invokeConfig = new aws2.lambda.EventInvokeConfig(group, "async", {
2261
+ functionArn: result.lambda.arn,
2262
+ retryAttempts: props.retryAttempts,
2263
+ onFailure: getGlobalOnFailure(ctx)
2264
+ });
2265
+ invokeConfig.dependsOn(result.policy);
2266
+ if (hasOnFailure(ctx.stackConfigs)) {
2267
+ result.policy.addStatement({
2268
+ actions: ["sqs:SendMessage", "sqs:GetQueueUrl"],
2269
+ resources: [getGlobalOnFailure(ctx)]
2270
+ });
2271
+ }
2272
+ return result;
2273
+ };
2245
2274
 
2246
2275
  // src/feature/cron/index.ts
2247
2276
  var cronFeature = defineFeature({
@@ -2249,8 +2278,7 @@ var cronFeature = defineFeature({
2249
2278
  onStack(ctx) {
2250
2279
  for (const [id, props] of Object.entries(ctx.stackConfig.crons ?? {})) {
2251
2280
  const group = new Node3(ctx.stack, "cron", id);
2252
- const { lambda } = createLambdaFunction(group, ctx, this.name, id, props.consumer);
2253
- lambda.addEnvironment("LOG_VIEWABLE_ERROR", "1");
2281
+ const { lambda } = createAsyncLambdaFunction(group, ctx, "cron", id, props.consumer);
2254
2282
  const rule = new aws3.events.Rule(group, "rule", {
2255
2283
  name: formatLocalResourceName(ctx.app.name, ctx.stack.name, this.name, id),
2256
2284
  schedule: props.schedule,
@@ -3002,17 +3030,6 @@ var graphqlFeature = defineFeature({
3002
3030
  }
3003
3031
  });
3004
3032
 
3005
- // src/feature/on-failure/util.ts
3006
- var getGlobalOnFailure = (ctx) => {
3007
- return hasOnFailure(ctx.stackConfigs) ? ctx.shared.get("on-failure-queue-arn") : void 0;
3008
- };
3009
- var hasOnFailure = (stacks) => {
3010
- const onFailure = stacks.find((stack) => {
3011
- return typeof stack.onFailure !== "undefined";
3012
- });
3013
- return !!onFailure;
3014
- };
3015
-
3016
3033
  // src/feature/on-failure/index.ts
3017
3034
  import { Node as Node7, aws as aws7 } from "@awsless/formation";
3018
3035
  var onFailureFeature = defineFeature({
@@ -3072,7 +3089,7 @@ var pubsubFeature = defineFeature({
3072
3089
  onStack(ctx) {
3073
3090
  for (const [id, props] of Object.entries(ctx.stackConfig.pubsub ?? {})) {
3074
3091
  const group = new Node8(ctx.stack, "pubsub", id);
3075
- const { lambda } = createLambdaFunction(group, ctx, `pubsub`, id, props.consumer);
3092
+ const { lambda } = createAsyncLambdaFunction(group, ctx, `pubsub`, id, props.consumer);
3076
3093
  const name = formatLocalResourceName(ctx.app.name, ctx.stack.name, "pubsub", id);
3077
3094
  const topic = new aws8.iot.TopicRule(group, "rule", {
3078
3095
  name: name.replaceAll("-", "_"),
@@ -3221,8 +3238,7 @@ var storeFeature = defineFeature({
3221
3238
  "removed:marker": "s3:ObjectRemoved:DeleteMarkerCreated"
3222
3239
  };
3223
3240
  for (const [event, funcProps] of Object.entries(props.events ?? {})) {
3224
- const { lambda } = createLambdaFunction(group, ctx, `store`, id, funcProps);
3225
- lambda.addEnvironment("LOG_VIEWABLE_ERROR", "1");
3241
+ const { lambda } = createAsyncLambdaFunction(group, ctx, `store`, id, funcProps);
3226
3242
  lambdaConfigs.push({
3227
3243
  event: eventMap[event],
3228
3244
  function: lambda.arn
@@ -3382,8 +3398,7 @@ var topicFeature = defineFeature({
3382
3398
  endpoint: props
3383
3399
  });
3384
3400
  } else if (typeof props === "object") {
3385
- const { lambda } = createLambdaFunction(group, ctx, `topic`, id, props);
3386
- lambda.addEnvironment("LOG_VIEWABLE_ERROR", "1");
3401
+ const { lambda } = createAsyncLambdaFunction(group, ctx, `topic`, id, props);
3387
3402
  new aws12.sns.Subscription(group, id, {
3388
3403
  topicArn,
3389
3404
  protocol: "lambda",
@@ -3484,10 +3499,10 @@ var authFeature = defineFeature({
3484
3499
  const list4 = {};
3485
3500
  for (const [trigger, triggerProps] of Object.entries(props.triggers ?? {})) {
3486
3501
  const triggerGroup = new Node14(group, "trigger", trigger);
3487
- const { lambda, policy } = createLambdaFunction(
3502
+ const { lambda, policy } = createAsyncLambdaFunction(
3488
3503
  triggerGroup,
3489
3504
  ctx,
3490
- this.name,
3505
+ "auth",
3491
3506
  `${id}-${trigger}`,
3492
3507
  triggerProps
3493
3508
  );
@@ -4101,7 +4116,7 @@ var restFeature = defineFeature({
4101
4116
  // src/feature/task/index.ts
4102
4117
  import { camelCase as camelCase6 } from "change-case";
4103
4118
  import { relative as relative4 } from "path";
4104
- import { Node as Node19, aws as aws19 } from "@awsless/formation";
4119
+ import { Node as Node19 } from "@awsless/formation";
4105
4120
  var typeGenCode7 = `
4106
4121
  import { InvokeOptions } from '@awsless/lambda'
4107
4122
  import type { Mock } from 'vitest'
@@ -4150,20 +4165,7 @@ var taskFeature = defineFeature({
4150
4165
  onStack(ctx) {
4151
4166
  for (const [id, props] of Object.entries(ctx.stackConfig.tasks ?? {})) {
4152
4167
  const group = new Node19(ctx.stack, "task", id);
4153
- const { lambda, policy } = createLambdaFunction(group, ctx, "task", id, props.consumer);
4154
- lambda.addEnvironment("LOG_VIEWABLE_ERROR", "1");
4155
- const invokeConfig = new aws19.lambda.EventInvokeConfig(group, "config", {
4156
- functionArn: lambda.arn,
4157
- retryAttempts: props.retryAttempts,
4158
- onFailure: getGlobalOnFailure(ctx)
4159
- });
4160
- invokeConfig.dependsOn(policy);
4161
- if (hasOnFailure(ctx.stackConfigs)) {
4162
- policy.addStatement({
4163
- actions: ["sqs:SendMessage", "sqs:GetQueueUrl"],
4164
- resources: [getGlobalOnFailure(ctx)]
4165
- });
4166
- }
4168
+ createAsyncLambdaFunction(group, ctx, "task", id, props.consumer);
4167
4169
  }
4168
4170
  }
4169
4171
  });
@@ -4507,20 +4509,20 @@ var config = (program2) => {
4507
4509
  import { confirm as confirm3 } from "@clack/prompts";
4508
4510
 
4509
4511
  // src/util/workspace.ts
4510
- import { WorkSpace, aws as aws20, local } from "@awsless/formation";
4512
+ import { WorkSpace, aws as aws19, local } from "@awsless/formation";
4511
4513
  import { minutes as minutes4 } from "@awsless/duration";
4512
4514
  import { dirname as dirname8, join as join9 } from "path";
4513
4515
  import { mkdir as mkdir2, readFile as readFile6, rm, writeFile as writeFile2 } from "fs/promises";
4514
4516
  var createWorkSpace = (props) => {
4515
- const lockProvider = new aws20.dynamodb.LockProvider({
4517
+ const lockProvider = new aws19.dynamodb.LockProvider({
4516
4518
  ...props,
4517
4519
  tableName: "awsless-locks"
4518
4520
  });
4519
- const stateProvider = new aws20.s3.StateProvider({
4521
+ const stateProvider = new aws19.s3.StateProvider({
4520
4522
  ...props,
4521
4523
  bucket: "awsless-state"
4522
4524
  });
4523
- const cloudProviders = aws20.createCloudProviders({
4525
+ const cloudProviders = aws19.createCloudProviders({
4524
4526
  ...props,
4525
4527
  timeout: minutes4(60)
4526
4528
  });
@@ -4897,7 +4899,7 @@ var deploy = (program2) => {
4897
4899
  };
4898
4900
 
4899
4901
  // src/cli/command/diff.ts
4900
- import { WorkSpace as WorkSpace2, aws as aws21 } from "@awsless/formation";
4902
+ import { WorkSpace as WorkSpace2, aws as aws20 } from "@awsless/formation";
4901
4903
  import chalk7 from "chalk";
4902
4904
  var diff = (program2) => {
4903
4905
  program2.command("diff").description("Diff your app with AWS").action(async (filters) => {
@@ -4909,12 +4911,12 @@ var diff = (program2) => {
4909
4911
  const { app, builders } = createApp({ appConfig, stackConfigs, accountId }, filters);
4910
4912
  await buildAssets(builders);
4911
4913
  const workspace = new WorkSpace2({
4912
- stateProvider: new aws21.dynamodb.DynamoDBStateProvider({
4914
+ stateProvider: new aws20.dynamodb.DynamoDBStateProvider({
4913
4915
  credentials,
4914
4916
  region,
4915
4917
  tableName: "awsless-state"
4916
4918
  }),
4917
- cloudProviders: aws21.createCloudProviders({
4919
+ cloudProviders: aws20.createCloudProviders({
4918
4920
  credentials,
4919
4921
  region: appConfig.region
4920
4922
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.227",
3
+ "version": "0.0.229",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -31,11 +31,11 @@
31
31
  "@awsless/lambda": "^0.0.19",
32
32
  "@awsless/open-search": "^0.0.12",
33
33
  "@awsless/redis": "^0.0.12",
34
+ "@awsless/sns": "^0.0.7",
34
35
  "@awsless/s3": "^0.0.10",
35
36
  "@awsless/sqs": "^0.0.7",
36
- "@awsless/sns": "^0.0.7",
37
- "@awsless/ssm": "^0.0.7",
38
37
  "@awsless/validate": "^0.0.14",
38
+ "@awsless/ssm": "^0.0.7",
39
39
  "@awsless/weak-cache": "^0.0.1"
40
40
  },
41
41
  "dependencies": {
@@ -98,10 +98,10 @@
98
98
  "zod": "^3.21.4",
99
99
  "zod-to-json-schema": "^3.22.3",
100
100
  "@awsless/duration": "^0.0.1",
101
- "@awsless/size": "^0.0.1",
102
101
  "@awsless/graphql": "^0.0.9",
102
+ "@awsless/size": "^0.0.1",
103
+ "@awsless/formation": "^0.0.22",
103
104
  "@awsless/validate": "^0.0.14",
104
- "@awsless/formation": "^0.0.21",
105
105
  "@awsless/code": "^0.0.10"
106
106
  },
107
107
  "scripts": {