File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,21 @@ class SQSWorker {
27
27
const roleArn = process . env . AWS_ROLE_ARN ;
28
28
const sessionName = process . env . AWS_ROLE_SESSION_NAME ;
29
29
const externalId = process . env . AWS_EXTERNAL_ID ;
30
- const durationSeconds = parseInt ( process . env . AWS_ROLE_DURATION || '3600' ) ;
30
+
31
+ // Parse and validate AWS_ROLE_DURATION with proper error handling
32
+ let durationSeconds = 3600 ; // Default: 1 hour
33
+ if ( process . env . AWS_ROLE_DURATION ) {
34
+ const parsedDuration = parseInt ( process . env . AWS_ROLE_DURATION , 10 ) ;
35
+ if ( isNaN ( parsedDuration ) ) {
36
+ console . warn ( `⚠️ Invalid AWS_ROLE_DURATION value: "${ process . env . AWS_ROLE_DURATION } ". Using default: ${ durationSeconds } seconds` ) ;
37
+ } else if ( parsedDuration < 900 ) {
38
+ console . warn ( `⚠️ AWS_ROLE_DURATION too low: ${ parsedDuration } s (minimum: 900s). Using default: ${ durationSeconds } seconds` ) ;
39
+ } else if ( parsedDuration > 43200 ) {
40
+ console . warn ( `⚠️ AWS_ROLE_DURATION too high: ${ parsedDuration } s (maximum: 43200s). Using default: ${ durationSeconds } seconds` ) ;
41
+ } else {
42
+ durationSeconds = parsedDuration ;
43
+ }
44
+ }
31
45
32
46
if ( roleArn && sessionName ) {
33
47
// Use AssumeRole credentials
You can’t perform that action at this time.
0 commit comments