Skip to content

Commit 007eecd

Browse files
eks works
Signed-off-by: ivan katliarchuk <[email protected]>
1 parent ed99477 commit 007eecd

File tree

3 files changed

+36
-25
lines changed

3 files changed

+36
-25
lines changed

with-tests/eks/readme.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
- [Cluster Versioning](https://docs.aws.amazon.com/id_id/cli/latest/reference/eks/describe-cluster-versions.html)
33
- [Describe Versions](https://docs.aws.amazon.com/eks/latest/APIReference/API_DescribeClusterVersions.html)
4-
4+
- [Example Syntax](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/eks/command/DescribeClusterVersionsCommand/)
55

66
## Commands
77

@@ -17,3 +17,8 @@ pnpm start
1717
```json
1818

1919
```
20+
21+
Error
22+
```sh
23+
AccessDeniedException: User: arn:aws:sts::048958980748:assumed-role/AWSReservedSSO_PaasLimited_1e6f3b4b8eedd01d/[email protected] is not authorized to perform: eks:DescribeClusterVersions on resource: arn:aws:eks:eu-west-1:048958980748:*
24+
```

with-tests/eks/src/app.ts

+26-19
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77

88
import type { GetReleasesConfig, ReleaseResult } from './utils/types';
99

10-
import { fromNodeProviderChain } from '@aws-sdk/credential-providers';
10+
// import { fromNodeProviderChain } from '@aws-sdk/credential-providers';
1111

1212
import { EksFilter } from './schema';
1313
import { logger } from './utils/logger';
@@ -16,30 +16,30 @@ import { ClusterVersionInformation } from '@aws-sdk/client-eks/dist-types/models
1616

1717
export class AwsEKSDataSource {
1818

19-
private readonly clients: Record<string, EKSClient> = {};
19+
// private readonly clients: Record<string, EKSClient> = {};
2020

2121
async getReleases({
2222
packageName: serializedFilter
2323
}: GetReleasesConfig): Promise<ReleaseResult | null> {
2424
const res = EksFilter.safeParse(serializedFilter);
2525
if (!res.success) {
26+
console.log("UPS ERROR")
2627
logger.debug(
2728
{ err: res.error, serializedFilter },
2829
'Error parsing eks-addons config.',
2930
);
3031
return null
3132
}
3233

33-
const filter = res.data;
34-
3534
const input: DescribeClusterVersionsCommandInput = {
36-
defaultOnly: false,
37-
includeAll: true,
38-
maxResults: 1,
35+
defaultOnly: res.data.default ?? undefined,
36+
includeAll: res.data?.default === undefined ? true : undefined,
3937
};
38+
console.log(input)
4039
const cmd = new DescribeClusterVersionsCommand(input)
41-
const response: DescribeClusterVersionsCommandOutput = await this.getClient(filter).send(cmd)
40+
const response: DescribeClusterVersionsCommandOutput = await this.getClientS().send(cmd)
4241
const addons: ClusterVersionInformation[] = response.clusterVersions ?? [];
42+
// console.log(addons)
4343
const result = {
4444
releases: addons
4545
.filter((info): info is ClusterVersionInformation & { clusterVersion: string } =>
@@ -50,7 +50,7 @@ export class AwsEKSDataSource {
5050
status: info.status,
5151
}))
5252
}
53-
console.log(addons)
53+
// console.log(addons)
5454
return result
5555
// return {
5656
// releases: addons
@@ -73,23 +73,30 @@ export class AwsEKSDataSource {
7373
// };
7474
}
7575

76-
private getClient({ region, profile }: EksFilter): EKSClient {
77-
const cacheKey = `${region ?? 'default'}#${profile ?? 'default'}`;
78-
if (!(cacheKey in this.clients)) {
79-
this.clients[cacheKey] = new EKSClient({
80-
region: region ?? undefined,
81-
credentials: fromNodeProviderChain(profile ? { profile: profile } : undefined)
82-
})
83-
}
84-
return this.clients[cacheKey];
76+
// private getClient({ region, profile }: EksFilter): EKSClient {
77+
// const cacheKey = `${region ?? 'default'}#${profile ?? 'default'}`;
78+
// if (!(cacheKey in this.clients)) {
79+
// this.clients[cacheKey] = new EKSClient({
80+
// region: region ?? undefined,
81+
// credentials: fromNodeProviderChain(profile ? { profile: profile } : undefined)
82+
// })
83+
// }
84+
// return this.clients[cacheKey];
85+
// }
86+
87+
private getClientS(): EKSClient {
88+
return new EKSClient()
8589
}
8690
}
8791

8892
const eks = new AwsEKSDataSource()
8993

9094
const input: readonly string[] = [
9195
'{}',
92-
// '{"addonName":"amazon-cloudwatch-observability", "default":true}'
96+
'{"default":true}',
97+
'{"default":false}',
98+
// '{"status":"standard-support", "default":true}',
99+
// '{"status":"standard_support"}',
93100
];
94101

95102
input.forEach((el) => {

with-tests/eks/src/schema.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { type ZodEffects, type ZodString, z } from 'zod';
22
import { Json } from './utils/schema-utils';
33

4+
// https://github.com/colinhacks/zod
5+
46
const stringIsBoolSchema: ZodEffects<ZodString, boolean, string> = z
57
.string()
68
.transform((value) => {
@@ -13,13 +15,10 @@ const stringIsBoolSchema: ZodEffects<ZodString, boolean, string> = z
1315
}
1416
});
1517

16-
// declare const ClusterVersionStatus: {
17-
// readonly extended_support: "extended-support";
18-
// readonly standard_support: "standard-support";
19-
// };
20-
2118
// added status
2219

20+
// Only one of the defaultOnly, clusterVersions, includeAll or status request parameters is accepted at a time.
21+
// Only one of the defaultOnly, clusterVersions, includeAll or status request parameters is accepted at a time.
2322
export const EksFilterSchema = z.object({
2423
default: z.oboolean().or(stringIsBoolSchema),
2524
region: z.string().optional(),

0 commit comments

Comments
 (0)