diff --git a/packages/aws-cdk/lib/cli/cli-config.ts b/packages/aws-cdk/lib/cli/cli-config.ts index 73f46cf7e..6d02257fc 100644 --- a/packages/aws-cdk/lib/cli/cli-config.ts +++ b/packages/aws-cdk/lib/cli/cli-config.ts @@ -183,15 +183,15 @@ export async function makeConfig(): Promise { 'Do not use this in production environments', }, 'hotswap-ecs-minimum-healthy-percent': { - type: 'string', + type: 'number', desc: 'Lower limit on the number of your service\'s tasks that must remain in the RUNNING state during a deployment, as a percentage of the desiredCount', }, 'hotswap-ecs-maximum-healthy-percent': { - type: 'string', + type: 'number', desc: 'Upper limit on the number of your service\'s tasks that are allowed in the RUNNING or PENDING state during a deployment, as a percentage of the desiredCount', }, 'hotswap-ecs-stabilization-timeout-seconds': { - type: 'string', + type: 'number', desc: 'Number of seconds to wait for a single service to reach stable state, where the desiredCount is equal to the runningCount', }, 'watch': { @@ -312,15 +312,15 @@ export async function makeConfig(): Promise { 'and falls back to a full deployment if that is not possible.', }, 'hotswap-ecs-minimum-healthy-percent': { - type: 'string', + type: 'number', desc: 'Lower limit on the number of your service\'s tasks that must remain in the RUNNING state during a deployment, as a percentage of the desiredCount', }, 'hotswap-ecs-maximum-healthy-percent': { - type: 'string', + type: 'number', desc: 'Upper limit on the number of your service\'s tasks that are allowed in the RUNNING or PENDING state during a deployment, as a percentage of the desiredCount', }, 'hotswap-ecs-stabilization-timeout-seconds': { - type: 'string', + type: 'number', desc: 'Number of seconds to wait for a single service to reach stable state, where the desiredCount is equal to the runningCount', }, 'logs': { diff --git a/packages/aws-cdk/lib/cli/cli-type-registry.json b/packages/aws-cdk/lib/cli/cli-type-registry.json index 439316754..c69ea647d 100644 --- a/packages/aws-cdk/lib/cli/cli-type-registry.json +++ b/packages/aws-cdk/lib/cli/cli-type-registry.json @@ -518,15 +518,15 @@ "desc": "Attempts to perform a 'hotswap' deployment, which skips CloudFormation and updates the resources directly, and falls back to a full deployment if that is not possible. Do not use this in production environments" }, "hotswap-ecs-minimum-healthy-percent": { - "type": "string", + "type": "number", "desc": "Lower limit on the number of your service's tasks that must remain in the RUNNING state during a deployment, as a percentage of the desiredCount" }, "hotswap-ecs-maximum-healthy-percent": { - "type": "string", + "type": "number", "desc": "Upper limit on the number of your service's tasks that are allowed in the RUNNING or PENDING state during a deployment, as a percentage of the desiredCount" }, "hotswap-ecs-stabilization-timeout-seconds": { - "type": "string", + "type": "number", "desc": "Number of seconds to wait for a single service to reach stable state, where the desiredCount is equal to the runningCount" }, "watch": { @@ -696,15 +696,15 @@ "desc": "Attempts to perform a 'hotswap' deployment, which skips CloudFormation and updates the resources directly, and falls back to a full deployment if that is not possible." }, "hotswap-ecs-minimum-healthy-percent": { - "type": "string", + "type": "number", "desc": "Lower limit on the number of your service's tasks that must remain in the RUNNING state during a deployment, as a percentage of the desiredCount" }, "hotswap-ecs-maximum-healthy-percent": { - "type": "string", + "type": "number", "desc": "Upper limit on the number of your service's tasks that are allowed in the RUNNING or PENDING state during a deployment, as a percentage of the desiredCount" }, "hotswap-ecs-stabilization-timeout-seconds": { - "type": "string", + "type": "number", "desc": "Number of seconds to wait for a single service to reach stable state, where the desiredCount is equal to the runningCount" }, "logs": { diff --git a/packages/aws-cdk/lib/cli/parse-command-line-arguments.ts b/packages/aws-cdk/lib/cli/parse-command-line-arguments.ts index e28045c5f..3103b3299 100644 --- a/packages/aws-cdk/lib/cli/parse-command-line-arguments.ts +++ b/packages/aws-cdk/lib/cli/parse-command-line-arguments.ts @@ -3,8 +3,8 @@ // Do not edit by hand; all changes will be overwritten at build time from the config file. // ------------------------------------------------------------------------------------------- /* eslint-disable @stylistic/max-len, @typescript-eslint/consistent-type-imports */ -import { Argv } from 'yargs'; import * as helpers from './util/yargs-helpers'; +import { Argv } from 'yargs'; // @ts-ignore TS6133 export function parseCommandLineArguments(args: Array): any { @@ -550,17 +550,17 @@ export function parseCommandLineArguments(args: Array): any { }) .option('hotswap-ecs-minimum-healthy-percent', { default: undefined, - type: 'string', + type: 'number', desc: "Lower limit on the number of your service's tasks that must remain in the RUNNING state during a deployment, as a percentage of the desiredCount", }) .option('hotswap-ecs-maximum-healthy-percent', { default: undefined, - type: 'string', + type: 'number', desc: "Upper limit on the number of your service's tasks that are allowed in the RUNNING or PENDING state during a deployment, as a percentage of the desiredCount", }) .option('hotswap-ecs-stabilization-timeout-seconds', { default: undefined, - type: 'string', + type: 'number', desc: 'Number of seconds to wait for a single service to reach stable state, where the desiredCount is equal to the runningCount', }) .option('watch', { @@ -729,17 +729,17 @@ export function parseCommandLineArguments(args: Array): any { }) .option('hotswap-ecs-minimum-healthy-percent', { default: undefined, - type: 'string', + type: 'number', desc: "Lower limit on the number of your service's tasks that must remain in the RUNNING state during a deployment, as a percentage of the desiredCount", }) .option('hotswap-ecs-maximum-healthy-percent', { default: undefined, - type: 'string', + type: 'number', desc: "Upper limit on the number of your service's tasks that are allowed in the RUNNING or PENDING state during a deployment, as a percentage of the desiredCount", }) .option('hotswap-ecs-stabilization-timeout-seconds', { default: undefined, - type: 'string', + type: 'number', desc: 'Number of seconds to wait for a single service to reach stable state, where the desiredCount is equal to the runningCount', }) .option('logs', { diff --git a/packages/aws-cdk/lib/cli/user-input.ts b/packages/aws-cdk/lib/cli/user-input.ts index 9d3f9cc11..aecdfcaf4 100644 --- a/packages/aws-cdk/lib/cli/user-input.ts +++ b/packages/aws-cdk/lib/cli/user-input.ts @@ -867,21 +867,21 @@ export interface DeployOptions { * * @default - undefined */ - readonly hotswapEcsMinimumHealthyPercent?: string; + readonly hotswapEcsMinimumHealthyPercent?: number; /** * Upper limit on the number of your service's tasks that are allowed in the RUNNING or PENDING state during a deployment, as a percentage of the desiredCount * * @default - undefined */ - readonly hotswapEcsMaximumHealthyPercent?: string; + readonly hotswapEcsMaximumHealthyPercent?: number; /** * Number of seconds to wait for a single service to reach stable state, where the desiredCount is equal to the runningCount * * @default - undefined */ - readonly hotswapEcsStabilizationTimeoutSeconds?: string; + readonly hotswapEcsStabilizationTimeoutSeconds?: number; /** * Continuously observe the project files, and deploy the given stack(s) automatically when changes are detected. Implies --hotswap by default @@ -1127,21 +1127,21 @@ export interface WatchOptions { * * @default - undefined */ - readonly hotswapEcsMinimumHealthyPercent?: string; + readonly hotswapEcsMinimumHealthyPercent?: number; /** * Upper limit on the number of your service's tasks that are allowed in the RUNNING or PENDING state during a deployment, as a percentage of the desiredCount * * @default - undefined */ - readonly hotswapEcsMaximumHealthyPercent?: string; + readonly hotswapEcsMaximumHealthyPercent?: number; /** * Number of seconds to wait for a single service to reach stable state, where the desiredCount is equal to the runningCount * * @default - undefined */ - readonly hotswapEcsStabilizationTimeoutSeconds?: string; + readonly hotswapEcsStabilizationTimeoutSeconds?: number; /** * Show CloudWatch log events from all resources in the selected Stacks in the terminal. 'true' by default, use --no-logs to turn off diff --git a/packages/aws-cdk/test/cli/cli-arguments.test.ts b/packages/aws-cdk/test/cli/cli-arguments.test.ts index 3c3269361..839f2719a 100644 --- a/packages/aws-cdk/test/cli/cli-arguments.test.ts +++ b/packages/aws-cdk/test/cli/cli-arguments.test.ts @@ -95,6 +95,29 @@ describe('yargs', () => { globalOptions: expect.anything(), }); }); + + test('hotswap ECS arguments are correctly parsed', async () => { + const input = await parseCommandLineArguments([ + 'deploy', + '--hotswap', + '--hotswap-ecs-minimum-healthy-percent', '100', + '--hotswap-ecs-maximum-healthy-percent', '250', + '--hotswap-ecs-stabilization-timeout-seconds', '300', + ]); + + const result = convertYargsToUserInput(input); + + expect(result).toEqual({ + command: 'deploy', + deploy: expect.objectContaining({ + hotswap: true, + hotswapEcsMinimumHealthyPercent: 100, + hotswapEcsMaximumHealthyPercent: 250, + hotswapEcsStabilizationTimeoutSeconds: 300, + }), + globalOptions: expect.anything(), + }); + }); }); describe('config', () => {