@awsless/awsless 0.0.210 → 0.0.211

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 +29 -15
  2. package/package.json +4 -4
package/dist/bin.js CHANGED
@@ -2051,6 +2051,17 @@ var build = (type, name, builder) => {
2051
2051
  });
2052
2052
  };
2053
2053
 
2054
+ // src/feature/on-failure/util.ts
2055
+ var getGlobalOnFailure = (ctx) => {
2056
+ return hasOnFailure(ctx.stackConfigs) ? ctx.shared.get("on-failure-queue-arn") : void 0;
2057
+ };
2058
+ var hasOnFailure = (stacks) => {
2059
+ const onFailure = stacks.find((stack) => {
2060
+ return typeof stack.onFailure !== "undefined";
2061
+ });
2062
+ return !!onFailure;
2063
+ };
2064
+
2054
2065
  // src/feature/function/util.ts
2055
2066
  var createLambdaFunction = (group, ctx, ns, id, local2) => {
2056
2067
  let name;
@@ -2113,9 +2124,15 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
2113
2124
  }
2114
2125
  new aws2.lambda.EventInvokeConfig(group, "async", {
2115
2126
  functionArn: lambda.arn,
2116
- retryAttempts: props.retryAttempts
2117
- // onFailure: getGlobalOnFailure(ctx),
2127
+ retryAttempts: props.retryAttempts,
2128
+ onFailure: getGlobalOnFailure(ctx)
2118
2129
  });
2130
+ if (hasOnFailure(ctx.stackConfigs)) {
2131
+ policy.addStatement({
2132
+ actions: ["sqs:SendMessage", "sqs:GetQueueUrl"],
2133
+ resources: [getGlobalOnFailure(ctx)]
2134
+ });
2135
+ }
2119
2136
  if (props.log.retention.value > 0n) {
2120
2137
  const logGroup = new aws2.cloudWatch.LogGroup(group, "log", {
2121
2138
  name: lambda.name.apply((name2) => `/aws/lambda/${name2}`),
@@ -2947,17 +2964,6 @@ var graphqlFeature = defineFeature({
2947
2964
  }
2948
2965
  });
2949
2966
 
2950
- // src/feature/on-failure/util.ts
2951
- var getGlobalOnFailure = (ctx) => {
2952
- return hasOnFailure(ctx.stackConfigs) ? ctx.shared.get("on-failure-queue-arn") : void 0;
2953
- };
2954
- var hasOnFailure = (stacks) => {
2955
- const onFailure = stacks.find((stack) => {
2956
- return typeof stack.onFailure !== "undefined";
2957
- });
2958
- return !!onFailure;
2959
- };
2960
-
2961
2967
  // src/feature/on-failure/index.ts
2962
2968
  import { Node as Node7, aws as aws7 } from "@awsless/formation";
2963
2969
  var onFailureFeature = defineFeature({
@@ -2983,11 +2989,12 @@ var onFailureFeature = defineFeature({
2983
2989
  const queueArn = ctx.shared.get("on-failure-queue-arn");
2984
2990
  const group = new Node7(ctx.stack, "on-failure", "failure");
2985
2991
  const { lambda, policy } = createLambdaFunction(group, ctx, "on-failure", "failure", onFailure);
2986
- new aws7.lambda.EventSourceMapping(group, "on-failure", {
2992
+ const source = new aws7.lambda.EventSourceMapping(group, "on-failure", {
2987
2993
  functionArn: lambda.arn,
2988
2994
  sourceArn: queueArn,
2989
2995
  batchSize: 10
2990
2996
  });
2997
+ source.dependsOn(policy);
2991
2998
  policy.addStatement({
2992
2999
  actions: [
2993
3000
  "sqs:SendMessage",
@@ -3196,6 +3203,7 @@ var tableFeature = defineFeature({
3196
3203
  });
3197
3204
  if (props.stream) {
3198
3205
  const { lambda, policy } = createLambdaFunction(group, ctx, "table", id, props.stream.consumer);
3206
+ const onFailure = getGlobalOnFailure(ctx);
3199
3207
  const source = new aws11.lambda.EventSourceMapping(group, id, {
3200
3208
  functionArn: lambda.arn,
3201
3209
  sourceArn: table2.streamArn,
@@ -3204,10 +3212,16 @@ var tableFeature = defineFeature({
3204
3212
  // retryAttempts: props.stream.consumer.retryAttempts ?? -1,
3205
3213
  parallelizationFactor: 1,
3206
3214
  startingPosition: "latest",
3207
- onFailure: getGlobalOnFailure(ctx)
3215
+ onFailure
3208
3216
  });
3209
3217
  policy.addStatement(table2.streamPermissions);
3210
3218
  source.dependsOn(policy);
3219
+ if (onFailure) {
3220
+ policy.addStatement({
3221
+ actions: ["sqs:SendMessage", "sqs:GetQueueUrl"],
3222
+ resources: [onFailure]
3223
+ });
3224
+ }
3211
3225
  }
3212
3226
  ctx.onFunction(({ policy }) => {
3213
3227
  policy.addStatement(...table2.permissions);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.210",
3
+ "version": "0.0.211",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -30,10 +30,10 @@
30
30
  "peerDependencies": {
31
31
  "@awsless/lambda": "^0.0.18",
32
32
  "@awsless/open-search": "^0.0.12",
33
+ "@awsless/s3": "^0.0.10",
33
34
  "@awsless/redis": "^0.0.12",
34
35
  "@awsless/sns": "^0.0.7",
35
36
  "@awsless/sqs": "^0.0.7",
36
- "@awsless/s3": "^0.0.10",
37
37
  "@awsless/validate": "^0.0.13",
38
38
  "@awsless/ssm": "^0.0.7",
39
39
  "@awsless/weak-cache": "^0.0.1"
@@ -97,11 +97,11 @@
97
97
  "wrap-ansi": "^8.1.0",
98
98
  "zod": "^3.21.4",
99
99
  "zod-to-json-schema": "^3.22.3",
100
- "@awsless/formation": "^0.0.20",
101
100
  "@awsless/duration": "^0.0.1",
102
- "@awsless/size": "^0.0.1",
101
+ "@awsless/formation": "^0.0.20",
103
102
  "@awsless/graphql": "^0.0.9",
104
103
  "@awsless/validate": "^0.0.13",
104
+ "@awsless/size": "^0.0.1",
105
105
  "@awsless/code": "^0.0.10"
106
106
  },
107
107
  "scripts": {