Skip to content

Commit

Permalink
Fix the semver version check for adminPassword props
Browse files Browse the repository at this point in the history
Signed-off-by: Sayali Gaikawad <gaiksaya@amazon.com>
  • Loading branch information
gaiksaya committed Jan 5, 2024
1 parent 71fa6ba commit 358f878
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
3 changes: 2 additions & 1 deletion lib/infra/infra-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { LogGroup, RetentionDays } from 'aws-cdk-lib/aws-logs';
import { readFileSync } from 'fs';
import { dump, load } from 'js-yaml';
import { join } from 'path';
import { satisfies } from 'semver';
import { CloudwatchAgent } from '../cloudwatch/cloudwatch-agent';
import { ProcstatMetricDefinition } from '../cloudwatch/metrics-section';
import { InfraStackMonitoring } from '../monitoring/alarms';
Expand Down Expand Up @@ -206,7 +207,7 @@ export class InfraStack extends Stack {
this.securityDisabled = securityDisabled === 'true';

this.adminPassword = this.securityDisabled ? '' : `${props?.adminPassword ?? scope.node.tryGetContext('adminPassword')}`;
if (!this.securityDisabled && Number.parseFloat(this.distVersion) >= 2.12 && this.adminPassword === 'undefined') {
if (!this.securityDisabled && satisfies(this.distVersion, '>=2.12.0') && this.adminPassword === 'undefined') {
throw new Error('adminPassword parameter is required to be set when security is enabled');
}

Expand Down
26 changes: 20 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
},
"devDependencies": {
"@types/jest": "^27.5.2",
"@types/js-yaml": "^4.0.5",
"@types/node": "10.17.27",
"@types/prettier": "2.6.0",
"@types/js-yaml": "^4.0.5",
"@types/semver": "^7.5.6",
"aws-cdk": "2.45.0",
"jest": "^27.5.1",
"ts-jest": "^27.1.4",
Expand All @@ -27,10 +28,11 @@
"@typescript-eslint/parser": "^4.31.1",
"aws-cdk-lib": "2.45.0",
"constructs": "^10.0.0",
"js-yaml": "^4.1.0",
"source-map-support": "^0.5.21",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.24.2"
"eslint-plugin-import": "^2.24.2",
"js-yaml": "^4.1.0",
"semver": "^7.5.6",
"source-map-support": "^0.5.21"
}
}

0 comments on commit 358f878

Please sign in to comment.