Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tools - Weathertop: Update plugin stacks to include EnvVars #6948

Merged
merged 20 commits into from
Oct 9, 2024
6 changes: 6 additions & 0 deletions .tools/test/stacks/config/variables.json
ford-at-aws marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"name": "S3_BUCKET_NAME_PREFIX",
"value": "sdk-example-code"
}
]
13 changes: 8 additions & 5 deletions .tools/test/stacks/plugin/typescript/plugin_stack.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
ford-at-aws marked this conversation as resolved.
Show resolved Hide resolved
// SPDX-License-Identifier: Apache-2.0

import * as cdk from "aws-cdk-lib";
import * as ec2 from "aws-cdk-lib/aws-ec2";
import * as events from "aws-cdk-lib/aws-events";
Expand All @@ -14,8 +13,9 @@ import * as sqs from "aws-cdk-lib/aws-sqs";
import * as batch from "aws-cdk-lib/aws-batch";
import * as subs from "aws-cdk-lib/aws-sns-subscriptions";
import { Construct } from "constructs";
import { readAccountConfig } from "../../config/types";
import { readAccountConfig } from "../../config/targets";
import { readResourceConfig } from "../../config/resources";
import variableConfigJson from "../../config/variables.json";

const toolName = process.env.TOOL_NAME ?? "defaultToolName";

Expand All @@ -31,20 +31,23 @@ class PluginStack extends cdk.Stack {
const acctConfig = readAccountConfig("../../config/targets.yaml");
const resourceConfig = readResourceConfig("../../config/resources.yaml");

const adminTopicName = resourceConfig["topic_name"];
const adminBucketName = resourceConfig["bucket_name"];
this.awsRegion = resourceConfig["aws_region"];
this.adminAccountId = resourceConfig["admin_acct"];
const adminTopicName = resourceConfig["topic_name"];
const adminBucketName = resourceConfig["bucket_name"];

const snsTopic = this.initGetTopic(adminTopicName);
const sqsQueue = new sqs.Queue(this, `BatchJobQueue-${toolName}`);
if (acctConfig[`${toolName}`].status === "enabled") {
this.initSubscribeSns(sqsQueue, snsTopic);
this.batchMemory = acctConfig[`${toolName}`]?.memory ?? "16384";
this.batchVcpus = acctConfig[`${toolName}`]?.vcpus ?? "4";
}

const [jobDefinition, jobQueue] = this.initBatchFargate();
const batchFunction = this.initBatchLambda(jobQueue, jobDefinition);
this.initSqsLambdaIntegration(batchFunction, sqsQueue);

if (acctConfig[`${toolName}`].status === "enabled") {
this.initLogFunction(adminBucketName);
}
Expand Down Expand Up @@ -134,6 +137,7 @@ class PluginStack extends cdk.Stack {
value: this.batchMemory,
},
],
environment: variableConfigJson,
},
platformCapabilities: ["FARGATE"],
});
Expand Down Expand Up @@ -211,7 +215,6 @@ class PluginStack extends cdk.Stack {
resources: [sqsQueue.queueArn],
}),
);

// Additionally, ensure the Lambda function can create and write to CloudWatch Logs.
lambdaFunction.addToRolePolicy(
new iam.PolicyStatement({
Expand Down
4 changes: 3 additions & 1 deletion .tools/test/stacks/plugin/typescript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"inlineSources": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"typeRoots": ["./node_modules/@types"]
"typeRoots": ["./node_modules/@types"],
"resolveJsonModule": true,
"esModuleInterop": true
},
"exclude": ["node_modules", "cdk.out"]
}
Loading