diff --git a/packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts b/packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts index 1902d757f486d..284bb3a8d5f46 100644 --- a/packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts +++ b/packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts @@ -54,7 +54,7 @@ export function fullDiff( normalize(newTemplate); const theDiff = diffTemplate(currentTemplate, newTemplate); if (changeSet) { - filterFalsePositivies(theDiff, changeSet); + filterFalsePositives(theDiff, changeSet); addImportInformation(theDiff, changeSet); } if (isImport) { @@ -64,7 +64,7 @@ export function fullDiff( return theDiff; } -function diffTemplate( +export function diffTemplate( currentTemplate: { [key: string]: any }, newTemplate: { [key: string]: any }, ): types.TemplateDiff { @@ -235,7 +235,7 @@ function addImportInformation(diff: types.TemplateDiff, changeSet?: CloudFormati } } -function filterFalsePositivies(diff: types.TemplateDiff, changeSet: CloudFormation.DescribeChangeSetOutput) { +function filterFalsePositives(diff: types.TemplateDiff, changeSet: CloudFormation.DescribeChangeSetOutput) { const replacements = findResourceReplacements(changeSet); diff.resources.forEachDifference((logicalId: string, change: types.ResourceDifference) => { if (change.resourceType.includes('AWS::Serverless')) { diff --git a/packages/@aws-cdk/cloudformation-diff/lib/format.ts b/packages/@aws-cdk/cloudformation-diff/lib/format.ts index 7935f774fd468..724af468c2f45 100644 --- a/packages/@aws-cdk/cloudformation-diff/lib/format.ts +++ b/packages/@aws-cdk/cloudformation-diff/lib/format.ts @@ -30,7 +30,7 @@ export interface FormatStream extends NodeJS.WritableStream { export function formatDifferences( stream: FormatStream, templateDiff: TemplateDiff, - logicalToPathMap: { [logicalId: string]: string } = { }, + logicalToPathMap: { [logicalId: string]: string } = {}, context: number = 3) { const formatter = new Formatter(stream, logicalToPathMap, templateDiff, context); @@ -59,7 +59,7 @@ export function formatDifferences( export function formatSecurityChanges( stream: NodeJS.WritableStream, templateDiff: TemplateDiff, - logicalToPathMap: {[logicalId: string]: string} = {}, + logicalToPathMap: { [logicalId: string]: string } = {}, context?: number) { const formatter = new Formatter(stream, logicalToPathMap, templateDiff, context); @@ -254,7 +254,7 @@ class Formatter { const oldStr = JSON.stringify(oldObject, null, 2); const newStr = JSON.stringify(newObject, null, 2); const diff = _diffStrings(oldStr, newStr, this.context); - for (let i = 0 ; i < diff.length ; i++) { + for (let i = 0; i < diff.length; i++) { this.print('%s %s %s', linePrefix, i === 0 ? '└─' : ' ', diff[i]); } } else { @@ -466,7 +466,7 @@ function _diffStrings(oldStr: string, newStr: string, context: number): string[] function _findIndent(lines: string[]): number { let indent = Number.MAX_SAFE_INTEGER; for (const line of lines) { - for (let i = 1 ; i < line.length ; i++) { + for (let i = 1; i < line.length; i++) { if (line.charAt(i) !== ' ') { indent = indent > i - 1 ? i - 1 : indent; break; diff --git a/packages/aws-cdk/lib/api/deployments.ts b/packages/aws-cdk/lib/api/deployments.ts index 925cdebd45e15..b7bea90c56c28 100644 --- a/packages/aws-cdk/lib/api/deployments.ts +++ b/packages/aws-cdk/lib/api/deployments.ts @@ -7,7 +7,7 @@ import { CredentialsOptions, SdkForEnvironment, SdkProvider } from './aws-auth/s import { deployStack, DeployStackResult, destroyStack, DeploymentMethod } from './deploy-stack'; import { EnvironmentResources, EnvironmentResourcesRegistry } from './environment-resources'; import { HotswapMode } from './hotswap/common'; -import { loadCurrentTemplateWithNestedStacks, loadCurrentTemplate, flattenNestedStackNames, TemplateWithNestedStackCount } from './nested-stack-helpers'; +import { loadCurrentTemplateWithNestedStacks, loadCurrentTemplate, RootTemplateWithNestedStacks } from './nested-stack-helpers'; import { CloudFormationStack, Template, ResourcesToImport, ResourceIdentifierSummaries } from './util/cloudformation'; import { StackActivityProgress } from './util/cloudformation/stack-activity-monitor'; import { replaceEnvPlaceholders } from './util/placeholders'; @@ -327,13 +327,9 @@ export class Deployments { public async readCurrentTemplateWithNestedStacks( rootStackArtifact: cxapi.CloudFormationStackArtifact, retrieveProcessedTemplate: boolean = false, - ): Promise { + ): Promise { const sdk = (await this.prepareSdkWithLookupOrDeployRole(rootStackArtifact)).stackSdk; - const templateWithNestedStacks = await loadCurrentTemplateWithNestedStacks(rootStackArtifact, sdk, retrieveProcessedTemplate); - return { - deployedTemplate: templateWithNestedStacks.deployedTemplate, - nestedStackCount: flattenNestedStackNames(templateWithNestedStacks.nestedStackNames).length, - }; + return loadCurrentTemplateWithNestedStacks(rootStackArtifact, sdk, retrieveProcessedTemplate); } public async readCurrentTemplate(stackArtifact: cxapi.CloudFormationStackArtifact): Promise