{ "Resources": { "FirstServiceRole097DB3A5": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": "lambda.amazonaws.com" } } ], "Version": "2012-10-17" }, "ManagedPolicyArns": [ { "Fn::Join": [ "", [ "arn:", { "Ref": "AWS::Partition" }, ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" ] ] } ] } }, "FirstServiceRoleDefaultPolicyB5EF41C4": { "Type": "AWS::IAM::Policy", "Properties": { "PolicyDocument": { "Statement": [ { "Action": "events:PutEvents", "Effect": "Allow", "Resource": { "Fn::Join": [ "", [ "arn:", { "Ref": "AWS::Partition" }, ":events:", { "Ref": "AWS::Region" }, ":", { "Ref": "AWS::AccountId" }, ":event-bus/default" ] ] } } ], "Version": "2012-10-17" }, "PolicyName": "FirstServiceRoleDefaultPolicyB5EF41C4", "Roles": [ { "Ref": "FirstServiceRole097DB3A5" } ] } }, "First8D4707F1": { "Type": "AWS::Lambda::Function", "Properties": { "Code": { "ZipFile": "exports.handler = async (event) => {\n console.log('Event: %j', event);\n if (event === 'error') throw new Error('UnkownError');\n return event;\n };" }, "Role": { "Fn::GetAtt": [ "FirstServiceRole097DB3A5", "Arn" ] }, "Handler": "index.handler", "Runtime": "nodejs10.x" }, "DependsOn": [ "FirstServiceRoleDefaultPolicyB5EF41C4", "FirstServiceRole097DB3A5" ] }, "FirstEventInvokeConfigFailureA1E005BC": { "Type": "AWS::Events::Rule", "Properties": { "EventPattern": { "detail-type": [ "Lambda Function Invocation Result - Failure" ], "resources": [ { "Fn::Join": [ "", [ { "Fn::GetAtt": [ "First8D4707F1", "Arn" ] }, ":$LATEST" ] ] } ], "source": [ "lambda" ] }, "State": "ENABLED", "Targets": [ { "Arn": { "Fn::GetAtt": [ "ErrorD9F0B79D", "Arn" ] }, "Id": "Target0", "InputPath": "$.detail.responsePayload" } ] } }, "FirstEventInvokeConfigFailureAllowEventRuleawscdklambdachainErrorC073CD8DCAD68018": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:InvokeFunction", "FunctionName": { "Fn::GetAtt": [ "ErrorD9F0B79D", "Arn" ] }, "Principal": "events.amazonaws.com", "SourceArn": { "Fn::GetAtt": [ "FirstEventInvokeConfigFailureA1E005BC", "Arn" ] } } }, "FirstEventInvokeConfigSuccess865FF6FF": { "Type": "AWS::Events::Rule", "Properties": { "EventPattern": { "detail-type": [ "Lambda Function Invocation Result - Success" ], "resources": [ { "Fn::Join": [ "", [ { "Fn::GetAtt": [ "First8D4707F1", "Arn" ] }, ":$LATEST" ] ] } ], "source": [ "lambda" ] }, "State": "ENABLED", "Targets": [ { "Arn": { "Fn::GetAtt": [ "Second394350F9", "Arn" ] }, "Id": "Target0", "InputPath": "$.detail.responsePayload" } ] } }, "FirstEventInvokeConfigSuccessAllowEventRuleawscdklambdachainSecond178F48F8A8DE2790": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:InvokeFunction", "FunctionName": { "Fn::GetAtt": [ "Second394350F9", "Arn" ] }, "Principal": "events.amazonaws.com", "SourceArn": { "Fn::GetAtt": [ "FirstEventInvokeConfigSuccess865FF6FF", "Arn" ] } } }, "FirstEventInvokeConfig7DE6209E": { "Type": "AWS::Lambda::EventInvokeConfig", "Properties": { "FunctionName": { "Ref": "First8D4707F1" }, "Qualifier": "$LATEST", "DestinationConfig": { "OnFailure": { "Destination": { "Fn::Join": [ "", [ "arn:", { "Ref": "AWS::Partition" }, ":events:", { "Ref": "AWS::Region" }, ":", { "Ref": "AWS::AccountId" }, ":event-bus/default" ] ] } }, "OnSuccess": { "Destination": { "Fn::Join": [ "", [ "arn:", { "Ref": "AWS::Partition" }, ":events:", { "Ref": "AWS::Region" }, ":", { "Ref": "AWS::AccountId" }, ":event-bus/default" ] ] } } }, "MaximumRetryAttempts": 0 } }, "SecondServiceRole55940A31": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": "lambda.amazonaws.com" } } ], "Version": "2012-10-17" }, "ManagedPolicyArns": [ { "Fn::Join": [ "", [ "arn:", { "Ref": "AWS::Partition" }, ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" ] ] } ] } }, "SecondServiceRoleDefaultPolicyB593E14A": { "Type": "AWS::IAM::Policy", "Properties": { "PolicyDocument": { "Statement": [ { "Action": "events:PutEvents", "Effect": "Allow", "Resource": { "Fn::Join": [ "", [ "arn:", { "Ref": "AWS::Partition" }, ":events:", { "Ref": "AWS::Region" }, ":", { "Ref": "AWS::AccountId" }, ":event-bus/default" ] ] } } ], "Version": "2012-10-17" }, "PolicyName": "SecondServiceRoleDefaultPolicyB593E14A", "Roles": [ { "Ref": "SecondServiceRole55940A31" } ] } }, "Second394350F9": { "Type": "AWS::Lambda::Function", "Properties": { "Code": { "ZipFile": "exports.handler = async (event) => {\n console.log('Event: %j', event);\n if (event === 'error') throw new Error('UnkownError');\n return event;\n };" }, "Role": { "Fn::GetAtt": [ "SecondServiceRole55940A31", "Arn" ] }, "Handler": "index.handler", "Runtime": "nodejs10.x" }, "DependsOn": [ "SecondServiceRoleDefaultPolicyB593E14A", "SecondServiceRole55940A31" ] }, "SecondEventInvokeConfigSuccess53614893": { "Type": "AWS::Events::Rule", "Properties": { "EventPattern": { "detail-type": [ "Lambda Function Invocation Result - Success" ], "resources": [ { "Fn::Join": [ "", [ { "Fn::GetAtt": [ "Second394350F9", "Arn" ] }, ":$LATEST" ] ] } ], "source": [ "lambda" ] }, "State": "ENABLED", "Targets": [ { "Arn": { "Fn::GetAtt": [ "Third1125870F", "Arn" ] }, "Id": "Target0", "InputPath": "$.detail.responsePayload" } ] } }, "SecondEventInvokeConfigSuccessAllowEventRuleawscdklambdachainThird031C7FF6ABA1C15A": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:InvokeFunction", "FunctionName": { "Fn::GetAtt": [ "Third1125870F", "Arn" ] }, "Principal": "events.amazonaws.com", "SourceArn": { "Fn::GetAtt": [ "SecondEventInvokeConfigSuccess53614893", "Arn" ] } } }, "SecondEventInvokeConfig3F9DE36C": { "Type": "AWS::Lambda::EventInvokeConfig", "Properties": { "FunctionName": { "Ref": "Second394350F9" }, "Qualifier": "$LATEST", "DestinationConfig": { "OnSuccess": { "Destination": { "Fn::Join": [ "", [ "arn:", { "Ref": "AWS::Partition" }, ":events:", { "Ref": "AWS::Region" }, ":", { "Ref": "AWS::AccountId" }, ":event-bus/default" ] ] } } } } }, "ThirdServiceRole42701801": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": "lambda.amazonaws.com" } } ], "Version": "2012-10-17" }, "ManagedPolicyArns": [ { "Fn::Join": [ "", [ "arn:", { "Ref": "AWS::Partition" }, ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" ] ] } ] } }, "Third1125870F": { "Type": "AWS::Lambda::Function", "Properties": { "Code": { "ZipFile": "exports.handler = async (event) => {\n console.log('Event: %j', event);\n if (event === 'error') throw new Error('UnkownError');\n return event;\n };" }, "Role": { "Fn::GetAtt": [ "ThirdServiceRole42701801", "Arn" ] }, "Handler": "index.handler", "Runtime": "nodejs10.x" }, "DependsOn": [ "ThirdServiceRole42701801" ] }, "ErrorServiceRoleCE484966": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": "lambda.amazonaws.com" } } ], "Version": "2012-10-17" }, "ManagedPolicyArns": [ { "Fn::Join": [ "", [ "arn:", { "Ref": "AWS::Partition" }, ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" ] ] } ] } }, "ErrorD9F0B79D": { "Type": "AWS::Lambda::Function", "Properties": { "Code": { "ZipFile": "exports.handler = async (event) => {\n console.log('Event: %j', event);\n if (event === 'error') throw new Error('UnkownError');\n return event;\n };" }, "Role": { "Fn::GetAtt": [ "ErrorServiceRoleCE484966", "Arn" ] }, "Handler": "index.handler", "Runtime": "nodejs10.x" }, "DependsOn": [ "ErrorServiceRoleCE484966" ] } }, "Outputs": { "FirstFunctionName": { "Value": { "Ref": "First8D4707F1" } }, "ThirdFunctionName": { "Value": { "Ref": "Third1125870F" } }, "ErrorFunctionName": { "Value": { "Ref": "ErrorD9F0B79D" } } } }