-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
59 additions
and
26 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
packages/@aws-cdk/toolkit/lib/actions/diff/private/helpers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { DescribeChangeSetOutput, fullDiff } from '@aws-cdk/cloudformation-diff'; | ||
import * as cxapi from '@aws-cdk/cx-api'; | ||
import { ToolkitError } from '../../../api/errors'; | ||
import { RequireApproval } from '../../deploy'; | ||
|
||
/** | ||
* Return whether the diff has security-impacting changes that need confirmation | ||
*/ | ||
export function diffRequiresApproval( | ||
oldTemplate: any, | ||
newTemplate: cxapi.CloudFormationStackArtifact, | ||
requireApproval: RequireApproval, | ||
changeSet?: DescribeChangeSetOutput, | ||
): boolean { | ||
// @todo return or print the full diff. | ||
const diff = fullDiff(oldTemplate, newTemplate.template, changeSet); | ||
|
||
switch (requireApproval) { | ||
case RequireApproval.NEVER: return false; | ||
case RequireApproval.ANY_CHANGE: return diff.permissionsAnyChanges; | ||
case RequireApproval.BROADENING: return diff.permissionsBroadened; | ||
default: throw new ToolkitError(`Unrecognized approval level: ${requireApproval}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './helpers'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters