From a7d28476689739d96a6a84f4b10551c9557d2eb1 Mon Sep 17 00:00:00 2001 From: howlla Date: Thu, 21 Mar 2024 16:07:17 -0700 Subject: [PATCH] fix comments from reviewer --- .../index.ts | 6 +-- ...don.ts => kubecostserviceaccountsaddon.ts} | 40 +++---------------- package.json | 12 +++--- 3 files changed, 14 insertions(+), 44 deletions(-) rename lib/single-new-eks-cost-monitoring-pattern/{grafanaoperatorsecretaddon.ts => kubecostserviceaccountsaddon.ts} (61%) diff --git a/lib/single-new-eks-cost-monitoring-pattern/index.ts b/lib/single-new-eks-cost-monitoring-pattern/index.ts index cb8ae5f0..64823f97 100644 --- a/lib/single-new-eks-cost-monitoring-pattern/index.ts +++ b/lib/single-new-eks-cost-monitoring-pattern/index.ts @@ -2,7 +2,7 @@ import { Construct } from 'constructs'; import * as cdk from "aws-cdk-lib"; import * as blueprints from '@aws-quickstart/eks-blueprints'; import { GlobalResources, LookupHostedZoneProvider, ObservabilityBuilder } from '@aws-quickstart/eks-blueprints'; -import { GrafanaOperatorSecretAddon } from './grafanaoperatorsecretaddon'; +import { KubecostServiceAccountsAddon } from './kubecostserviceaccountsaddon'; import { KubecostAddOn, KubecostAddOnProps } from '@kubecost/kubecost-eks-blueprints-addon'; import * as amp from 'aws-cdk-lib/aws-aps'; import * as eks from 'aws-cdk-lib/aws-eks'; @@ -148,7 +148,7 @@ export default class SingleNewEksCostMonitoringPattern extends cdk.Stack { new KubeCostExtensionAddon({ namespace:"kubecost", version:"1.108.1", - kubecostToken: "Z2dvZDk5OUBnbWFpbC5jb20=xm343yadf98", + kubecostToken: blueprints.utils.valueFromContext(scope, "dev.subzone.name", "get token from kubecost.com/install"), values: { global: { amp: { @@ -215,7 +215,7 @@ export default class SingleNewEksCostMonitoringPattern extends cdk.Stack { }, adminPasswordSecretName: SECRET_ARGO_ADMIN_PWD, }), - new GrafanaOperatorSecretAddon() + new KubecostServiceAccountsAddon() ]; const mngProps: blueprints.MngClusterProviderProps = { diff --git a/lib/single-new-eks-cost-monitoring-pattern/grafanaoperatorsecretaddon.ts b/lib/single-new-eks-cost-monitoring-pattern/kubecostserviceaccountsaddon.ts similarity index 61% rename from lib/single-new-eks-cost-monitoring-pattern/grafanaoperatorsecretaddon.ts rename to lib/single-new-eks-cost-monitoring-pattern/kubecostserviceaccountsaddon.ts index d7be058f..04e7653c 100644 --- a/lib/single-new-eks-cost-monitoring-pattern/grafanaoperatorsecretaddon.ts +++ b/lib/single-new-eks-cost-monitoring-pattern/kubecostserviceaccountsaddon.ts @@ -3,11 +3,11 @@ import * as blueprints from '@aws-quickstart/eks-blueprints'; import * as eks from "aws-cdk-lib/aws-eks"; import { ManagedPolicy } from "aws-cdk-lib/aws-iam"; import { Construct } from 'constructs'; -import { createNamespace, dependable } from '@aws-quickstart/eks-blueprints/dist/utils'; -export class GrafanaOperatorSecretAddon implements blueprints.ClusterAddOn { + +export class KubecostServiceAccountsAddon implements blueprints.ClusterAddOn { id?: string | undefined; - @dependable(blueprints.addons.ExternalsSecretsAddOn.name) + @blueprints.utils.dependable(blueprints.addons.ExternalsSecretsAddOn.name) deploy(clusterInfo: blueprints.ClusterInfo): void | Promise { const cluster = clusterInfo.cluster; @@ -31,7 +31,7 @@ export class GrafanaOperatorSecretAddon implements blueprints.ClusterAddOn { serviceAccount2.role.addManagedPolicy(policyRead); serviceAccount2.role.addManagedPolicy(policyWrite); - const namespace = createNamespace("kubecost",cluster); + const namespace = blueprints.utils.createNamespace("kubecost",cluster); serviceAccount1.node.addDependency(namespace); serviceAccount2.node.addDependency(namespace); @@ -66,37 +66,7 @@ export class GrafanaOperatorSecretAddon implements blueprints.ClusterAddOn { ], }); - // const externalSecret = new eks.KubernetesManifest(clusterInfo.cluster.stack, "ExternalSecret", { - // cluster: cluster, - // manifest: [ - // { - // apiVersion: "external-secrets.io/v1beta1", - // kind: "ExternalSecret", - // metadata: { - // name: "external-grafana-admin-credentials", - // namespace: "grafana-operator" - // }, - // spec: { - // secretStoreRef: { - // name: "ssm-parameter-store", - // kind: "ClusterSecretStore", - // }, - // target: { - // name: "grafana-admin-credentials" - // }, - // data: [ - // { - // secretKey: "GF_SECURITY_ADMIN_APIKEY", - // remoteRef: { - // key: "/cdk-accelerator/grafana-api-key" - // }, - // }, - // ], - // }, - // }, - // ], - // }); - // externalSecret.node.addDependency(secretStore); + return Promise.resolve(secretStore); } } \ No newline at end of file diff --git a/package.json b/package.json index 3c174bc2..9190ef82 100644 --- a/package.json +++ b/package.json @@ -10,12 +10,12 @@ "lint": "npx eslint . --ext .js,.jsx,.ts,.tsx" }, "devDependencies": { - "@aws-quickstart/eks-blueprints": "^1.13.1", + "@aws-quickstart/eks-blueprints": "^1.14.0", "@types/jest": "^29.5.11", "@types/node": "^20.10.4", "@typescript-eslint/eslint-plugin": "^6.14.0", "@typescript-eslint/parser": "^6.14.0", - "aws-cdk": "2.114.1", + "aws-cdk": "2.132.0", "copyfiles": "^2.4.1", "eslint": "^8.55.0", "jest": "^29.7.0", @@ -24,17 +24,17 @@ "typescript": "^5.3.3" }, "dependencies": { - "@aws-quickstart/eks-blueprints": "^1.13.1", + "@aws-quickstart/eks-blueprints": "^1.14.0", "@kubecost/kubecost-eks-blueprints-addon": "^0.1.8", - "aws-cdk": "2.114.1", + "aws-cdk": "2.132.0", "aws-sdk": "^2.1455.0", "constructs": "^10.3.0", "eks-blueprints-cdk-kubeflow-ext": "0.1.9", "source-map-support": "^0.5.21" }, "overrides": { - "@aws-quickstart/eks-blueprints": "^1.13.1", - "aws-cdk": "2.114.1", + "@aws-quickstart/eks-blueprints": "^1.14.0", + "aws-cdk": "2.132.0", "xml2js": "0.5.0" } } \ No newline at end of file