/
asg-cluster-provider.ts
44 lines (37 loc) · 1.17 KB
/
asg-cluster-provider.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
33
34
35
36
37
38
39
40
41
42
43
44
import * as eks from "aws-cdk-lib/aws-eks";
import { defaultOptions, GenericClusterProvider } from "./generic-cluster-provider";
import { AutoscalingNodeGroup } from "./types";
/**
* Configuration options for the cluster provider.
*/
export interface AsgClusterProviderProps extends Partial<eks.CommonClusterOptions>, AutoscalingNodeGroup {
/**
* The name for the cluster.
*/
name?: string;
/**
* Is it a private only EKS Cluster?
* Defaults to private_and_public cluster, set to true for private cluster
* @default false
*/
privateCluster?: boolean;
/**
* Tags for the cluster
*/
tags?: {
[key: string]: string;
}
}
/**
* AsgClusterProvider provisions an EKS cluster with an autoscaling group for self-managed capacity.
*/
export class AsgClusterProvider extends GenericClusterProvider {
constructor(props?: AsgClusterProviderProps) {
super({...defaultOptions, ...props, ...{
autoscalingNodeGroups: [{
id: props?.id ?? props?.clusterName ?? "eks-blueprints-asg",
...props as Omit<AutoscalingNodeGroup, "id" | "tags">
}]
}});
}
}