Skip to content

Commit 0758ff2

Browse files
authored
runners: make ssm policy an array (#6858)
Fixes an issue where the SSM parameter policies were not being set correctly. Resulted in errors like: ValidationException: Invalid policies input: {"Type":"Expiration","Version":"1.0","Attributes":{"Timestamp":"2025-06-27T19:11:55.437Z"}}. Signed-off-by: Eli Uriegas <[email protected]>
1 parent 8f9d301 commit 0758ff2

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

terraform-aws-github-runner/modules/runners/lambdas/runners/src/scale-runners/runners.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,16 +1346,16 @@ describe('createRunner', () => {
13461346
// Verify the Policies parameter contains the correct expiration policy structure
13471347
const putParameterCall = mockSSM.putParameter.mock.calls[0][0];
13481348
const policies = JSON.parse(putParameterCall.Policies);
1349-
expect(policies).toEqual({
1349+
expect(policies).toEqual([{
13501350
Type: 'Expiration',
13511351
Version: '1.0',
13521352
Attributes: {
13531353
Timestamp: expect.any(String),
13541354
},
1355-
});
1355+
}]);
13561356

13571357
// Verify the timestamp is approximately 30 minutes in the future
1358-
const expirationTime = new Date(policies.Attributes.Timestamp);
1358+
const expirationTime = new Date(policies[0].Attributes.Timestamp);
13591359
const now = Date.now();
13601360
const timeDiff = expirationTime.getTime() - now;
13611361
expect(timeDiff).toBeGreaterThan(25 * 60 * 1000); // at least 25 minutes (allowing for test execution time)

terraform-aws-github-runner/modules/runners/lambdas/runners/src/scale-runners/runners.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,13 +536,14 @@ async function addSSMParameterRunnerConfig(
536536
Type: 'SecureString',
537537
// NOTE: This does need to be a string, check docs at:
538538
// https://docs.aws.amazon.com/systems-manager/latest/userguide/example_ssm_PutParameter_section.html
539-
Policies: JSON.stringify({
539+
// Policies must be an array, even for a single policy
540+
Policies: JSON.stringify([{
540541
Type: 'Expiration',
541542
Version: '1.0',
542543
Attributes: {
543544
Timestamp: new Date(Date.now() + 30 * 60 * 1000).toISOString(),
544545
},
545-
}),
546+
}]),
546547
})
547548
.promise();
548549
return parameterName;

0 commit comments

Comments
 (0)