11// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22// SPDX-License-Identifier: Apache-2.0
3-
43import * as cdk from "aws-cdk-lib" ;
54import * as ec2 from "aws-cdk-lib/aws-ec2" ;
65import * as events from "aws-cdk-lib/aws-events" ;
@@ -14,8 +13,9 @@ import * as sqs from "aws-cdk-lib/aws-sqs";
1413import * as batch from "aws-cdk-lib/aws-batch" ;
1514import * as subs from "aws-cdk-lib/aws-sns-subscriptions" ;
1615import { Construct } from "constructs" ;
17- import { readAccountConfig } from "../../config/types " ;
16+ import { readAccountConfig } from "../../config/targets " ;
1817import { readResourceConfig } from "../../config/resources" ;
18+ import variableConfigJson from "../../config/variables.json" ;
1919
2020const toolName = process . env . TOOL_NAME ?? "defaultToolName" ;
2121
@@ -31,20 +31,23 @@ class PluginStack extends cdk.Stack {
3131 const acctConfig = readAccountConfig ( "../../config/targets.yaml" ) ;
3232 const resourceConfig = readResourceConfig ( "../../config/resources.yaml" ) ;
3333
34- const adminTopicName = resourceConfig [ "topic_name" ] ;
35- const adminBucketName = resourceConfig [ "bucket_name" ] ;
3634 this . awsRegion = resourceConfig [ "aws_region" ] ;
3735 this . adminAccountId = resourceConfig [ "admin_acct" ] ;
36+ const adminTopicName = resourceConfig [ "topic_name" ] ;
37+ const adminBucketName = resourceConfig [ "bucket_name" ] ;
38+
3839 const snsTopic = this . initGetTopic ( adminTopicName ) ;
3940 const sqsQueue = new sqs . Queue ( this , `BatchJobQueue-${ toolName } ` ) ;
4041 if ( acctConfig [ `${ toolName } ` ] . status === "enabled" ) {
4142 this . initSubscribeSns ( sqsQueue , snsTopic ) ;
4243 this . batchMemory = acctConfig [ `${ toolName } ` ] ?. memory ?? "16384" ;
4344 this . batchVcpus = acctConfig [ `${ toolName } ` ] ?. vcpus ?? "4" ;
4445 }
46+
4547 const [ jobDefinition , jobQueue ] = this . initBatchFargate ( ) ;
4648 const batchFunction = this . initBatchLambda ( jobQueue , jobDefinition ) ;
4749 this . initSqsLambdaIntegration ( batchFunction , sqsQueue ) ;
50+
4851 if ( acctConfig [ `${ toolName } ` ] . status === "enabled" ) {
4952 this . initLogFunction ( adminBucketName ) ;
5053 }
@@ -134,6 +137,7 @@ class PluginStack extends cdk.Stack {
134137 value : this . batchMemory ,
135138 } ,
136139 ] ,
140+ environment : variableConfigJson ,
137141 } ,
138142 platformCapabilities : [ "FARGATE" ] ,
139143 } ) ;
@@ -211,7 +215,6 @@ class PluginStack extends cdk.Stack {
211215 resources : [ sqsQueue . queueArn ] ,
212216 } ) ,
213217 ) ;
214-
215218 // Additionally, ensure the Lambda function can create and write to CloudWatch Logs.
216219 lambdaFunction . addToRolePolicy (
217220 new iam . PolicyStatement ( {
0 commit comments