From c87c0105928a065e6a289ec3f95a36f6087384f1 Mon Sep 17 00:00:00 2001 From: yicr Date: Mon, 3 Jun 2024 12:32:21 +0900 Subject: [PATCH] fix: insert line feed in concatenated trace --- src/index.ts | 4 ++-- test/__snapshots__/hello.test.ts.snap | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index f03179a..044be95 100644 --- a/src/index.ts +++ b/src/index.ts @@ -42,7 +42,7 @@ export class LambdaFunctionInvokeErrorNotificationStack extends cdk.Stack { sfn.JsonPath.stringAt('$.account'), sfn.JsonPath.stringAt('$.region'), ), - Message: sfn.JsonPath.format('Account : {}\nRegion : {}\nFunction : {}\nErrorMessage : {}\nTrace : {}', + Message: sfn.JsonPath.format('Account : {}\nRegion : {}\nFunction : {}\nErrorMessage : {}\nTrace : \n{}', sfn.JsonPath.stringAt('$.account'), sfn.JsonPath.stringAt('$.region'), sfn.JsonPath.stringAt('$.detail.requestContext.functionArn'), @@ -82,7 +82,7 @@ export class LambdaFunctionInvokeErrorNotificationStack extends cdk.Stack { const concatenateValue: sfn.Pass = new sfn.Pass(this, 'Concatenate', { parameters: { - Trace: sfn.JsonPath.format('{}{}', sfn.JsonPath.stringAt('$.Prepare.Concatenated.Trace'), sfn.JsonPath.stringAt('$.Temp.GetTrace.Line')), + Trace: sfn.JsonPath.format('{}{}\n', sfn.JsonPath.stringAt('$.Prepare.Concatenated.Trace'), sfn.JsonPath.stringAt('$.Temp.GetTrace.Line')), }, resultPath: '$.Prepare.Concatenated', }); diff --git a/test/__snapshots__/hello.test.ts.snap b/test/__snapshots__/hello.test.ts.snap index a036ea2..176b761 100644 --- a/test/__snapshots__/hello.test.ts.snap +++ b/test/__snapshots__/hello.test.ts.snap @@ -240,7 +240,7 @@ exports[`hello 1`] = ` "Fn::Join": [ "", [ - "{"StartAt":"Init","States":{"Init":{"Type":"Pass","Result":"","ResultPath":"$.Prepare.Concatenated.Trace","Next":"TraceLinces"},"TraceLinces":{"Type":"Pass","ResultPath":"$.TempTrace","Parameters":{"Lines.$":"$.detail.responsePayload.trace"},"Next":"CheckUntreatedTranceLinesExist"},"CheckUntreatedTranceLinesExist":{"Type":"Choice","Choices":[{"Variable":"$.TempTrace.Lines[0]","IsPresent":true,"Next":"GetTraceLine"}],"Default":"PrepareMessage"},"UntreatedTranceLines":{"Type":"Pass","ResultPath":"$.TempTrace","Parameters":{"Lines.$":"$.TempTrace.Lines[1:]"},"Next":"CheckUntreatedTranceLinesExist"},"Concatenate":{"Type":"Pass","ResultPath":"$.Prepare.Concatenated","Parameters":{"Trace.$":"States.Format('{}{}', $.Prepare.Concatenated.Trace, $.Temp.GetTrace.Line)"},"Next":"UntreatedTranceLines"},"GetTraceLine":{"Type":"Pass","ResultPath":"$.Temp.GetTrace","Parameters":{"Line.$":"States.ArrayGetItem($.TempTrace.Lines, 0)"},"Next":"Concatenate"},"PrepareMessage":{"Type":"Pass","ResultPath":"$.Prepare.Sns.Topic","Parameters":{"Subject.$":"States.Format('😵 [Failur] AWS Lambda Function Invocation Failur Notification [{}][{}]', $.account, $.region)","Message.$":"States.Format('Account : {}\\nRegion : {}\\nFunction : {}\\nErrorMessage : {}\\nTrace : {}', $.account, $.region, $.detail.requestContext.functionArn, $.detail.responsePayload.errorMessage, $.Prepare.Concatenated.Trace)"},"Next":"SendNotification"},"SendNotification":{"End":true,"Type":"Task","InputPath":"$.Prepare.Sns.Topic","ResultPath":"$.Result.Sns.Topic","Resource":"arn:", + "{"StartAt":"Init","States":{"Init":{"Type":"Pass","Result":"","ResultPath":"$.Prepare.Concatenated.Trace","Next":"TraceLinces"},"TraceLinces":{"Type":"Pass","ResultPath":"$.TempTrace","Parameters":{"Lines.$":"$.detail.responsePayload.trace"},"Next":"CheckUntreatedTranceLinesExist"},"CheckUntreatedTranceLinesExist":{"Type":"Choice","Choices":[{"Variable":"$.TempTrace.Lines[0]","IsPresent":true,"Next":"GetTraceLine"}],"Default":"PrepareMessage"},"UntreatedTranceLines":{"Type":"Pass","ResultPath":"$.TempTrace","Parameters":{"Lines.$":"$.TempTrace.Lines[1:]"},"Next":"CheckUntreatedTranceLinesExist"},"Concatenate":{"Type":"Pass","ResultPath":"$.Prepare.Concatenated","Parameters":{"Trace.$":"States.Format('{}{}\\n', $.Prepare.Concatenated.Trace, $.Temp.GetTrace.Line)"},"Next":"UntreatedTranceLines"},"GetTraceLine":{"Type":"Pass","ResultPath":"$.Temp.GetTrace","Parameters":{"Line.$":"States.ArrayGetItem($.TempTrace.Lines, 0)"},"Next":"Concatenate"},"PrepareMessage":{"Type":"Pass","ResultPath":"$.Prepare.Sns.Topic","Parameters":{"Subject.$":"States.Format('😵 [Failur] AWS Lambda Function Invocation Failur Notification [{}][{}]', $.account, $.region)","Message.$":"States.Format('Account : {}\\nRegion : {}\\nFunction : {}\\nErrorMessage : {}\\nTrace : \\n{}', $.account, $.region, $.detail.requestContext.functionArn, $.detail.responsePayload.errorMessage, $.Prepare.Concatenated.Trace)"},"Next":"SendNotification"},"SendNotification":{"End":true,"Type":"Task","InputPath":"$.Prepare.Sns.Topic","ResultPath":"$.Result.Sns.Topic","Resource":"arn:", { "Ref": "AWS::Partition", },