File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
terraform-aws-github-runner/modules/runners/lambdas/runners/src/scale-runners Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -1340,7 +1340,26 @@ describe('createRunner', () => {
1340
1340
Name : 'wg113-i-1234' ,
1341
1341
Value : 'us-east-1-BLAH' ,
1342
1342
Type : 'SecureString' ,
1343
+ Policies : expect . any ( String ) ,
1343
1344
} ) ;
1345
+
1346
+ // Verify the Policies parameter contains the correct expiration policy structure
1347
+ const putParameterCall = mockSSM . putParameter . mock . calls [ 0 ] [ 0 ] ;
1348
+ const policies = JSON . parse ( putParameterCall . Policies ) ;
1349
+ expect ( policies ) . toEqual ( {
1350
+ Type : 'Expiration' ,
1351
+ Version : '1.0' ,
1352
+ Attributes : {
1353
+ Timestamp : expect . any ( String ) ,
1354
+ } ,
1355
+ } ) ;
1356
+
1357
+ // Verify the timestamp is approximately 30 minutes in the future
1358
+ const expirationTime = new Date ( policies . Attributes . Timestamp ) ;
1359
+ const now = Date . now ( ) ;
1360
+ const timeDiff = expirationTime . getTime ( ) - now ;
1361
+ expect ( timeDiff ) . toBeGreaterThan ( 25 * 60 * 1000 ) ; // at least 25 minutes (allowing for test execution time)
1362
+ expect ( timeDiff ) . toBeLessThan ( 35 * 60 * 1000 ) ; // at most 35 minutes (allowing for clock differences)
1344
1363
} ) ;
1345
1364
1346
1365
it ( 'creates ssm experiment parameters when joining experiment' , async ( ) => {
@@ -1384,6 +1403,7 @@ describe('createRunner', () => {
1384
1403
Name : 'wg113-i-1234' ,
1385
1404
Value : 'us-east-1-BLAH #ON_AMI_EXPERIMENT' ,
1386
1405
Type : 'SecureString' ,
1406
+ Policies : expect . any ( String ) ,
1387
1407
} ) ;
1388
1408
expect ( mockEC2 . runInstances ) . toBeCalledTimes ( 1 ) ;
1389
1409
expect ( mockEC2 . runInstances ) . toBeCalledWith (
Original file line number Diff line number Diff line change @@ -534,6 +534,15 @@ async function addSSMParameterRunnerConfig(
534
534
Name : parameterName ,
535
535
Value : runnerConfig ,
536
536
Type : 'SecureString' ,
537
+ // NOTE: This does need to be a string, check docs at:
538
+ // https://docs.aws.amazon.com/systems-manager/latest/userguide/example_ssm_PutParameter_section.html
539
+ Policies : JSON . stringify ( {
540
+ Type : 'Expiration' ,
541
+ Version : '1.0' ,
542
+ Attributes : {
543
+ Timestamp : new Date ( Date . now ( ) + 30 * 60 * 1000 ) . toISOString ( ) ,
544
+ } ,
545
+ } ) ,
537
546
} )
538
547
. promise ( ) ;
539
548
return parameterName ;
You can’t perform that action at this time.
0 commit comments