Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
DerkSch committed Dec 5, 2022
1 parent 6ff80c8 commit 3e97e06
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 48 deletions.
Expand Up @@ -69,7 +69,7 @@
]
},
"HandlerArn": {
"Ref": "MyTriggerFunctionCurrentVersion61957CE160cd5b4c06c4d00191dc10a647ea0777"
"Ref": "MyTriggerFunctionCurrentVersion61957CE160cd5b4c06c4d00191dc10a647ea0777"
},
"InvocationType": "RequestResponse",
"Timeout": {
Expand All @@ -87,7 +87,7 @@
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"MyTriggerFunctionCurrentVersion61957CE160cd5b4c06c4d00191dc10a647ea0777": {
"MyTriggerFunctionCurrentVersion61957CE160cd5b4c06c4d00191dc10a647ea0777": {
"Type": "AWS::Lambda::Version",
"Properties": {
"FunctionName": {
Expand Down Expand Up @@ -143,6 +143,28 @@
}
]
},
{
"Effect": "Allow",
"Action": [
"lambda:InvokeFunction"
],
"Resource": [
{
"Fn::Join": [
"",
[
{
"Fn::GetAtt": [
"MyLambdaFunction67CCA873",
"Arn"
]
},
":*"
]
]
}
]
},
{
"Effect": "Allow",
"Action": [
Expand Down Expand Up @@ -195,7 +217,7 @@
"AWSCDKTriggerCustomResourceProviderCustomResourceProviderRoleE18FAF0A"
]
},
"MySecondFunctionServiceRole5B930841": {
"MyLambdaFunctionServiceRole313A4D46": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
Expand Down Expand Up @@ -226,26 +248,35 @@
]
}
},
"MySecondFunction0F0B51EB": {
"MyLambdaFunction67CCA873": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"ZipFile": "exports.handler = function() { console.log(\"hello\"); };"
"ZipFile": "exports.handler = function() { await setTimeout(3*60*1000, \"hi\"); };"
},
"Role": {
"Fn::GetAtt": [
"MySecondFunctionServiceRole5B930841",
"MyLambdaFunctionServiceRole313A4D46",
"Arn"
]
},
"Handler": "index.handler",
"Runtime": "nodejs16.x"
"Runtime": "nodejs16.x",
"Timeout": 900
},
"DependsOn": [
"MySecondFunctionServiceRole5B930841"
"MyLambdaFunctionServiceRole313A4D46"
]
},
"MySecondFunctionTrigger8C61EC28": {
"MyLambdaFunctionCurrentVersion4FAB80ECdc4d4e257bb2b44c9c4b9231f0d16f4c": {
"Type": "AWS::Lambda::Version",
"Properties": {
"FunctionName": {
"Ref": "MyLambdaFunction67CCA873"
}
}
},
"MyTrigger": {
"Type": "Custom::Trigger",
"Properties": {
"ServiceToken": {
Expand All @@ -255,21 +286,19 @@
]
},
"HandlerArn": {
"Ref": "MySecondFunctionCurrentVersion7D497B5D173a4bb1f758991022ea97d651403362"
}
"Ref": "MyLambdaFunctionCurrentVersion4FAB80ECdc4d4e257bb2b44c9c4b9231f0d16f4c"
},
"InvocationType": "Event",
"Timeout": 60000
},
"DependsOn": [
"Topic198E71B3E",
"Topic269377B75"
],
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"MySecondFunctionCurrentVersion7D497B5D173a4bb1f758991022ea97d651403362": {
"Type": "AWS::Lambda::Version",
"Properties": {
"FunctionName": {
"Ref": "MySecondFunction0F0B51EB"
}
}
},
"MyLambdaFunctionServiceRole313A4D46": {
"MySecondFunctionServiceRole5B930841": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
Expand Down Expand Up @@ -300,35 +329,26 @@
]
}
},
"MyLambdaFunction67CCA873": {
"MySecondFunction0F0B51EB": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"ZipFile": "exports.handler = function() { await setTimeout(3*60*1000, \"hi\"); };"
"ZipFile": "exports.handler = function() { console.log(\"hello\"); };"
},
"Role": {
"Fn::GetAtt": [
"MyLambdaFunctionServiceRole313A4D46",
"MySecondFunctionServiceRole5B930841",
"Arn"
]
},
"Handler": "index.handler",
"Runtime": "nodejs16.x",
"Timeout": 900
"Runtime": "nodejs16.x"
},
"DependsOn": [
"MyLambdaFunctionServiceRole313A4D46"
"MySecondFunctionServiceRole5B930841"
]
},
"MyLambdaFunctionCurrentVersion4FAB80ECdc4d4e257bb2b44c9c4b9231f0d16f4c": {
"Type": "AWS::Lambda::Version",
"Properties": {
"FunctionName": {
"Ref": "MyLambdaFunction67CCA873"
}
}
},
"MyTrigger": {
"MySecondFunctionTrigger8C61EC28": {
"Type": "Custom::Trigger",
"Properties": {
"ServiceToken": {
Expand All @@ -338,17 +358,28 @@
]
},
"HandlerArn": {
"Ref": "MyLambdaFunctionCurrentVersion4FAB80ECdc4d4e257bb2b44c9c4b9231f0d16f4c"
"Ref": "MySecondFunctionCurrentVersion7D497B5D173a4bb1f758991022ea97d651403362"
},
"InvocationType": "Event",
"Timeout": 60000
"InvocationType": "RequestResponse",
"Timeout": {
"amount": 2,
"unit": {
"label": "minutes",
"isoLabel": "M",
"inMillis": 60000
}
}
},
"DependsOn": [
"Topic198E71B3E",
"Topic269377B75"
],
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"MySecondFunctionCurrentVersion7D497B5D173a4bb1f758991022ea97d651403362": {
"Type": "AWS::Lambda::Version",
"Properties": {
"FunctionName": {
"Ref": "MySecondFunction0F0B51EB"
}
}
}
},
"Parameters": {
Expand Down
12 changes: 6 additions & 6 deletions packages/@aws-cdk/triggers/test/trigger-handler.test.ts
Expand Up @@ -41,14 +41,14 @@ test('Create', async () => {
await lambda.handler({ RequestType: 'Create', ...mockRequest });

expect(invokeMock).toBeCalledTimes(1);
expect(invokeMock).toBeCalledWith({ FunctionName: handlerArn });
expect(invokeMock).toBeCalledWith({ FunctionName: handlerArn, InvocationType: 'Event' });
});

test('Update', async () => {
await lambda.handler({ RequestType: 'Update', PhysicalResourceId: 'PRID', OldResourceProperties: {}, ...mockRequest });

expect(invokeMock).toBeCalledTimes(1);
expect(invokeMock).toBeCalledWith({ FunctionName: handlerArn });
expect(invokeMock).toBeCalledWith({ FunctionName: handlerArn, InvocationType: 'Event' });
});

test('Delete - handler not called', async () => {
Expand All @@ -66,7 +66,7 @@ test('non-200 status code throws an error', async () => {
.toMatchObject({ message: 'Trigger handler failed with status code 500' });

expect(invokeMock).toBeCalledTimes(1);
expect(invokeMock).toBeCalledWith({ FunctionName: handlerArn });
expect(invokeMock).toBeCalledWith({ FunctionName: handlerArn, InvocationType: 'Event' });
});

test('retry with access denied exception', async () => {
Expand All @@ -83,7 +83,7 @@ test('retry with access denied exception', async () => {
await response;

expect(invokeMock).toBeCalledTimes(2);
expect(invokeMock).toBeCalledWith({ FunctionName: handlerArn });
expect(invokeMock).toBeCalledWith({ FunctionName: handlerArn, InvocationType: 'Event' });
});

test('throws an error for other exceptions', async () => {
Expand All @@ -96,7 +96,7 @@ test('throws an error for other exceptions', async () => {
.toThrow();

expect(invokeMock).toBeCalledTimes(1);
expect(invokeMock).toBeCalledWith({ FunctionName: handlerArn });
expect(invokeMock).toBeCalledWith({ FunctionName: handlerArn, InvocationType: 'Event' });
});

describe('function error', () => {
Expand All @@ -113,7 +113,7 @@ describe('function error', () => {
.toMatchObject({ message: expectedError });

expect(invokeMock).toBeCalledTimes(1);
expect(invokeMock).toBeCalledWith({ FunctionName: handlerArn });
expect(invokeMock).toBeCalledWith({ FunctionName: handlerArn, InvocationType: 'Event' });
};
};

Expand Down

0 comments on commit 3e97e06

Please sign in to comment.