Skip to content

Commit

Permalink
fix(toolkit): scrutiny dialog should with no tty
Browse files Browse the repository at this point in the history
If STDIN is not connected to a TTY (terminal), and scrutiny is enabled,
we expect the program to fail (exit with non-zero exit code).

This is especially important for CI/CD scenarios where you wouldn't want
to accidentally deploy changes that didn't pass a scrutiny check.

Fixes #1380

Tested manually.
  • Loading branch information
Elad Ben-Israel committed Dec 17, 2018
1 parent 2759a6b commit 40235b6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/aws-cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,13 @@ async function initCommandLine() {
if (requireApproval !== RequireApproval.Never) {
const currentTemplate = await readCurrentTemplate(stack);
if (printSecurityDiff(currentTemplate, stack, requireApproval)) {
const confirmed = await confirm(`Do you wish to deploy these changes (y/n)?`);

// only talk to user if we STDIN is a terminal (otherwise, fail)
let confirmed = false;
if (process.stdin.isTTY) {
confirmed = await confirm(`Do you wish to deploy these changes (y/n)?`);
}

if (!confirmed) { throw new Error('Aborted by user'); }
}
}
Expand Down

0 comments on commit 40235b6

Please sign in to comment.