Skip to content

Commit ed3aaf7

Browse files
authored
fix(triggers): executed on update even when executeOnHandlerChange is false (#26676)
Currently, trigger is re-executed every time when the handler function code or configuration changes even if executeOnHandlerChange is set to false. This is because executeOnHandlerChange prop is never used in the current implementation. This PR solves the issue by referring executeOnHandlerChange prop and skipping function invocation when executeOnHandlerChange is set to false. Closes #25939 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 19e1eb6 commit ed3aaf7

File tree

16 files changed

+1635
-943
lines changed

16 files changed

+1635
-943
lines changed

packages/@aws-cdk-testing/framework-integ/test/triggers/test/integ.triggers.js.snapshot/MyStack.assets.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"version": "32.0.0",
2+
"version": "33.0.0",
33
"files": {
4-
"bcb8f5f1cebce365c4a0bf886b9820908bb469b121d65ef42809ae9798fb9232": {
4+
"237e4a416773a5765262a8b9c70210bd35dfd48ae5a364b19e35f260026b5139": {
55
"source": {
6-
"path": "asset.bcb8f5f1cebce365c4a0bf886b9820908bb469b121d65ef42809ae9798fb9232",
6+
"path": "asset.237e4a416773a5765262a8b9c70210bd35dfd48ae5a364b19e35f260026b5139",
77
"packaging": "zip"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "bcb8f5f1cebce365c4a0bf886b9820908bb469b121d65ef42809ae9798fb9232.zip",
12+
"objectKey": "237e4a416773a5765262a8b9c70210bd35dfd48ae5a364b19e35f260026b5139.zip",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}
@@ -27,15 +27,15 @@
2727
}
2828
}
2929
},
30-
"2aba455d6086d5fb7be6c191dd151bacd3ced3db7a93799474386bb144c6d89a": {
30+
"d70b0346c408b6c05836b626356b50a8a99a92a3fe6ea2e281a97ecf03dd1201": {
3131
"source": {
3232
"path": "MyStack.template.json",
3333
"packaging": "file"
3434
},
3535
"destinations": {
3636
"current_account-current_region": {
3737
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
38-
"objectKey": "2aba455d6086d5fb7be6c191dd151bacd3ced3db7a93799474386bb144c6d89a.json",
38+
"objectKey": "d70b0346c408b6c05836b626356b50a8a99a92a3fe6ea2e281a97ecf03dd1201.json",
3939
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
4040
}
4141
}

packages/@aws-cdk-testing/framework-integ/test/triggers/test/integ.triggers.js.snapshot/MyStack.template.json

+20-15
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@
4646
"Code": {
4747
"ZipFile": "exports.handler = function() { console.log(\"hi\"); };"
4848
},
49+
"Handler": "index.handler",
4950
"Role": {
5051
"Fn::GetAtt": [
5152
"MyTriggerFunctionServiceRole1BB78C29",
5253
"Arn"
5354
]
5455
},
55-
"Handler": "index.handler",
5656
"Runtime": "nodejs16.x"
5757
},
5858
"DependsOn": [
@@ -72,7 +72,8 @@
7272
"Ref": "MyTriggerFunctionCurrentVersion61957CE160cd5b4c06c4d00191dc10a647ea0777"
7373
},
7474
"InvocationType": "RequestResponse",
75-
"Timeout": "120000"
75+
"Timeout": "120000",
76+
"ExecuteOnHandlerChange": true
7677
},
7778
"DependsOn": [
7879
"Topic269377B75"
@@ -237,7 +238,7 @@
237238
"S3Bucket": {
238239
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
239240
},
240-
"S3Key": "bcb8f5f1cebce365c4a0bf886b9820908bb469b121d65ef42809ae9798fb9232.zip"
241+
"S3Key": "237e4a416773a5765262a8b9c70210bd35dfd48ae5a364b19e35f260026b5139.zip"
241242
},
242243
"Timeout": 900,
243244
"MemorySize": 128,
@@ -299,13 +300,13 @@
299300
"Code": {
300301
"ZipFile": "exports.handler = async function() { await setTimeout(() => {console.log(\"hi\")}, 3*60*1000); };"
301302
},
303+
"Handler": "index.handler",
302304
"Role": {
303305
"Fn::GetAtt": [
304306
"MyLambdaFunctionServiceRole313A4D46",
305307
"Arn"
306308
]
307309
},
308-
"Handler": "index.handler",
309310
"Runtime": "nodejs16.x",
310311
"Timeout": 900
311312
},
@@ -334,7 +335,8 @@
334335
"Ref": "MyLambdaFunctionCurrentVersion4FAB80EC75f2df347bcc21ea05f818cb68778d9f"
335336
},
336337
"InvocationType": "Event",
337-
"Timeout": "60000"
338+
"Timeout": "60000",
339+
"ExecuteOnHandlerChange": true
338340
},
339341
"DependsOn": [
340342
"Topic198E71B3E",
@@ -413,12 +415,6 @@
413415
},
414416
"S3Key": "004b12857696fed3c10ad54c8e3cabd07cdf653ec469cbadab6c64ae6c9ce690.zip"
415417
},
416-
"Role": {
417-
"Fn::GetAtt": [
418-
"MyAssertionLambdaFunctionServiceRole36146F3B",
419-
"Arn"
420-
]
421-
},
422418
"Environment": {
423419
"Variables": {
424420
"QUEUE_URL": {
@@ -427,6 +423,12 @@
427423
}
428424
},
429425
"Handler": "index.handler",
426+
"Role": {
427+
"Fn::GetAtt": [
428+
"MyAssertionLambdaFunctionServiceRole36146F3B",
429+
"Arn"
430+
]
431+
},
430432
"Runtime": "nodejs16.x",
431433
"Timeout": 900
432434
},
@@ -456,7 +458,8 @@
456458
"Ref": "MyAssertionLambdaFunctionCurrentVersionF4FA4C80f14c7075b9f4d7c63066e881d45e211c"
457459
},
458460
"InvocationType": "RequestResponse",
459-
"Timeout": "60000"
461+
"Timeout": "60000",
462+
"ExecuteOnHandlerChange": true
460463
},
461464
"DependsOn": [
462465
"TestQueue6F0069AA"
@@ -501,13 +504,13 @@
501504
"Code": {
502505
"ZipFile": "exports.handler = function() { console.log(\"hello\"); };"
503506
},
507+
"Handler": "index.handler",
504508
"Role": {
505509
"Fn::GetAtt": [
506510
"MySecondFunctionServiceRole5B930841",
507511
"Arn"
508512
]
509513
},
510-
"Handler": "index.handler",
511514
"Runtime": "nodejs16.x"
512515
},
513516
"DependsOn": [
@@ -527,7 +530,8 @@
527530
"Ref": "MySecondFunctionCurrentVersion7D497B5D173a4bb1f758991022ea97d651403362"
528531
},
529532
"InvocationType": "RequestResponse",
530-
"Timeout": "120000"
533+
"Timeout": "120000",
534+
"ExecuteOnHandlerChange": true
531535
},
532536
"UpdateReplacePolicy": "Delete",
533537
"DeletionPolicy": "Delete"
@@ -553,7 +557,8 @@
553557
"Ref": "MyLambdaFunctionCurrentVersion4FAB80EC75f2df347bcc21ea05f818cb68778d9f"
554558
},
555559
"InvocationType": "RequestResponse",
556-
"Timeout": "120000"
560+
"Timeout": "120000",
561+
"ExecuteOnHandlerChange": true
557562
},
558563
"UpdateReplacePolicy": "Delete",
559564
"DeletionPolicy": "Delete"

packages/@aws-cdk-testing/framework-integ/test/triggers/test/integ.triggers.js.snapshot/TriggerTestDefaultTestDeployAssert61636546.assets.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
{
2-
"version": "32.0.0",
2+
"version": "33.0.0",
33
"files": {
4-
"86e6ecbc86f6febc745cde7ce633979efa869d6d493b12f2c9d8641d70caa7c2": {
4+
"e4815916885b43e053d8fcef603638aa3a4754c27a3cb0d21fd1c50c2923415b": {
55
"source": {
6-
"path": "asset.86e6ecbc86f6febc745cde7ce633979efa869d6d493b12f2c9d8641d70caa7c2.bundle",
6+
"path": "asset.e4815916885b43e053d8fcef603638aa3a4754c27a3cb0d21fd1c50c2923415b.bundle",
77
"packaging": "zip"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "86e6ecbc86f6febc745cde7ce633979efa869d6d493b12f2c9d8641d70caa7c2.zip",
12+
"objectKey": "e4815916885b43e053d8fcef603638aa3a4754c27a3cb0d21fd1c50c2923415b.zip",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}
1616
},
17-
"506333024aade6ef1f4c1b78000bbc1e1307f8003bad9422adb127768f97739b": {
17+
"033efbe16b566cb69151acaa2d38b2c1f73bf411f644ae441daf0c6aec5a6697": {
1818
"source": {
1919
"path": "TriggerTestDefaultTestDeployAssert61636546.template.json",
2020
"packaging": "file"
2121
},
2222
"destinations": {
2323
"current_account-current_region": {
2424
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25-
"objectKey": "506333024aade6ef1f4c1b78000bbc1e1307f8003bad9422adb127768f97739b.json",
25+
"objectKey": "033efbe16b566cb69151acaa2d38b2c1f73bf411f644ae441daf0c6aec5a6697.json",
2626
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
2727
}
2828
}

packages/@aws-cdk-testing/framework-integ/test/triggers/test/integ.triggers.js.snapshot/TriggerTestDefaultTestDeployAssert61636546.template.json

+15-6
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,24 @@
1818
},
1919
"parameters": {
2020
"QueueUrl": {
21-
"Fn::ImportValue": "MyStack:ExportsOutputRefTestQueue6F0069AA4C7E94E2"
21+
"Fn::Join": [
22+
"",
23+
[
24+
"\"",
25+
{
26+
"Fn::ImportValue": "MyStack:ExportsOutputRefTestQueue6F0069AA4C7E94E2"
27+
},
28+
"\""
29+
]
30+
]
2231
},
23-
"WaitTimeSeconds": 20
32+
"WaitTimeSeconds": "20"
2433
},
2534
"flattenResponse": "true",
2635
"outputPaths": [
2736
"Messages.0.Body"
2837
],
29-
"salt": "1688619578418"
38+
"salt": "1691559124118"
3039
},
3140
"UpdateReplacePolicy": "Delete",
3241
"DeletionPolicy": "Delete"
@@ -206,7 +215,7 @@
206215
"S3Bucket": {
207216
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
208217
},
209-
"S3Key": "86e6ecbc86f6febc745cde7ce633979efa869d6d493b12f2c9d8641d70caa7c2.zip"
218+
"S3Key": "e4815916885b43e053d8fcef603638aa3a4754c27a3cb0d21fd1c50c2923415b.zip"
210219
},
211220
"Timeout": 120,
212221
"Handler": "index.handler",
@@ -267,7 +276,7 @@
267276
"S3Bucket": {
268277
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
269278
},
270-
"S3Key": "86e6ecbc86f6febc745cde7ce633979efa869d6d493b12f2c9d8641d70caa7c2.zip"
279+
"S3Key": "e4815916885b43e053d8fcef603638aa3a4754c27a3cb0d21fd1c50c2923415b.zip"
271280
},
272281
"Timeout": 120,
273282
"Handler": "index.isComplete",
@@ -309,7 +318,7 @@
309318
"S3Bucket": {
310319
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
311320
},
312-
"S3Key": "86e6ecbc86f6febc745cde7ce633979efa869d6d493b12f2c9d8641d70caa7c2.zip"
321+
"S3Key": "e4815916885b43e053d8fcef603638aa3a4754c27a3cb0d21fd1c50c2923415b.zip"
313322
},
314323
"Timeout": 120,
315324
"Handler": "index.onTimeout",

packages/@aws-cdk-testing/framework-integ/test/triggers/test/integ.triggers.js.snapshot/asset.237e4a416773a5765262a8b9c70210bd35dfd48ae5a364b19e35f260026b5139/index.js

+90
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)