Skip to content

Commit d45294e

Browse files
committed
fixes
1 parent 10b80ce commit d45294e

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
{
2-
"S3_BUCKET_NAME_PREFIX": "sdk-example-code"
3-
}
1+
[
2+
{
3+
"S3_BUCKET_NAME_PREFIX": "sdk-example-code"
4+
}
5+
]

.tools/test/stacks/plugin/typescript/plugin_stack.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
13
import * as cdk from "aws-cdk-lib";
24
import * as ec2 from "aws-cdk-lib/aws-ec2";
35
import * as events from "aws-cdk-lib/aws-events";
@@ -15,8 +17,6 @@ import { readAccountConfig } from "../../config/targets";
1517
import { readResourceConfig } from "../../config/resources";
1618
import * as fs from 'fs';
1719

18-
const variableConfigJson = JSON.parse(fs.readFileSync('../../config/variables.json', 'utf-8'));
19-
2020
const toolName = process.env.TOOL_NAME ?? "defaultToolName";
2121

2222
class PluginStack extends cdk.Stack {
@@ -25,7 +25,7 @@ class PluginStack extends cdk.Stack {
2525
private batchMemory: string;
2626
private batchVcpus: string;
2727

28-
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
28+
constructor(scope: Construct, id: string, variables: Record<string, string>, props?: cdk.StackProps) {
2929
super(scope, id, props);
3030

3131
const acctConfig = readAccountConfig("../../config/targets.yaml");
@@ -62,7 +62,7 @@ class PluginStack extends cdk.Stack {
6262
);
6363
}
6464

65-
private initBatchFargate(): [batch.CfnJobDefinition, batch.CfnJobQueue] {
65+
private initBatchFargate(variables: Record<string, string>): [batch.CfnJobDefinition, batch.CfnJobQueue] {
6666
const batchExecutionRole = new iam.Role(
6767
this,
6868
`BatchExecutionRole-${toolName}`,
@@ -118,11 +118,13 @@ class PluginStack extends cdk.Stack {
118118

119119
const containerImageUri = `${this.adminAccountId}.dkr.ecr.us-east-1.amazonaws.com/${toolName}:latest`;
120120

121-
// Convert JSON to environment variable format for Batch.
122-
const environmentVariables = Object.entries(variableConfigJson).map(([key, value]) => ({
123-
name: key,
124-
value: value as string,
125-
}));
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();
126128

127129
const jobDefinition = new batch.CfnJobDefinition(this, "JobDefn", {
128130
type: "container",
@@ -235,6 +237,7 @@ class PluginStack extends cdk.Stack {
235237
}
236238

237239
private initLogFunction(adminBucketName: string): void {
240+
// S3 Bucket to store logs within this account.
238241
const bucket = new s3.Bucket(this, "LogBucket", {
239242
versioned: false,
240243
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,

0 commit comments

Comments
 (0)