-
Notifications
You must be signed in to change notification settings - Fork 6
/
scheduled-ecs-task.test.ts
32 lines (29 loc) · 1.12 KB
/
scheduled-ecs-task.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { Duration } from "aws-cdk-lib";
import { Template } from "aws-cdk-lib/assertions";
import { Vpc } from "aws-cdk-lib/aws-ec2";
import { Schedule } from "aws-cdk-lib/aws-events";
import type { GuStack } from "../constructs/core";
import { simpleGuStackForTesting } from "../utils/test";
import { GuScheduledEcsTask } from "./scheduled-ecs-task";
const makeVpc = (stack: GuStack) =>
Vpc.fromVpcAttributes(stack, "VPC", {
vpcId: "test",
availabilityZones: [""],
publicSubnetIds: [""],
privateSubnetIds: ["abc-123"],
});
describe("The GuScheduledEcsTask pattern", () => {
it("should use the specified schedule", () => {
const stack = simpleGuStackForTesting();
const vpc = makeVpc(stack);
new GuScheduledEcsTask(stack, "test", {
schedule: Schedule.rate(Duration.minutes(1)),
containerConfiguration: { id: "node:10", type: "registry" },
monitoringConfiguration: { noMonitoring: true },
vpc,
app: "ecs-test",
subnets: vpc.privateSubnets,
});
Template.fromStack(stack).hasResourceProperties("AWS::Events::Rule", { ScheduleExpression: "rate(1 minute)" });
});
});