@mbc-cqrs-serverless/cli 1.3.3 → 1.3.5

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/index.js CHANGED
@@ -11,7 +11,7 @@ async function bootstrap() {
11
11
  const program = new commander_1.Command();
12
12
  program
13
13
  .version(
14
- // eslint-disable-next-line @typescript-eslint/no-var-requires
14
+ // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
15
15
  require('../package.json').version, '-v, --version', 'Output the current version.')
16
16
  .usage('<command> [options]')
17
17
  .helpOption('-h, --help', 'Output usage information.');
@@ -14,7 +14,7 @@ function localBinExists() {
14
14
  return (0, fs_1.existsSync)((0, path_1.join)(...localBinPathSegments));
15
15
  }
16
16
  function loadLocalBinCommandLoader() {
17
- // eslint-disable-next-line @typescript-eslint/no-var-requires
17
+ // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
18
18
  const commandLoader = require(path_1.posix.join(...localBinPathSegments, 'dist', 'commands'));
19
19
  return commandLoader;
20
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mbc-cqrs-serverless/cli",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "a CLI to get started with MBC CQRS serverless framework",
5
5
  "keywords": [
6
6
  "mbc",
@@ -58,5 +58,5 @@
58
58
  "@faker-js/faker": "^8.3.1",
59
59
  "copyfiles": "^2.4.1"
60
60
  },
61
- "gitHead": "3307005192eff1d8ac1eae7e72b838fe7ff95af9"
61
+ "gitHead": "ec9f5438d64b3bcc7c62feb1327acc652e4c1aad"
62
62
  }
@@ -20,6 +20,8 @@ EVENT_SOURCE_DISABLED=false
20
20
  # Serverless Offline (API Gateway)
21
21
  LOCAL_HTTP_PORT=3000
22
22
  LOCAL_LAMBDA_PORT=3002
23
+ # serverless-offline-lambda (external Lambda invoke)
24
+ LOCAL_OFFLINE_LAMBDA_PORT=4000
23
25
  # DynamoDB Local
24
26
  LOCAL_DYNAMODB_PORT=8000
25
27
  # MySQL (RDS)
@@ -48,8 +50,12 @@ LOCAL_DDB_ADMIN_PORT=8001
48
50
  # DynamoDB endpoint, useful for local development
49
51
  DYNAMODB_ENDPOINT=http://localhost:${LOCAL_DYNAMODB_PORT:-8000}
50
52
  DYNAMODB_REGION=ap-northeast-1
51
- # set the limit size for `attributes` of object in DDB
52
- ATTRIBUTE_LIMIT_SIZE=389120 # bytes, refer to https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ServiceQuotas.html#limits-attributes
53
+ # Max size (bytes) for `attributes` before S3 offload.
54
+ # Must account for Step Functions 256 KB payload limit: the SFN state passes
55
+ # the DynamoDB event twice (input + context.Execution.Input), so the safe
56
+ # limit is ~(256 KB - overhead) / 2 ≈ 110 KB. Default: 100 KB.
57
+ # DynamoDB item limit is 400 KB — do NOT use that as the reference.
58
+ ATTRIBUTE_LIMIT_SIZE=102400
53
59
  # S3 endpoint, useful for local development
54
60
  S3_ENDPOINT=http://localhost:${LOCAL_S3_PORT:-4566}
55
61
  S3_REGION=ap-northeast-1
@@ -68,7 +74,9 @@ SNS_ALARM_TOPIC_ARN=arn:aws:sns:ap-northeast-1:101010101010:AlarmSnsTopic
68
74
  # Cognito endpoint, useful for local development
69
75
  COGNITO_URL=http://localhost:${LOCAL_COGNITO_PORT:-9229}
70
76
  COGNITO_USER_POOL_ID=local_2G7noHgW
71
- COGNITO_USER_POLL_CLIENT_ID=dnk8y7ii3wled35p3lw0l2cd7
77
+ COGNITO_USER_POOL_CLIENT_ID=dnk8y7ii3wled35p3lw0l2cd7
78
+ # DEPRECATED: Use COGNITO_USER_POOL_CLIENT_ID instead (typo: POLL -> POOL)
79
+ # COGNITO_USER_POLL_CLIENT_ID=dnk8y7ii3wled35p3lw0l2cd7
72
80
  COGNITO_REGION=ap-northeast-1
73
81
  # AppSync endpoint, useful for local development
74
82
  APPSYNC_ENDPOINT=http://localhost:${LOCAL_APPSYNC_PORT:-4001}/graphql
@@ -10,8 +10,33 @@ export type Config = {
10
10
  domain: {
11
11
  http: string
12
12
  appsync: string
13
+ appsyncEvents?: string // optional: custom domain for AppSync Events API
13
14
  }
14
15
 
16
+ appsyncEvents?: {
17
+ /** Set true to create the AppSync Events API and inject env vars into Lambda/ECS */
18
+ enabled: boolean
19
+ /**
20
+ * Channel namespace name — must be a pre-registered name in the AppSync Event API.
21
+ * Becomes segment 1 of every channel path: /{namespace}/{tenantCode}/{table}/{action}/{id}
22
+ * Defaults to 'default'.
23
+ */
24
+ namespace: string
25
+ /** API key TTL in days. Defaults to 365. */
26
+ apiKeyExpireDays?: number
27
+ }
28
+
29
+ /**
30
+ * Value injected as NOTIFICATION_TRANSPORTS env var into Lambda/ECS.
31
+ * Controls which transports NotificationEventHandler uses.
32
+ * Examples:
33
+ * 'appsync-event' — Events API only
34
+ * 'appsync-graphql' — GraphQL API only
35
+ * 'appsync-graphql,appsync-event' — dual-publish (migration mode)
36
+ * Defaults to 'appsync-event' when appsyncEvents is enabled.
37
+ */
38
+ notificationTransports?: string
39
+
15
40
  // existing resources
16
41
  userPoolId?: string
17
42
 
@@ -249,6 +249,76 @@ export class InfraStack extends cdk.Stack {
249
249
  this.graphqlApiKey = new cdk.CfnOutput(this, 'GraphQLAPIKey', {
250
250
  value: appSyncApi.apiKey || '',
251
251
  })
252
+
253
+ // AppSync Events API (HTTP pub/sub, schema-free)
254
+ // Uses L2 EventApi so that ChannelNamespace can set explicit publishAuthModeTypes
255
+ // and subscribeAuthModeTypes — without these the namespace has no effective
256
+ // authorization and Lambda publish calls receive 401.
257
+ let appSyncEventsApi: cdk.aws_appsync.EventApi | undefined
258
+ if (props.config.appsyncEvents?.enabled) {
259
+ const expireDays = props.config.appsyncEvents.apiKeyExpireDays ?? 365
260
+
261
+ appSyncEventsApi = new cdk.aws_appsync.EventApi(this, 'events-api', {
262
+ apiName: prefix + 'events',
263
+ authorizationConfig: {
264
+ authProviders: [
265
+ {
266
+ authorizationType: cdk.aws_appsync.AppSyncAuthorizationType.IAM,
267
+ },
268
+ {
269
+ authorizationType:
270
+ cdk.aws_appsync.AppSyncAuthorizationType.API_KEY,
271
+ apiKeyConfig: {
272
+ expires: cdk.Expiration.after(cdk.Duration.days(expireDays)),
273
+ },
274
+ },
275
+ ],
276
+ // API-level defaults — overridden per-namespace below
277
+ connectionAuthModeTypes: [
278
+ cdk.aws_appsync.AppSyncAuthorizationType.API_KEY,
279
+ ],
280
+ defaultPublishAuthModeTypes: [
281
+ cdk.aws_appsync.AppSyncAuthorizationType.IAM,
282
+ ],
283
+ defaultSubscribeAuthModeTypes: [
284
+ cdk.aws_appsync.AppSyncAuthorizationType.API_KEY,
285
+ ],
286
+ },
287
+ })
288
+
289
+ // Namespace — explicitly sets auth per operation so it is never left
290
+ // without authorization (which caused the 401).
291
+ // publish = AWS_IAM → Lambda signs with its execution role
292
+ // subscribe = API_KEY → browser clients pass x-api-key header
293
+ new cdk.aws_appsync.ChannelNamespace(this, 'events-namespace', {
294
+ api: appSyncEventsApi,
295
+ channelNamespaceName: props.config.appsyncEvents.namespace ?? 'default',
296
+ authorizationConfig: {
297
+ publishAuthModeTypes: [cdk.aws_appsync.AppSyncAuthorizationType.IAM],
298
+ subscribeAuthModeTypes: [
299
+ cdk.aws_appsync.AppSyncAuthorizationType.API_KEY,
300
+ ],
301
+ },
302
+ })
303
+
304
+ // Outputs
305
+ new cdk.CfnOutput(this, 'AppSyncEventsHttpEndpoint', {
306
+ value: `https://${appSyncEventsApi.httpDns}/event`,
307
+ description:
308
+ 'AppSync Events HTTP endpoint — APPSYNC_EVENTS_ENDPOINT env var',
309
+ })
310
+ new cdk.CfnOutput(this, 'AppSyncEventsRealtimeEndpoint', {
311
+ value: `wss://${appSyncEventsApi.realtimeDns}/event/realtime`,
312
+ description:
313
+ 'AppSync Events WebSocket endpoint for client subscriptions',
314
+ })
315
+ new cdk.CfnOutput(this, 'AppSyncEventsNamespace', {
316
+ value: props.config.appsyncEvents.namespace ?? 'default',
317
+ description:
318
+ 'AppSync Events namespace — APPSYNC_EVENTS_NAMESPACE env var',
319
+ })
320
+ }
321
+
252
322
  // S3
253
323
  const ddbBucket = new cdk.aws_s3.Bucket(this, 'ddb-attributes', {
254
324
  bucketName: prefix + 'ddb-attributes', // Globally unique bucket name
@@ -389,7 +459,12 @@ export class InfraStack extends cdk.Stack {
389
459
  APP_NAME: name,
390
460
  LOG_LEVEL: props.config.logLevel?.level || 'info',
391
461
  EVENT_SOURCE_DISABLED: 'false',
392
- ATTRIBUTE_LIMIT_SIZE: '389120',
462
+ // Max size (bytes) for `attributes` before S3 offload.
463
+ // Must account for Step Functions 256 KB payload limit: the SFN state passes
464
+ // the DynamoDB event twice (input + context.Execution.Input), so the safe
465
+ // limit is ~(256 KB - overhead) / 2 ≈ 110 KB. Default: 100 KB.
466
+ // DynamoDB item limit is 400 KB — do NOT use that as the reference.
467
+ ATTRIBUTE_LIMIT_SIZE: '102400',
393
468
  S3_BUCKET_NAME: ddbBucket.bucketName,
394
469
  SFN_COMMAND_ARN: commandSfnArn,
395
470
  SFN_TASK_ARN: taskSfnArn,
@@ -398,6 +473,16 @@ export class InfraStack extends cdk.Stack {
398
473
  SNS_ALARM_TOPIC_ARN: alarmSns.topicArn,
399
474
  COGNITO_USER_POOL_ID: userPool.userPoolId,
400
475
  APPSYNC_ENDPOINT: appSyncApi.graphqlUrl,
476
+ // AppSync Events — only injected when feature is enabled
477
+ ...(props.config.appsyncEvents?.enabled && appSyncEventsApi
478
+ ? {
479
+ NOTIFICATION_TRANSPORTS:
480
+ props.config.notificationTransports ?? 'appsync-event',
481
+ APPSYNC_EVENTS_ENDPOINT: `https://${appSyncEventsApi.httpDns}/event`,
482
+ APPSYNC_EVENTS_NAMESPACE:
483
+ props.config.appsyncEvents.namespace ?? 'default',
484
+ }
485
+ : {}),
401
486
  SES_FROM_EMAIL: props.config.fromEmailAddress,
402
487
  DATABASE_URL: `postgresql://${props.config.rds.accountSsmKey}@${props.config.rds.endpoint}/${props.config.rds.dbName}?schema=public`,
403
488
  S3_PUBLIC_BUCKET_NAME: publicBucket.bucketName,
@@ -645,6 +730,14 @@ export class InfraStack extends cdk.Stack {
645
730
  domainName: httpDistribution.distributionDomainName,
646
731
  })
647
732
 
733
+ if (props.config.domain.appsyncEvents && appSyncEventsApi) {
734
+ new cdk.aws_route53.CnameRecord(this, 'AppSyncEventsCnameRecord', {
735
+ zone: hostedZone,
736
+ recordName: props.config.domain.appsyncEvents,
737
+ domainName: appSyncEventsApi.httpDns,
738
+ })
739
+ }
740
+
648
741
  this.httpDistributionDomain = new cdk.CfnOutput(
649
742
  this,
650
743
  'http-distribution-domain',
@@ -692,6 +785,10 @@ export class InfraStack extends cdk.Stack {
692
785
  stateName: string,
693
786
  nextState: cdk.aws_stepfunctions.IChainable | null,
694
787
  integrationPattern: cdk.aws_stepfunctions.IntegrationPattern,
788
+ taskTimeout?: cdk.aws_stepfunctions.Timeout,
789
+ configureTask?: (
790
+ task: cdk.aws_stepfunctions_tasks.LambdaInvoke,
791
+ ) => cdk.aws_stepfunctions.IChainable,
695
792
  ) => {
696
793
  const payloadObject: {
697
794
  [key: string]: any
@@ -703,7 +800,7 @@ export class InfraStack extends cdk.Stack {
703
800
  integrationPattern ===
704
801
  cdk.aws_stepfunctions.IntegrationPattern.WAIT_FOR_TASK_TOKEN
705
802
  ) {
706
- payloadObject['taskToken'] = cdk.aws_stepfunctions.JsonPath.taskToken // '$$.Task.Token'
803
+ payloadObject['taskToken'] = cdk.aws_stepfunctions.JsonPath.taskToken
707
804
  }
708
805
  const lambdaTask = new cdk.aws_stepfunctions_tasks.LambdaInvoke(
709
806
  this,
@@ -715,12 +812,19 @@ export class InfraStack extends cdk.Stack {
715
812
  stateName,
716
813
  outputPath: '$.Payload[0][0]',
717
814
  integrationPattern,
815
+ ...(taskTimeout ? { taskTimeout } : {}),
718
816
  },
719
817
  )
818
+ // addCatch must run on the State before .next() turns it into a Chain.
819
+ const configuredTask = configureTask
820
+ ? (configureTask(
821
+ lambdaTask,
822
+ ) as cdk.aws_stepfunctions_tasks.LambdaInvoke)
823
+ : lambdaTask
720
824
  if (nextState) {
721
- return lambdaTask.next(nextState)
825
+ return configuredTask.next(nextState)
722
826
  }
723
- return lambdaTask
827
+ return configuredTask
724
828
  }
725
829
 
726
830
  // Define states
@@ -766,10 +870,34 @@ export class InfraStack extends cdk.Stack {
766
870
  cdk.aws_stepfunctions.IntegrationPattern.REQUEST_RESPONSE,
767
871
  )
768
872
 
873
+ // States.Timeout never invokes the wait_prev_command Lambda, so the
874
+ // command row is not updated (status/taskToken stay post-waitConfirmToken,
875
+ // typically wait_prev_command:FINISHED + stale token). That is one case of
876
+ // the broader cascade: any predecessor exit before FINISH leaves a
877
+ // non-finish status, so later versions will not self-resume and may each
878
+ // wait another 24h. Execution still fails here (CW ExecutionsFailed may fire).
879
+ const waitPrevCommandTimeoutHandler = new cdk.aws_stepfunctions.Pass(
880
+ this,
881
+ 'wait_prev_command_timeout',
882
+ {
883
+ stateName: 'wait_prev_command_timeout',
884
+ parameters: {
885
+ error: 'States.Timeout',
886
+ cause: 'wait_prev_command exceeded taskTimeout (24h)',
887
+ },
888
+ },
889
+ ).next(fail)
890
+
769
891
  const waitPrevCommand = lambdaInvoke(
770
892
  'wait_prev_command',
771
893
  setTtlCommand,
772
894
  cdk.aws_stepfunctions.IntegrationPattern.WAIT_FOR_TASK_TOKEN,
895
+ cdk.aws_stepfunctions.Timeout.duration(cdk.Duration.hours(24)),
896
+ (task) =>
897
+ task.addCatch(waitPrevCommandTimeoutHandler, {
898
+ errors: ['States.Timeout'],
899
+ resultPath: '$.timeoutError',
900
+ }),
773
901
  )
774
902
 
775
903
  // Define Choice state
@@ -824,6 +952,32 @@ export class InfraStack extends cdk.Stack {
824
952
  },
825
953
  )
826
954
 
955
+ // Pages when any command-handler execution fails — including wait_prev_command
956
+ // States.Timeout, which never invokes Lambda so publishAlarm cannot run.
957
+ const commandSfnFailedAlarm = new cdk.aws_cloudwatch.Alarm(
958
+ this,
959
+ 'command-handler-sfn-failed-alarm',
960
+ {
961
+ alarmName: prefix + 'command-handler-sfn-failed',
962
+ alarmDescription:
963
+ 'Command handler Step Functions execution failed (includes wait_prev_command 24h timeout)',
964
+ metric: stateMachine.metricFailed({
965
+ period: cdk.Duration.minutes(1),
966
+ statistic: 'Sum',
967
+ }),
968
+ threshold: 1,
969
+ evaluationPeriods: 1,
970
+ datapointsToAlarm: 1,
971
+ treatMissingData: cdk.aws_cloudwatch.TreatMissingData.NOT_BREACHING,
972
+ comparisonOperator:
973
+ cdk.aws_cloudwatch.ComparisonOperator
974
+ .GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
975
+ },
976
+ )
977
+ commandSfnFailedAlarm.addAlarmAction(
978
+ new cdk.aws_cloudwatch_actions.SnsAction(alarmSns),
979
+ )
980
+
827
981
  // Output the State Machine's ARN
828
982
  this.stateMachineArn = new cdk.CfnOutput(this, 'StateMachineArn', {
829
983
  value: stateMachine.stateMachineArn,
@@ -957,7 +1111,7 @@ export class InfraStack extends cdk.Stack {
957
1111
  },
958
1112
  })
959
1113
  .itemProcessor(csvRowsHandlerState, {
960
- executionType: aws_stepfunctions.ProcessorType.STANDARD,
1114
+ executionType: cdk.aws_stepfunctions.ProcessorType.STANDARD,
961
1115
  })
962
1116
 
963
1117
  // Catch ALL Map state errors and route them to finalizeParentJobState
@@ -1100,6 +1254,8 @@ export class InfraStack extends cdk.Stack {
1100
1254
  appSyncApi.grantMutation(lambdaApi)
1101
1255
  importActionSqs.grantSendMessages(lambdaApi)
1102
1256
 
1257
+ appSyncEventsApi?.grantPublish(lambdaApi)
1258
+
1103
1259
  // Define an IAM policy for full DynamoDB access
1104
1260
  const dynamoDbTablePrefixArn = cdk.Arn.format({
1105
1261
  partition: 'aws',
@@ -1135,6 +1291,14 @@ export class InfraStack extends cdk.Stack {
1135
1291
  resources: [commandSfnArn],
1136
1292
  })
1137
1293
 
1294
+ // SendTaskSuccess is scoped to this command state machine (same pattern as
1295
+ // CDK stateMachine.grantTaskResponse). Task tokens are still required at
1296
+ // call time; Resource '*' is unnecessary and over-broad for the template.
1297
+ const sfnTaskTokenPolicy = new cdk.aws_iam.PolicyStatement({
1298
+ actions: ['states:SendTaskSuccess'],
1299
+ resources: [stateMachine.stateMachineArn],
1300
+ })
1301
+
1138
1302
  const taskSfnPolicy = new cdk.aws_iam.PolicyStatement({
1139
1303
  actions: ['states:*'],
1140
1304
  resources: [taskSfnArn], // Access to all resources
@@ -1148,7 +1312,7 @@ export class InfraStack extends cdk.Stack {
1148
1312
  // Attach the policy to the Lambda function's execution role
1149
1313
  lambdaApi.role?.attachInlinePolicy(
1150
1314
  new cdk.aws_iam.Policy(this, 'lambda-event-sfn-policy', {
1151
- statements: [sfnPolicy],
1315
+ statements: [sfnPolicy, sfnTaskTokenPolicy],
1152
1316
  }),
1153
1317
  )
1154
1318
 
@@ -1231,6 +1395,7 @@ export class InfraStack extends cdk.Stack {
1231
1395
  statements: [ssmPolicy],
1232
1396
  }),
1233
1397
  )
1398
+ appSyncEventsApi?.grantPublish(taskRole)
1234
1399
  }
1235
1400
  }
1236
1401
  }
@@ -90,7 +90,7 @@ exports[`snapshot test for InfraStack 1`] = `
90
90
  "Arn",
91
91
  ],
92
92
  },
93
- "Runtime": "nodejs22.x",
93
+ "Runtime": "nodejs24.x",
94
94
  "Tags": [
95
95
  {
96
96
  "Key": "env",
@@ -210,6 +210,45 @@ exports[`snapshot test for InfraStack 1`] = `
210
210
  },
211
211
  "Type": "AWS::Cognito::UserPoolClient",
212
212
  },
213
+ "commandhandlersfnfailedalarmB54C35EC": {
214
+ "Properties": {
215
+ "AlarmActions": [
216
+ {
217
+ "Ref": "alarmsnsFB7BBC3B",
218
+ },
219
+ ],
220
+ "AlarmDescription": "Command handler Step Functions execution failed (includes wait_prev_command 24h timeout)",
221
+ "AlarmName": "dev--command-handler-sfn-failed",
222
+ "ComparisonOperator": "GreaterThanOrEqualToThreshold",
223
+ "DatapointsToAlarm": 1,
224
+ "Dimensions": [
225
+ {
226
+ "Name": "StateMachineArn",
227
+ "Value": {
228
+ "Ref": "commandhandlerstatemachine937D91FB",
229
+ },
230
+ },
231
+ ],
232
+ "EvaluationPeriods": 1,
233
+ "MetricName": "ExecutionsFailed",
234
+ "Namespace": "AWS/States",
235
+ "Period": 60,
236
+ "Statistic": "Sum",
237
+ "Tags": [
238
+ {
239
+ "Key": "env",
240
+ "Value": "dev",
241
+ },
242
+ {
243
+ "Key": "name",
244
+ "Value": "",
245
+ },
246
+ ],
247
+ "Threshold": 1,
248
+ "TreatMissingData": "notBreaching",
249
+ },
250
+ "Type": "AWS::CloudWatch::Alarm",
251
+ },
213
252
  "commandhandlersfnlog9072E963": {
214
253
  "DeletionPolicy": "Delete",
215
254
  "Properties": {
@@ -251,7 +290,7 @@ exports[`snapshot test for InfraStack 1`] = `
251
290
  "Arn",
252
291
  ],
253
292
  },
254
- "","Payload":{"input.$":"$","context.$":"$$"}}},"check_version_result":{"Type":"Choice","Choices":[{"Variable":"$.result","NumericEquals":0,"Next":"set_ttl_command"},{"Variable":"$.result","NumericEquals":1,"Next":"wait_prev_command"},{"Variable":"$.result","NumericEquals":-1,"Next":"fail"}],"Default":"wait_prev_command"},"wait_prev_command":{"Next":"set_ttl_command","Retry":[{"ErrorEquals":["Lambda.ClientExecutionTimeoutException","Lambda.ServiceException","Lambda.AWSLambdaException","Lambda.SdkClientException"],"IntervalSeconds":2,"MaxAttempts":6,"BackoffRate":2}],"Type":"Task","OutputPath":"$.Payload[0][0]","Resource":"arn:",
293
+ "","Payload":{"input.$":"$","context.$":"$$"}}},"check_version_result":{"Type":"Choice","Choices":[{"Variable":"$.result","NumericEquals":0,"Next":"set_ttl_command"},{"Variable":"$.result","NumericEquals":1,"Next":"wait_prev_command"},{"Variable":"$.result","NumericEquals":-1,"Next":"fail"}],"Default":"wait_prev_command"},"wait_prev_command":{"Next":"set_ttl_command","Retry":[{"ErrorEquals":["Lambda.ClientExecutionTimeoutException","Lambda.ServiceException","Lambda.AWSLambdaException","Lambda.SdkClientException"],"IntervalSeconds":2,"MaxAttempts":6,"BackoffRate":2}],"Catch":[{"ErrorEquals":["States.Timeout"],"ResultPath":"$.timeoutError","Next":"wait_prev_command_timeout"}],"Type":"Task","TimeoutSeconds":86400,"OutputPath":"$.Payload[0][0]","Resource":"arn:",
255
294
  {
256
295
  "Ref": "AWS::Partition",
257
296
  },
@@ -317,7 +356,7 @@ exports[`snapshot test for InfraStack 1`] = `
317
356
  "Arn",
318
357
  ],
319
358
  },
320
- "","Payload":{"input.$":"$","context.$":"$$"}}},"success":{"Type":"Succeed"},"fail":{"Type":"Fail","ErrorPath":"$.error","CausePath":"$.cause"}},"Comment":"A state machine that run the command stream handler"}",
359
+ "","Payload":{"input.$":"$","context.$":"$$"}}},"success":{"Type":"Succeed"},"wait_prev_command_timeout":{"Type":"Pass","Parameters":{"error":"States.Timeout","cause":"wait_prev_command exceeded taskTimeout (24h)"},"Next":"fail"},"fail":{"Type":"Fail","ErrorPath":"$.error","CausePath":"$.cause"}},"Comment":"A state machine that run the command stream handler"}",
321
360
  ],
322
361
  ],
323
362
  },
@@ -821,7 +860,18 @@ exports[`snapshot test for InfraStack 1`] = `
821
860
  "Fn::Join": [
822
861
  "",
823
862
  [
824
- "{"StartAt":"import-csv","States":{"import-csv":{"Type":"Map","End":true,"ItemProcessor":{"ProcessorConfig":{"Mode":"DISTRIBUTED","ExecutionType":"EXPRESS"},"StartAt":"csv_rows_handler","States":{"csv_rows_handler":{"End":true,"Retry":[{"ErrorEquals":["Lambda.ClientExecutionTimeoutException","Lambda.ServiceException","Lambda.AWSLambdaException","Lambda.SdkClientException"],"IntervalSeconds":2,"MaxAttempts":6,"BackoffRate":2}],"Type":"Task","OutputPath":"$.Payload[0][0]","Resource":"arn:",
863
+ "{"StartAt":"import-csv","States":{"import-csv":{"Type":"Map","ResultPath":"$.mapOutput","Next":"finalize_parent_job","Catch":[{"ErrorEquals":["States.ALL"],"ResultPath":"$.errorOutput","Next":"finalize_parent_job"}],"ItemProcessor":{"ProcessorConfig":{"Mode":"DISTRIBUTED","ExecutionType":"STANDARD"},"StartAt":"csv_rows_handler","States":{"csv_rows_handler":{"End":true,"Retry":[{"ErrorEquals":["Lambda.ClientExecutionTimeoutException","Lambda.ServiceException","Lambda.AWSLambdaException","Lambda.SdkClientException"],"IntervalSeconds":2,"MaxAttempts":6,"BackoffRate":2}],"Type":"Task","OutputPath":"$.Payload[0][0]","Resource":"arn:",
864
+ {
865
+ "Ref": "AWS::Partition",
866
+ },
867
+ ":states:::lambda:invoke","Parameters":{"FunctionName":"",
868
+ {
869
+ "Fn::GetAtt": [
870
+ "lambdaapi893CD94E",
871
+ "Arn",
872
+ ],
873
+ },
874
+ "","Payload":{"input.$":"$","context.$":"$$"}}}}},"MaxConcurrency":50,"ItemReader":{"Resource":"arn:aws:states:::s3:getObject","ReaderConfig":{"InputType":"CSV","CSVHeaderLocation":"FIRST_ROW"},"Parameters":{"Bucket.$":"$.bucket","Key.$":"$.key"}},"ResultWriter":{"Resource":"arn:aws:states:::s3:putObject","Parameters":{"Bucket":"your-import-bucket-name","Prefix":"sfn-results/import-csv"}},"ItemBatcher":{"MaxItemsPerBatch":100,"BatchInput":{"Attributes.$":"$"}},"Label":"import-csv"},"finalize_parent_job":{"Next":"success","Retry":[{"ErrorEquals":["Lambda.ServiceException","Lambda.AWSLambdaException","Lambda.SdkClientException"],"IntervalSeconds":2,"MaxAttempts":5,"BackoffRate":2}],"Type":"Task","OutputPath":"$.Payload[0][0]","Resource":"arn:",
825
875
  {
826
876
  "Ref": "AWS::Partition",
827
877
  },
@@ -832,7 +882,7 @@ exports[`snapshot test for InfraStack 1`] = `
832
882
  "Arn",
833
883
  ],
834
884
  },
835
- "","Payload":{"input.$":"$","context.$":"$$"}}}}},"MaxConcurrency":50,"ItemReader":{"Resource":"arn:aws:states:::s3:getObject","ReaderConfig":{"InputType":"CSV","CSVHeaderLocation":"FIRST_ROW"},"Parameters":{"Bucket.$":"$.bucket","Key.$":"$.key"}},"ItemBatcher":{"MaxInputBytesPerBatch":10,"BatchInput":{"Attributes.$":"$"}},"Label":"import-csv"}},"Comment":"A state machine for import-csv module handler"}",
885
+ "","Payload":{"input.$":"$","context.$":"$$"}}},"success":{"Type":"Succeed"}},"Comment":"A state machine for import-csv module handler"}",
836
886
  ],
837
887
  ],
838
888
  },
@@ -1059,13 +1109,16 @@ exports[`snapshot test for InfraStack 1`] = `
1059
1109
  ],
1060
1110
  },
1061
1111
  "APP_NAME": "",
1062
- "ATTRIBUTE_LIMIT_SIZE": "389120",
1112
+ "ATTRIBUTE_LIMIT_SIZE": "102400",
1063
1113
  "COGNITO_USER_POOL_ID": {
1064
1114
  "Ref": "devuserpool23B1805F",
1065
1115
  },
1066
1116
  "DATABASE_URL": "postgresql://@/?schema=public",
1067
1117
  "EVENT_SOURCE_DISABLED": "false",
1068
1118
  "FRONT_BASE_URL": "",
1119
+ "IMPORT_QUEUE_URL": {
1120
+ "Ref": "importactionsqs5E43BE2E",
1121
+ },
1069
1122
  "LOG_LEVEL": "verbose",
1070
1123
  "NODE_ENV": "dev",
1071
1124
  "NODE_OPTIONS": "--enable-source-maps",
@@ -1118,7 +1171,7 @@ exports[`snapshot test for InfraStack 1`] = `
1118
1171
  "Value": "",
1119
1172
  },
1120
1173
  ],
1121
- "Timeout": 31536000,
1174
+ "Timeout": 30,
1122
1175
  "TracingConfig": {
1123
1176
  "Mode": "Active",
1124
1177
  },
@@ -1148,7 +1201,7 @@ exports[`snapshot test for InfraStack 1`] = `
1148
1201
  "FilterCriteria": {
1149
1202
  "Filters": [
1150
1203
  {
1151
- "Pattern": "{"eventName":["INSERT"]}",
1204
+ "Pattern": "{"eventName":["INSERT"],"dynamodb":{"NewImage":{"syncMode":[{"exists":false}]}}}",
1152
1205
  },
1153
1206
  ],
1154
1207
  },
@@ -1181,7 +1234,7 @@ exports[`snapshot test for InfraStack 1`] = `
1181
1234
  "FilterCriteria": {
1182
1235
  "Filters": [
1183
1236
  {
1184
- "Pattern": "{"eventName":["INSERT"]}",
1237
+ "Pattern": "{"eventName":["INSERT"],"dynamodb":{"NewImage":{"syncMode":[{"exists":false}]}}}",
1185
1238
  },
1186
1239
  ],
1187
1240
  },
@@ -1214,7 +1267,7 @@ exports[`snapshot test for InfraStack 1`] = `
1214
1267
  "FilterCriteria": {
1215
1268
  "Filters": [
1216
1269
  {
1217
- "Pattern": "{"eventName":["INSERT"]}",
1270
+ "Pattern": "{"eventName":["INSERT"],"dynamodb":{"NewImage":{"syncMode":[{"exists":false}]}}}",
1218
1271
  },
1219
1272
  ],
1220
1273
  },
@@ -1594,6 +1647,20 @@ exports[`snapshot test for InfraStack 1`] = `
1594
1647
  ],
1595
1648
  },
1596
1649
  },
1650
+ {
1651
+ "Action": [
1652
+ "sqs:SendMessage",
1653
+ "sqs:GetQueueAttributes",
1654
+ "sqs:GetQueueUrl",
1655
+ ],
1656
+ "Effect": "Allow",
1657
+ "Resource": {
1658
+ "Fn::GetAtt": [
1659
+ "importactionsqs5E43BE2E",
1660
+ "Arn",
1661
+ ],
1662
+ },
1663
+ },
1597
1664
  ],
1598
1665
  "Version": "2012-10-17",
1599
1666
  },
@@ -1769,6 +1836,13 @@ exports[`snapshot test for InfraStack 1`] = `
1769
1836
  "Effect": "Allow",
1770
1837
  "Resource": "arn:aws:states:ap-northeast-1:101010101010:stateMachine:dev--command-handler",
1771
1838
  },
1839
+ {
1840
+ "Action": "states:SendTaskSuccess",
1841
+ "Effect": "Allow",
1842
+ "Resource": {
1843
+ "Ref": "commandhandlerstatemachine937D91FB",
1844
+ },
1845
+ },
1772
1846
  ],
1773
1847
  "Version": "2012-10-17",
1774
1848
  },
@@ -1926,7 +2000,7 @@ exports[`snapshot test for InfraStack 1`] = `
1926
2000
  "AllowOrigins": [
1927
2001
  "*",
1928
2002
  ],
1929
- "MaxAge": 31536000,
2003
+ "MaxAge": 3600,
1930
2004
  },
1931
2005
  "Description": "HTTP API for Lambda integration",
1932
2006
  "Name": "dev--api",
@@ -3030,7 +3104,7 @@ schema {
3030
3104
  "Arn",
3031
3105
  ],
3032
3106
  },
3033
- "","Payload":{"input.$":"$","context.$":"$$"}}}}},"MaxConcurrency":2}},"TimeoutSeconds":525600,"Comment":"A state machine for task handler"}",
3107
+ "","Payload":{"input.$":"$","context.$":"$$"}}}}},"MaxConcurrency":2}},"TimeoutSeconds":900,"Comment":"A state machine for task handler"}",
3034
3108
  ],
3035
3109
  ],
3036
3110
  },
@@ -0,0 +1 @@
1
+ placeholder app asset for hermetic infra tests
@@ -0,0 +1 @@
1
+ placeholder layer asset for hermetic infra tests