Skip to content

Commit 32887c6

Browse files
authored
Merge branch 'main' into gh-24880
2 parents 2e752a6 + 939dc84 commit 32887c6

283 files changed

Lines changed: 2116 additions & 514 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Whitespace-only changes.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@
3131
"lerna": "^7.0.1",
3232
"nx": "^16.3.2",
3333
"patch-package": "^6.5.1",
34-
"semver": "^6.3.0",
34+
"semver": "^7.5.2",
3535
"standard-version": "^9.5.0",
36-
"typescript": "~4.9.5"
36+
"ts-node": "^10.9.1",
37+
"typescript": "~5.1.3"
3738
},
3839
"resolutions": {
3940
"colors": "1.4.0",

packages/@aws-cdk-testing/cli-integ/lib/corking.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ export class MemoryStream extends stream.Writable {
1919
this.parts.splice(0, this.parts.length);
2020
}
2121

22-
public async flushTo(strm: NodeJS.WritableStream) {
22+
public async flushTo(strm: NodeJS.WritableStream): Promise<void> {
2323
const flushed = strm.write(this.buffer());
2424
if (!flushed) {
2525
return new Promise(ok => strm.once('drain', ok));
2626
}
27+
return;
2728
}
2829

2930
public toString() {

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/tsconfig-custom.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"inlineSourceMap": true,
55
"inlineSources": true,
66
"alwaysStrict": true,
7-
"charset": "utf8",
87
"declaration": true,
98
"emitDecoratorMetadata": true,
109
"experimentalDecorators": true,

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"inlineSourceMap": true,
55
"inlineSources": true,
66
"alwaysStrict": true,
7-
"charset": "utf8",
87
"declaration": true,
98
"experimentalDecorators": true,
109
"incremental": true,

packages/@aws-cdk/aws-batch-alpha/lib/managed-compute-environment.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,15 +1068,17 @@ export class FargateComputeEnvironment extends ManagedComputeEnvironmentBase imp
10681068
const stack = Stack.of(scope);
10691069
const computeEnvironmentName = stack.splitArn(fargateComputeEnvironmentArn, ArnFormat.SLASH_RESOURCE_NAME).resourceName!;
10701070

1071-
class Import extends ManagedComputeEnvironmentBase implements IFargateComputeEnvironment {
1071+
class Import extends Resource implements IFargateComputeEnvironment {
10721072
public readonly computeEnvironmentArn = fargateComputeEnvironmentArn;
10731073
public readonly computeEnvironmentName = computeEnvironmentName;
10741074
public readonly enabled = true;
1075+
public readonly maxvCpus = 1;
1076+
public readonly connections = { } as any;
1077+
public readonly securityGroups = [];
1078+
public readonly tags: TagManager = new TagManager(TagType.MAP, 'AWS::Batch::ComputeEnvironment');
10751079
}
10761080

1077-
return new Import(scope, id, {
1078-
vpc: undefined as any,
1079-
});
1081+
return new Import(scope, id);
10801082
}
10811083

10821084
public readonly computeEnvironmentName: string;

packages/@aws-cdk/aws-batch-alpha/test/managed-compute-environment.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,4 +935,12 @@ describe('FargateComputeEnvironment', () => {
935935
ComputeEnvironmentName: 'maxPropsFargateCE',
936936
});
937937
});
938+
939+
test('can be imported from arn', () => {
940+
// WHEN
941+
const ce = FargateComputeEnvironment.fromFargateComputeEnvironmentArn(stack, 'import', 'arn:aws:batch:us-east-1:123456789012:compute-environment/ce-name');
942+
943+
// THEN
944+
expect(ce.computeEnvironmentArn).toEqual('arn:aws:batch:us-east-1:123456789012:compute-environment/ce-name');
945+
});
938946
});

packages/@aws-cdk/cdk-cli-wrapper/lib/cdk-wrapper.ts

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { DefaultCdkOptions, DeployOptions, DestroyOptions, SynthOptions, ListOptions, StackActivityProgress } from './commands';
2-
import { exec } from './utils';
1+
import { ChildProcess } from 'child_process';
2+
import { DefaultCdkOptions, DeployOptions, DestroyOptions, SynthOptions, ListOptions, StackActivityProgress, HotswapMode } from './commands';
3+
import { exec, watch } from './utils';
34

45
/**
56
* AWS CDK CLI operations
@@ -30,6 +31,11 @@ export interface ICdk {
3031
* cdk synth fast
3132
*/
3233
synthFast(options: SynthFastOptions): void;
34+
35+
/**
36+
* cdk watch
37+
*/
38+
watch(options: DeployOptions): ChildProcess;
3339
}
3440

3541
/**
@@ -176,6 +182,7 @@ export class CdkCliWrapper implements ICdk {
176182
...options.changeSetName ? ['--change-set-name', options.changeSetName] : [],
177183
...options.toolkitStackName ? ['--toolkit-stack-name', options.toolkitStackName] : [],
178184
...options.progress ? ['--progress', options.progress] : ['--progress', StackActivityProgress.EVENTS],
185+
...options.deploymentMethod ? ['--method', options.deploymentMethod] : [],
179186
...this.createDefaultArguments(options),
180187
];
181188

@@ -186,6 +193,50 @@ export class CdkCliWrapper implements ICdk {
186193
});
187194
}
188195

196+
public watch(options: DeployOptions): ChildProcess {
197+
let hotswap: string;
198+
switch (options.hotswap) {
199+
case HotswapMode.FALL_BACK:
200+
hotswap = '--hotswap-fallback';
201+
break;
202+
case HotswapMode.HOTSWAP_ONLY:
203+
hotswap = '--hotswap';
204+
break;
205+
default:
206+
hotswap = '--hotswap-fallback';
207+
break;
208+
}
209+
const deployCommandArgs: string[] = [
210+
'--watch',
211+
...renderBooleanArg('ci', options.ci),
212+
...renderBooleanArg('execute', options.execute),
213+
...renderBooleanArg('exclusively', options.exclusively),
214+
...renderBooleanArg('force', options.force),
215+
...renderBooleanArg('previous-parameters', options.usePreviousParameters),
216+
...renderBooleanArg('rollback', options.rollback),
217+
...renderBooleanArg('staging', options.staging),
218+
...renderBooleanArg('logs', options.traceLogs),
219+
hotswap,
220+
...options.reuseAssets ? renderArrayArg('--reuse-assets', options.reuseAssets) : [],
221+
...options.notificationArns ? renderArrayArg('--notification-arns', options.notificationArns) : [],
222+
...options.parameters ? renderMapArrayArg('--parameters', options.parameters) : [],
223+
...options.outputsFile ? ['--outputs-file', options.outputsFile] : [],
224+
...options.requireApproval ? ['--require-approval', options.requireApproval] : [],
225+
...options.changeSetName ? ['--change-set-name', options.changeSetName] : [],
226+
...options.toolkitStackName ? ['--toolkit-stack-name', options.toolkitStackName] : [],
227+
...options.progress ? ['--progress', options.progress] : ['--progress', StackActivityProgress.EVENTS],
228+
...options.deploymentMethod ? ['--method', options.deploymentMethod] : [],
229+
...this.createDefaultArguments(options),
230+
];
231+
232+
return watch([this.cdk, 'deploy', ...deployCommandArgs], {
233+
cwd: this.directory,
234+
verbose: this.showOutput,
235+
env: this.env,
236+
});
237+
238+
}
239+
189240
/**
190241
* cdk destroy
191242
*/

packages/@aws-cdk/cdk-cli-wrapper/lib/commands/deploy.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,53 @@ export interface DeployOptions extends DefaultCdkOptions {
105105
* @default StackActivityProgress.EVENTS
106106
*/
107107
readonly progress?: StackActivityProgress;
108+
109+
/**
110+
* Whether this 'deploy' command should actually delegate to the 'watch' command.
111+
*
112+
* @default false
113+
*/
114+
readonly watch?: boolean;
115+
116+
/**
117+
* Whether to perform a 'hotswap' deployment.
118+
* A 'hotswap' deployment will attempt to short-circuit CloudFormation
119+
* and update the affected resources like Lambda functions directly.
120+
*
121+
* @default - `HotswapMode.FALL_BACK` for regular deployments, `HotswapMode.HOTSWAP_ONLY` for 'watch' deployments
122+
*/
123+
readonly hotswap?: HotswapMode;
124+
125+
/**
126+
* Whether to show CloudWatch logs for hotswapped resources
127+
* locally in the users terminal
128+
*
129+
* @default - false
130+
*/
131+
readonly traceLogs?: boolean;
132+
133+
/**
134+
* Deployment method
135+
*/
136+
readonly deploymentMethod?: DeploymentMethod;
137+
}
138+
export type DeploymentMethod = 'direct' | 'change-set';
139+
140+
export enum HotswapMode {
141+
/**
142+
* Will fall back to CloudFormation when a non-hotswappable change is detected
143+
*/
144+
FALL_BACK = 'fall-back',
145+
146+
/**
147+
* Will not fall back to CloudFormation when a non-hotswappable change is detected
148+
*/
149+
HOTSWAP_ONLY = 'hotswap-only',
150+
151+
/**
152+
* Will not attempt to hotswap anything and instead go straight to CloudFormation
153+
*/
154+
FULL_DEPLOYMENT = 'full-deployment',
108155
}
109156

110157
/**

packages/@aws-cdk/cdk-cli-wrapper/lib/utils.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Helper functions for CDK Exec
2-
import { spawnSync } from 'child_process';
2+
import { spawn, spawnSync } from 'child_process';
33

44
/**
55
* Our own execute function which doesn't use shells and strings.
@@ -37,3 +37,22 @@ export function exec(commandLine: string[], options: { cwd?: string, json?: bool
3737
throw new Error('Command output is not JSON');
3838
}
3939
}
40+
41+
/**
42+
* For use with `cdk deploy --watch`
43+
*/
44+
export function watch(commandLine: string[], options: { cwd?: string, verbose?: boolean, env?: any } = { }) {
45+
const proc = spawn(commandLine[0], commandLine.slice(1), {
46+
stdio: ['ignore', 'pipe', options.verbose ? 'inherit' : 'pipe'], // inherit STDERR in verbose mode
47+
env: {
48+
...process.env,
49+
...options.env,
50+
},
51+
cwd: options.cwd,
52+
});
53+
proc.on('error', (err: Error) => {
54+
throw err;
55+
});
56+
57+
return proc;
58+
}

0 commit comments

Comments
 (0)