Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/cdk-docker-cluster/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @codedazur/cdk-docker-cluster

## 2.1.1

### Patch Changes

- [`b276f1f`](https://github.com/codedazur/toolkit/commit/b276f1f7528b18f536c4f1236bc0e9e60e08b257) Thanks [@thijsdaniels](https://github.com/thijsdaniels)! - Promote `containerInsights` prop to top level.

## 2.1.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/cdk-docker-cluster/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codedazur/cdk-docker-cluster",
"version": "2.1.0",
"version": "2.1.1",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
23 changes: 22 additions & 1 deletion packages/cdk-docker-cluster/src/constructs/DockerCluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,28 @@ describe("DockerCluster", () => {
});
});

it("enables container insights when configured", () => {
it("enables container insights when configured at top level", () => {
const app = new App();
const stack = new Stack(app, "Test");

new DockerCluster(stack, "DockerCluster", {
source: ContainerImage.fromRegistry("nginx:alpine"),
containerInsights: true,
});

const template = Template.fromStack(stack);

template.hasResourceProperties("AWS::ECS::Cluster", {
ClusterSettings: [
{
Name: "containerInsights",
Value: "enabled",
},
],
});
});

it("enables container insights when configured under cluster config (backwards compatibility)", () => {
const app = new App();
const stack = new Stack(app, "Test");

Expand Down
13 changes: 12 additions & 1 deletion packages/cdk-docker-cluster/src/constructs/DockerCluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,16 @@ export interface ClusterConfig {

export interface DockerClusterProps {
readonly source: string | SourceProps | ContainerImage;
/**
* Enable CloudWatch Container Insights for the ECS Cluster.
* @default false
*/
readonly containerInsights?: boolean;
readonly service?: ServiceProps;
readonly distribution?: Omit<SiteDistributionProps, "origin">;
/**
* @deprecated Use top-level `containerInsights` instead.
*/
readonly cluster?: ClusterConfig;
}

Expand Down Expand Up @@ -152,9 +160,12 @@ export class DockerCluster extends Construct {
? this.props.service?.tasks
: this.props.service?.tasks?.minimum;

const containerInsights =
this.props.containerInsights ?? this.props.cluster?.containerInsights;

const service = new ApplicationLoadBalancedFargateService(this, "Service", {
cluster: new Cluster(this, "Cluster", {
containerInsights: this.props.cluster?.containerInsights,
containerInsights,
}),
cpu: this.props.service?.cpu,
memoryLimitMiB: this.props.service?.memory,
Expand Down
6 changes: 2 additions & 4 deletions packages/cdk-next-app/src/constructs/NextApp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ import { describe, it } from "vitest";
import { NextApp } from "./NextApp";

describe("NextApp", () => {
it("forwards container insights configuration to the cluster", () => {
it("forwards top-level container insights configuration to the cluster", () => {
const app = new App();
const stack = new Stack(app, "Test");

new NextApp(stack, "NextApp", {
source: ContainerImage.fromRegistry("nginx:alpine"),
cluster: {
containerInsights: true,
},
containerInsights: true,
});

const template = Template.fromStack(stack);
Expand Down