@@ -17,6 +17,7 @@ import { readAccountConfig } from "../../config/targets";
1717import { readResourceConfig } from "../../config/resources" ;
1818import * as fs from 'fs' ;
1919
20+
2021const toolName = process . env . TOOL_NAME ?? "defaultToolName" ;
2122
2223class PluginStack extends cdk . Stack {
@@ -25,9 +26,11 @@ class PluginStack extends cdk.Stack {
2526 private batchMemory : string ;
2627 private batchVcpus : string ;
2728
28- constructor ( scope : Construct , id : string , variables : Record < string , string > , props ?: cdk . StackProps ) {
29+ constructor ( scope : Construct , id : string , props ?: cdk . StackProps ) {
2930 super ( scope , id , props ) ;
3031
32+ const variableConfigJson = JSON . parse ( fs . readFileSync ( '../../config/variables.json' , 'utf-8' ) ) ;
33+
3134 const acctConfig = readAccountConfig ( "../../config/targets.yaml" ) ;
3235 const resourceConfig = readResourceConfig ( "../../config/resources.yaml" ) ;
3336
@@ -44,7 +47,7 @@ class PluginStack extends cdk.Stack {
4447 this . batchVcpus = acctConfig [ `${ toolName } ` ] ?. vcpus ?? "4" ;
4548 }
4649
47- const [ jobDefinition , jobQueue ] = this . initBatchFargate ( ) ;
50+ const [ jobDefinition , jobQueue ] = this . initBatchFargate ( variableConfigJson ) ;
4851 const batchFunction = this . initBatchLambda ( jobQueue , jobDefinition ) ;
4952 this . initSqsLambdaIntegration ( batchFunction , sqsQueue ) ;
5053
@@ -118,13 +121,10 @@ class PluginStack extends cdk.Stack {
118121
119122 const containerImageUri = `${ this . adminAccountId } .dkr.ecr.us-east-1.amazonaws.com/${ toolName } :latest` ;
120123
121- // Convert JSON array to environment variable format for Batch.
122- const environmentVariables = variables . map ( ( obj : Record < string , string > ) =>
123- Object . entries ( obj ) . map ( ( [ key , value ] ) => ( {
124- name : key ,
125- value : value as string ,
126- } ) )
127- ) . flat ( ) ;
124+ const environmentVariables = Object . entries ( variables ) . map ( ( [ key , value ] ) => ( {
125+ name : key ,
126+ value : String ( value ) , // Ensure value is a string
127+ } ) ) ;
128128
129129 const jobDefinition = new batch . CfnJobDefinition ( this , "JobDefn" , {
130130 type : "container" ,
0 commit comments