Skip to content

Commit

Permalink
Use Node 18
Browse files Browse the repository at this point in the history
  • Loading branch information
plumdog committed May 15, 2024
1 parent 13c9f1c commit 3dc26c3
Show file tree
Hide file tree
Showing 7 changed files with 8,789 additions and 4,694 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v1
with:
node-version: '16.x'
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run compile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
node-version: [16.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16
v18
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class NodegroupAsgTagsProvider extends Construct {

const handler = new lambda.Function(this, 'Handler', {
code: lambda.Code.fromAsset(pathlib.join(__dirname, 'provider')),
runtime: lambda.Runtime.NODEJS_16_X,
runtime: lambda.Runtime.NODEJS_18_X,
handler: 'index.onEvent',
timeout: Duration.seconds(30),
});
Expand Down
13,429 changes: 8,764 additions & 4,665 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,21 @@
"lint": "npm run -- _lint --fix",
"lint-check": "npm run -- _lint --max-warnings 0",
"clean-provider": "rm -rf provider/build/",
"compile-provider": "npm run clean-provider && npx esbuild --platform=node --target=node16 --minify-syntax --external:aws-sdk --bundle --outdir=./provider/build ./provider/index.ts"
"compile-provider": "npm run clean-provider && npx esbuild --platform=node --target=node18 --minify-syntax --external:aws-sdk --bundle --outdir=./provider/build ./provider/index.ts"
},
"peerDependencies": {
"aws-cdk-lib": "^2.0.0",
"aws-cdk-lib": "^2.51.0",
"constructs": "^10.0.0"
},
"devDependencies": {
"@aws-sdk/client-auto-scaling": "^3.576.0",
"@aws-sdk/client-eks": "^3.576.0",
"@types/jest": "^24.0.0",
"@types/node": ">=10",
"@typescript-eslint/eslint-plugin": "5.50.0",
"@typescript-eslint/parser": "5.50.0",
"auto-changelog": "^1.16.2",
"aws-cdk-lib": "^2.15.0",
"aws-sdk": ">=2 <3",
"aws-cdk-lib": "^2.51.0",
"constructs": "^10.0.0",
"esbuild": "^0.17.5",
"eslint": "8.33.0",
Expand All @@ -52,6 +53,6 @@
"jest": "~29.3.1",
"prettier": "2.8.3",
"ts-jest": "29.0.3",
"typescript": ">=4.0.0"
"typescript": "^4.9.0"
}
}
35 changes: 15 additions & 20 deletions provider/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as AWS from 'aws-sdk';
import { AutoScaling } from '@aws-sdk/client-auto-scaling';
import { EKS } from '@aws-sdk/client-eks';
import * as utils from './utils';

interface ResourceProperties {
Expand Down Expand Up @@ -60,14 +61,12 @@ const loadTags = (tagsJson: string): Tags => {
};

const findAsgName = async (clusterName: string, nodegroupName: string): Promise<string> => {
const eks = new AWS.EKS();
const eks = new EKS();

const describeNodegroupResponse = await eks
.describeNodegroup({
clusterName,
nodegroupName,
})
.promise();
const describeNodegroupResponse = await eks.describeNodegroup({
clusterName,
nodegroupName,
});

const asgName = describeNodegroupResponse.nodegroup?.resources?.autoScalingGroups?.[0]?.name;

Expand All @@ -79,7 +78,7 @@ const findAsgName = async (clusterName: string, nodegroupName: string): Promise<
};

const tagAsg = async (asgName: string, tags: Tags): Promise<void> => {
const autoScaling = new AWS.AutoScaling();
const autoScaling = new AutoScaling();

const tagsToApply = [];

Expand All @@ -97,15 +96,13 @@ const tagAsg = async (asgName: string, tags: Tags): Promise<void> => {
return;
}

await autoScaling
.createOrUpdateTags({
Tags: tagsToApply,
})
.promise();
await autoScaling.createOrUpdateTags({
Tags: tagsToApply,
});
};

const untagAsg = async (asgName: string, tagKeys: Array<string>): Promise<void> => {
const autoScaling = new AWS.AutoScaling();
const autoScaling = new AutoScaling();

const tagsToDelete = [];

Expand All @@ -123,11 +120,9 @@ const untagAsg = async (asgName: string, tagKeys: Array<string>): Promise<void>
return;
}

await autoScaling
.deleteTags({
Tags: tagsToDelete,
})
.promise();
await autoScaling.deleteTags({
Tags: tagsToDelete,
});
};

const handleCreate = async (event: utils.CreateEvent<ResourceProperties>): Promise<utils.Response> => {
Expand Down

0 comments on commit 3dc26c3

Please sign in to comment.