diff --git a/packages/@aws-cdk/integ-runner/lib/runner/private/canonicalize-assets.ts b/packages/@aws-cdk/integ-runner/lib/runner/private/canonicalize-assets.ts deleted file mode 100644 index 9cee3d4742b3c..0000000000000 --- a/packages/@aws-cdk/integ-runner/lib/runner/private/canonicalize-assets.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Reduce template to a normal form where asset references have been normalized - * - * This makes it possible to compare templates if all that's different between - * them is the hashes of the asset values. - * - * Currently only handles parameterized assets, but can (and should) - * be adapted to handle convention-mode assets as well when we start using - * more of those. - */ -export function canonicalizeTemplate(template: any): any { - // For the weird case where we have an array of templates... - if (Array.isArray(template)) { - return template.map(canonicalizeTemplate); - } - - // Find assets via parameters - const stringSubstitutions = new Array<[RegExp, string]>(); - const paramRe = /^AssetParameters([a-zA-Z0-9]{64})(S3Bucket|S3VersionKey|ArtifactHash)([a-zA-Z0-9]{8})$/; - - const assetsSeen = new Set(); - for (const paramName of Object.keys(template?.Parameters || {})) { - const m = paramRe.exec(paramName); - if (!m) { continue; } - if (assetsSeen.has(m[1])) { continue; } - - assetsSeen.add(m[1]); - const ix = assetsSeen.size; - - // Full parameter reference - stringSubstitutions.push([ - new RegExp(`AssetParameters${m[1]}(S3Bucket|S3VersionKey|ArtifactHash)([a-zA-Z0-9]{8})`), - `Asset${ix}$1`, - ]); - // Substring asset hash reference - stringSubstitutions.push([ - new RegExp(`${m[1]}`), - `Asset${ix}Hash`, - ]); - } - - // Substitute them out - return substitute(template); - - function substitute(what: any): any { - if (Array.isArray(what)) { - return what.map(substitute); - } - - if (typeof what === 'object' && what !== null) { - const ret: any = {}; - for (const [k, v] of Object.entries(what)) { - ret[stringSub(k)] = substitute(v); - } - return ret; - } - - if (typeof what === 'string') { - return stringSub(what); - } - - return what; - } - - function stringSub(x: string) { - for (const [re, replacement] of stringSubstitutions) { - x = x.replace(re, replacement); - } - return x; - } -} diff --git a/packages/@aws-cdk/integ-runner/lib/runner/private/cloud-assembly.ts b/packages/@aws-cdk/integ-runner/lib/runner/private/cloud-assembly.ts index 56f2bdcfa4445..71a08392615db 100644 --- a/packages/@aws-cdk/integ-runner/lib/runner/private/cloud-assembly.ts +++ b/packages/@aws-cdk/integ-runner/lib/runner/private/cloud-assembly.ts @@ -90,28 +90,52 @@ export class AssemblyManifestReader { } /** - * For a given stackId return a list of assets that belong to the stack + * Return a list of assets for a given stack */ - public getAssetsForStack(stackId: string): string[] { + public getAssetIdsForStack(stackId: string): string[] { const assets: string[] = []; for (const artifact of Object.values(this.manifest.artifacts ?? {})) { if (artifact.type === ArtifactType.ASSET_MANIFEST && (artifact.properties as AssetManifestProperties)?.file === `${stackId}.assets.json`) { - assets.push(...this.assetsFromAssetManifest(artifact)); + assets.push(...this.assetsFromAssetManifest(artifact).map(asset => asset.id.assetId)); } else if (artifact.type === ArtifactType.AWS_CLOUDFORMATION_STACK) { - assets.push(...this.assetsFromAssemblyManifest(artifact)); + assets.push(...this.assetsFromAssemblyManifest(artifact).map(asset => asset.id)); } } return assets; } - private assetsFromAssemblyManifest(artifact: ArtifactManifest): string[] { + /** + * For a given stackId return a list of assets that belong to the stack + */ + public getAssetLocationsForStack(stackId: string): string[] { const assets: string[] = []; + for (const artifact of Object.values(this.manifest.artifacts ?? {})) { + if (artifact.type === ArtifactType.ASSET_MANIFEST && (artifact.properties as AssetManifestProperties)?.file === `${stackId}.assets.json`) { + assets.push(...this.assetsFromAssetManifest(artifact).map(asset => { + if (asset.type === 'file') { + return asset.source.path!; + } else { + return asset.source.directory!; + } + })); + } else if (artifact.type === ArtifactType.AWS_CLOUDFORMATION_STACK) { + assets.push(...this.assetsFromAssemblyManifest(artifact).map(asset => asset.path)); + } + } + return assets; + } + + /** + * Get a list of assets from the assembly manifest + */ + private assetsFromAssemblyManifest(artifact: ArtifactManifest): (ContainerImageAssetMetadataEntry | FileAssetMetadataEntry)[] { + const assets: (ContainerImageAssetMetadataEntry | FileAssetMetadataEntry)[] = []; for (const metadata of Object.values(artifact.metadata ?? {})) { metadata.forEach(data => { if (data.type === ArtifactMetadataEntryType.ASSET) { - const assetPath = (data.data as ContainerImageAssetMetadataEntry | FileAssetMetadataEntry).path; - if (assetPath.startsWith('asset.')) { - assets.push(assetPath); + const asset = (data.data as ContainerImageAssetMetadataEntry | FileAssetMetadataEntry); + if (asset.path.startsWith('asset.')) { + assets.push(asset); } } }); @@ -119,20 +143,23 @@ export class AssemblyManifestReader { return assets; } - private assetsFromAssetManifest(artifact: ArtifactManifest): string[] { - const assets: string[] = []; + /** + * Get a list of assets from the asset manifest + */ + private assetsFromAssetManifest(artifact: ArtifactManifest): (FileManifestEntry | DockerImageManifestEntry)[] { + const assets: (FileManifestEntry | DockerImageManifestEntry)[] = []; const fileName = (artifact.properties as AssetManifestProperties).file; const assetManifest = AssetManifest.fromFile(path.join(this.directory, fileName)); assetManifest.entries.forEach(entry => { if (entry.type === 'file') { const source = (entry as FileManifestEntry).source; if (source.path && source.path.startsWith('asset.')) { - assets.push((entry as FileManifestEntry).source.path!); + assets.push(entry as FileManifestEntry); } } else if (entry.type === 'docker-image') { const source = (entry as DockerImageManifestEntry).source; if (source.directory && source.directory.startsWith('asset.')) { - assets.push((entry as DockerImageManifestEntry).source.directory!); + assets.push(entry as DockerImageManifestEntry); } } }); diff --git a/packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts b/packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts index c9c67bc6d2f95..8761e1dd9edf9 100644 --- a/packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts +++ b/packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts @@ -268,7 +268,7 @@ export abstract class IntegRunner { const stacks = this.actualTestSuite.getStacksWithoutUpdateWorkflow() ?? []; const manifest = AssemblyManifestReader.fromPath(this.snapshotDir); const assets = flatten(stacks.map(stack => { - return manifest.getAssetsForStack(stack) ?? []; + return manifest.getAssetLocationsForStack(stack) ?? []; })); assets.forEach(asset => { diff --git a/packages/@aws-cdk/integ-runner/lib/runner/snapshot-test-runner.ts b/packages/@aws-cdk/integ-runner/lib/runner/snapshot-test-runner.ts index 84c0fdba6f488..3dbf55b4449fb 100644 --- a/packages/@aws-cdk/integ-runner/lib/runner/snapshot-test-runner.ts +++ b/packages/@aws-cdk/integ-runner/lib/runner/snapshot-test-runner.ts @@ -3,7 +3,6 @@ import { Writable, WritableOptions } from 'stream'; import { StringDecoder } from 'string_decoder'; import { diffTemplate, formatDifferences, ResourceDifference, ResourceImpact } from '@aws-cdk/cloudformation-diff'; import { Diagnostic, DiagnosticReason, DestructiveChange, SnapshotVerificationOptions } from '../workers/common'; -import { canonicalizeTemplate } from './private/canonicalize-assets'; import { AssemblyManifestReader } from './private/cloud-assembly'; import { IntegRunnerOptions, IntegRunner, DEFAULT_SYNTH_OPTIONS } from './runner-base'; @@ -166,8 +165,8 @@ export class IntegSnapshotRunner extends IntegRunner { // asset hashes from the templates so they are not part of the diff // comparison if (!this.actualTestSuite.getOptionsForStack(templateId)?.diffAssets) { - actualTemplate = canonicalizeTemplate(actualTemplate); - expectedTemplate = canonicalizeTemplate(expectedTemplate); + actualTemplate = this.canonicalizeTemplate(actualTemplate, templateId, this.cdkOutDir); + expectedTemplate = this.canonicalizeTemplate(expectedTemplate, templateId, this.snapshotDir); } const templateDiff = diffTemplate(expectedTemplate, actualTemplate); if (!templateDiff.isEmpty) { @@ -225,6 +224,87 @@ export class IntegSnapshotRunner extends IntegRunner { return stacks; } + + /** + * Reduce template to a normal form where asset references have been normalized + * + * This makes it possible to compare templates if all that's different between + * them is the hashes of the asset values. + */ + private canonicalizeTemplate(template: any, stackName: string, manifestDir: string): any { + const assetsSeen = new Set(); + const stringSubstitutions = new Array<[RegExp, string]>(); + + // Find assets via parameters (for LegacyStackSynthesizer) + const paramRe = /^AssetParameters([a-zA-Z0-9]{64})(S3Bucket|S3VersionKey|ArtifactHash)([a-zA-Z0-9]{8})$/; + for (const paramName of Object.keys(template?.Parameters || {})) { + const m = paramRe.exec(paramName); + if (!m) { continue; } + if (assetsSeen.has(m[1])) { continue; } + + assetsSeen.add(m[1]); + const ix = assetsSeen.size; + + // Full parameter reference + stringSubstitutions.push([ + new RegExp(`AssetParameters${m[1]}(S3Bucket|S3VersionKey|ArtifactHash)([a-zA-Z0-9]{8})`), + `Asset${ix}$1`, + ]); + // Substring asset hash reference + stringSubstitutions.push([ + new RegExp(`${m[1]}`), + `Asset${ix}Hash`, + ]); + } + + // find assets defined in the asset manifest + try { + const manifest = AssemblyManifestReader.fromPath(manifestDir); + const assets = manifest.getAssetIdsForStack(stackName); + assets.forEach(asset => { + if (!assetsSeen.has(asset)) { + assetsSeen.add(asset); + const ix = assetsSeen.size; + stringSubstitutions.push([ + new RegExp(asset), + `Asset${ix}$1`, + ]); + } + }); + } catch { + // if there is no asset manifest that is fine. + } + + // Substitute them out + return substitute(template); + + function substitute(what: any): any { + if (Array.isArray(what)) { + return what.map(substitute); + } + + if (typeof what === 'object' && what !== null) { + const ret: any = {}; + for (const [k, v] of Object.entries(what)) { + ret[stringSub(k)] = substitute(v); + } + return ret; + } + + if (typeof what === 'string') { + return stringSub(what); + } + + return what; + } + + function stringSub(x: string) { + for (const [re, replacement] of stringSubstitutions) { + x = x.replace(re, replacement); + } + return x; + } + } } class StringWritable extends Writable { diff --git a/packages/@aws-cdk/integ-runner/test/runner/private/cloud-assembly.test.ts b/packages/@aws-cdk/integ-runner/test/runner/private/cloud-assembly.test.ts index 77b6a2c7e6936..721e4cd520a66 100644 --- a/packages/@aws-cdk/integ-runner/test/runner/private/cloud-assembly.test.ts +++ b/packages/@aws-cdk/integ-runner/test/runner/private/cloud-assembly.test.ts @@ -287,7 +287,7 @@ describe('cloud assembly manifest reader', () => { test('can get assets from assembly manifest', () => { // WHEN const manifest = AssemblyManifestReader.fromFile(manifestFile); - const assets = manifest.getAssetsForStack('test-stack2'); + const assets = manifest.getAssetLocationsForStack('test-stack2'); // THEN expect(assets).toEqual([ diff --git a/packages/@aws-cdk/integ-runner/test/runner/snapshot-test-runner.test.ts b/packages/@aws-cdk/integ-runner/test/runner/snapshot-test-runner.test.ts index f5247bc390889..76ae2fb0f0176 100644 --- a/packages/@aws-cdk/integ-runner/test/runner/snapshot-test-runner.test.ts +++ b/packages/@aws-cdk/integ-runner/test/runner/snapshot-test-runner.test.ts @@ -136,6 +136,51 @@ describe('IntegTest runSnapshotTests', () => { }]); }); + test('dont diff new asset hashes', () => { + // WHEN + const integTest = new IntegSnapshotRunner({ + cdk: cdkMock.cdk, + test: new IntegTest({ + fileName: path.join(__dirname, '../test-data/xxxxx.test-with-new-assets-diff.js'), + discoveryRoot: 'test/test-data', + }), + integOutDir: 'test/test-data/cdk-integ.out.test-with-new-assets', + }); + const results = integTest.testSnapshot(); + expect(results.diagnostics).toEqual([]); + + // THEN + expect(synthFastMock).toHaveBeenCalledTimes(2); + expect(synthFastMock).toHaveBeenCalledWith({ + execCmd: ['node', 'xxxxx.test-with-new-assets-diff.js'], + env: expect.objectContaining({ + CDK_INTEG_ACCOUNT: '12345678', + CDK_INTEG_REGION: 'test-region', + }), + output: 'cdk-integ.out.test-with-new-assets', + }); + }); + + test('diff new asset hashes', () => { + // WHEN + const integTest = new IntegSnapshotRunner({ + cdk: cdkMock.cdk, + test: new IntegTest({ + fileName: path.join(__dirname, '../test-data/xxxxx.test-with-new-assets.js'), + discoveryRoot: 'test/test-data', + }), + integOutDir: 'test/test-data/cdk-integ.out.test-with-new-assets-diff', + }); + const results = integTest.testSnapshot(); + + // THEN + expect(results.diagnostics).toEqual(expect.arrayContaining([expect.objectContaining({ + reason: DiagnosticReason.SNAPSHOT_FAILED, + testName: integTest.testName, + message: expect.stringContaining('S3Key'), + })])); + }); + test('dont diff asset hashes', () => { // WHEN const integTest = new IntegSnapshotRunner({ @@ -146,9 +191,8 @@ describe('IntegTest runSnapshotTests', () => { }), integOutDir: 'test/test-data/test-with-snapshot-assets.integ.snapshot', }); - expect(() => { - integTest.testSnapshot(); - }).not.toThrow(); + const results = integTest.testSnapshot(); + expect(results.diagnostics).toEqual([]); // THEN expect(synthFastMock).toHaveBeenCalledTimes(2); diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets-diff/cdk.out b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets-diff/cdk.out new file mode 100644 index 0000000000000..2efc89439fab8 --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets-diff/cdk.out @@ -0,0 +1 @@ +{"version":"18.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets-diff/integ.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets-diff/integ.json new file mode 100644 index 0000000000000..c0acf5e475336 --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets-diff/integ.json @@ -0,0 +1,13 @@ +{ + "version": "v1.0.0", + "testCases": { + "xxxxx.test-with-new-assets": { + "stacks": ["test-stack"], + "stackUpdateWorkflow": false, + "diffAssets": true, + "allowDestroy": [ + "AWS::IAM::Role" + ] + } + } +} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets-diff/manifest.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets-diff/manifest.json new file mode 100644 index 0000000000000..131dfb43ec866 --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets-diff/manifest.json @@ -0,0 +1,43 @@ +{ + "version": "20.0.0", + "artifacts": { + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + }, + "metadata": {} + }, + "test-stack.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "test-stack.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "test-stack": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "test-stack.template.json", + "validateOnSynth": false + }, + "metadata": { + "/test-stack/MyFunction1/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyFunction1ServiceRole9852B06B" + } + ], + "/test-stack/MyFunction1/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyFunction12A744C2E" + } + ] + }, + "displayName": "test-stack" + } + } +} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets-diff/test-stack.assets.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets-diff/test-stack.assets.json new file mode 100644 index 0000000000000..04bcd2f5c1a4a --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets-diff/test-stack.assets.json @@ -0,0 +1,32 @@ +{ + "version": "17.0.0", + "files": { + "be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92825": { + "source": { + "path": "asset.be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824", + "packaging": "zip" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824.zip", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + }, + "cb05f22f001734dbadeb4f07d875c6ab8180f703346a8d66fca572a0e94c54a9": { + "source": { + "path": "test-stack.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "cb05f22f001734dbadeb4f07d875c6ab8180f703346a8d66fca572a0e94c54a9.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets-diff/test-stack.template.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets-diff/test-stack.template.json new file mode 100644 index 0000000000000..2beb6ac288dd2 --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets-diff/test-stack.template.json @@ -0,0 +1,54 @@ +{ + "Resources": { + "MyFunction1ServiceRole9852B06B": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "MyFunction12A744C2E": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Key": "be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92825.zip" + }, + "Role": { + "Fn::GetAtt": [ + "MyFunction1ServiceRole9852B06B", + "Arn" + ] + }, + "Handler": "index.handler", + "Runtime": "nodejs14.x" + }, + "DependsOn": [ + "MyFunction1ServiceRole9852B06B" + ] + } + } +} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets-diff/tree.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets-diff/tree.json new file mode 100644 index 0000000000000..b664bec74b37c --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets-diff/tree.json @@ -0,0 +1,114 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "@aws-cdk/core.Construct", + "version": "0.0.0" + } + }, + "test-stack": { + "id": "test-stack", + "path": "test-stack", + "children": { + "MyFunction1": { + "id": "MyFunction1", + "path": "test-stack/MyFunction1", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "test-stack/MyFunction1/ServiceRole", + "children": { + "Resource": { + "id": "Resource", + "path": "test-stack/MyFunction1/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "test-stack/MyFunction1/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "zipFile": "foo" + }, + "role": { + "Fn::GetAtt": [ + "MyFunction1ServiceRole9852B06B", + "Arn" + ] + }, + "handler": "index.handler", + "runtime": "nodejs14.x" + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-lambda.Function", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets/cdk.out b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets/cdk.out new file mode 100644 index 0000000000000..2efc89439fab8 --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets/cdk.out @@ -0,0 +1 @@ +{"version":"18.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets/integ.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets/integ.json new file mode 100644 index 0000000000000..d8b60d982deca --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets/integ.json @@ -0,0 +1,13 @@ +{ + "version": "v1.0.0", + "testCases": { + "xxxxx.test-with-new-assets": { + "stacks": ["test-stack"], + "stackUpdateWorkflow": false, + "diffAssets": false, + "allowDestroy": [ + "AWS::IAM::Role" + ] + } + } +} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets/manifest.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets/manifest.json new file mode 100644 index 0000000000000..131dfb43ec866 --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets/manifest.json @@ -0,0 +1,43 @@ +{ + "version": "20.0.0", + "artifacts": { + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + }, + "metadata": {} + }, + "test-stack.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "test-stack.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "test-stack": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "test-stack.template.json", + "validateOnSynth": false + }, + "metadata": { + "/test-stack/MyFunction1/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyFunction1ServiceRole9852B06B" + } + ], + "/test-stack/MyFunction1/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyFunction12A744C2E" + } + ] + }, + "displayName": "test-stack" + } + } +} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets/test-stack.assets.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets/test-stack.assets.json new file mode 100644 index 0000000000000..9fce39f0cb708 --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets/test-stack.assets.json @@ -0,0 +1,32 @@ +{ + "version": "17.0.0", + "files": { + "be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824": { + "source": { + "path": "asset.be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824", + "packaging": "zip" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824.zip", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + }, + "cb05f22f001734dbadeb4f07d875c6ab8180f703346a8d66fca572a0e94c54a9": { + "source": { + "path": "test-stack.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "cb05f22f001734dbadeb4f07d875c6ab8180f703346a8d66fca572a0e94c54a9.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets/test-stack.template.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets/test-stack.template.json new file mode 100644 index 0000000000000..fe60c3f20c5c3 --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets/test-stack.template.json @@ -0,0 +1,54 @@ +{ + "Resources": { + "MyFunction1ServiceRole9852B06B": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "MyFunction12A744C2E": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Key": "be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824.zip" + }, + "Role": { + "Fn::GetAtt": [ + "MyFunction1ServiceRole9852B06B", + "Arn" + ] + }, + "Handler": "index.handler", + "Runtime": "nodejs14.x" + }, + "DependsOn": [ + "MyFunction1ServiceRole9852B06B" + ] + } + } +} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets/tree.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets/tree.json new file mode 100644 index 0000000000000..b664bec74b37c --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-new-assets/tree.json @@ -0,0 +1,114 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "@aws-cdk/core.Construct", + "version": "0.0.0" + } + }, + "test-stack": { + "id": "test-stack", + "path": "test-stack", + "children": { + "MyFunction1": { + "id": "MyFunction1", + "path": "test-stack/MyFunction1", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "test-stack/MyFunction1/ServiceRole", + "children": { + "Resource": { + "id": "Resource", + "path": "test-stack/MyFunction1/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "test-stack/MyFunction1/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "zipFile": "foo" + }, + "role": { + "Fn::GetAtt": [ + "MyFunction1ServiceRole9852B06B", + "Arn" + ] + }, + "handler": "index.handler", + "runtime": "nodejs14.x" + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-lambda.Function", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/integ.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/integ.json index a2f390b4d7453..2cd7ddd429f8a 100644 --- a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/integ.json +++ b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/integ.json @@ -4,7 +4,7 @@ "xxxxx.test-with-snapshot-assets": { "stacks": ["test-stack"], "stackUpdateWorkflow": false, - "diffAssets": true, + "diffAssets": false, "hooks": { "preDeploy": ["echo \"preDeploy\""], "postDeploy": ["echo \"postDeploy\""], diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/asset.be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824/index.js b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/asset.be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824/index.js new file mode 100755 index 0000000000000..e69de29bb2d1d diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/cdk.out b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/cdk.out new file mode 100644 index 0000000000000..2efc89439fab8 --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"18.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/integ.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/integ.json new file mode 100644 index 0000000000000..c0acf5e475336 --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/integ.json @@ -0,0 +1,13 @@ +{ + "version": "v1.0.0", + "testCases": { + "xxxxx.test-with-new-assets": { + "stacks": ["test-stack"], + "stackUpdateWorkflow": false, + "diffAssets": true, + "allowDestroy": [ + "AWS::IAM::Role" + ] + } + } +} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/manifest.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/manifest.json new file mode 100644 index 0000000000000..131dfb43ec866 --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/manifest.json @@ -0,0 +1,43 @@ +{ + "version": "20.0.0", + "artifacts": { + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + }, + "metadata": {} + }, + "test-stack.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "test-stack.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "test-stack": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "test-stack.template.json", + "validateOnSynth": false + }, + "metadata": { + "/test-stack/MyFunction1/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyFunction1ServiceRole9852B06B" + } + ], + "/test-stack/MyFunction1/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyFunction12A744C2E" + } + ] + }, + "displayName": "test-stack" + } + } +} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/test-stack.assets.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/test-stack.assets.json new file mode 100644 index 0000000000000..04bcd2f5c1a4a --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/test-stack.assets.json @@ -0,0 +1,32 @@ +{ + "version": "17.0.0", + "files": { + "be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92825": { + "source": { + "path": "asset.be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824", + "packaging": "zip" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824.zip", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + }, + "cb05f22f001734dbadeb4f07d875c6ab8180f703346a8d66fca572a0e94c54a9": { + "source": { + "path": "test-stack.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "cb05f22f001734dbadeb4f07d875c6ab8180f703346a8d66fca572a0e94c54a9.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/test-stack.template.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/test-stack.template.json new file mode 100644 index 0000000000000..2beb6ac288dd2 --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/test-stack.template.json @@ -0,0 +1,54 @@ +{ + "Resources": { + "MyFunction1ServiceRole9852B06B": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "MyFunction12A744C2E": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Key": "be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92825.zip" + }, + "Role": { + "Fn::GetAtt": [ + "MyFunction1ServiceRole9852B06B", + "Arn" + ] + }, + "Handler": "index.handler", + "Runtime": "nodejs14.x" + }, + "DependsOn": [ + "MyFunction1ServiceRole9852B06B" + ] + } + } +} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/tree.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/tree.json new file mode 100644 index 0000000000000..b664bec74b37c --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets-diff.integ.snapshot/tree.json @@ -0,0 +1,114 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "@aws-cdk/core.Construct", + "version": "0.0.0" + } + }, + "test-stack": { + "id": "test-stack", + "path": "test-stack", + "children": { + "MyFunction1": { + "id": "MyFunction1", + "path": "test-stack/MyFunction1", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "test-stack/MyFunction1/ServiceRole", + "children": { + "Resource": { + "id": "Resource", + "path": "test-stack/MyFunction1/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "test-stack/MyFunction1/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "zipFile": "foo" + }, + "role": { + "Fn::GetAtt": [ + "MyFunction1ServiceRole9852B06B", + "Arn" + ] + }, + "handler": "index.handler", + "runtime": "nodejs14.x" + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-lambda.Function", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/asset.be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824/index.js b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/asset.be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824/index.js new file mode 100755 index 0000000000000..e69de29bb2d1d diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/cdk.out b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/cdk.out new file mode 100644 index 0000000000000..2efc89439fab8 --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"18.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/integ.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/integ.json new file mode 100644 index 0000000000000..c0acf5e475336 --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/integ.json @@ -0,0 +1,13 @@ +{ + "version": "v1.0.0", + "testCases": { + "xxxxx.test-with-new-assets": { + "stacks": ["test-stack"], + "stackUpdateWorkflow": false, + "diffAssets": true, + "allowDestroy": [ + "AWS::IAM::Role" + ] + } + } +} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/manifest.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/manifest.json new file mode 100644 index 0000000000000..131dfb43ec866 --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/manifest.json @@ -0,0 +1,43 @@ +{ + "version": "20.0.0", + "artifacts": { + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + }, + "metadata": {} + }, + "test-stack.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "test-stack.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "test-stack": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "test-stack.template.json", + "validateOnSynth": false + }, + "metadata": { + "/test-stack/MyFunction1/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyFunction1ServiceRole9852B06B" + } + ], + "/test-stack/MyFunction1/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyFunction12A744C2E" + } + ] + }, + "displayName": "test-stack" + } + } +} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/test-stack.assets.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/test-stack.assets.json new file mode 100644 index 0000000000000..9fce39f0cb708 --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/test-stack.assets.json @@ -0,0 +1,32 @@ +{ + "version": "17.0.0", + "files": { + "be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824": { + "source": { + "path": "asset.be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824", + "packaging": "zip" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824.zip", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + }, + "cb05f22f001734dbadeb4f07d875c6ab8180f703346a8d66fca572a0e94c54a9": { + "source": { + "path": "test-stack.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "cb05f22f001734dbadeb4f07d875c6ab8180f703346a8d66fca572a0e94c54a9.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/test-stack.template.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/test-stack.template.json new file mode 100644 index 0000000000000..fe60c3f20c5c3 --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/test-stack.template.json @@ -0,0 +1,54 @@ +{ + "Resources": { + "MyFunction1ServiceRole9852B06B": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "MyFunction12A744C2E": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Key": "be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824.zip" + }, + "Role": { + "Fn::GetAtt": [ + "MyFunction1ServiceRole9852B06B", + "Arn" + ] + }, + "Handler": "index.handler", + "Runtime": "nodejs14.x" + }, + "DependsOn": [ + "MyFunction1ServiceRole9852B06B" + ] + } + } +} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/tree.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/tree.json new file mode 100644 index 0000000000000..b664bec74b37c --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-new-assets.integ.snapshot/tree.json @@ -0,0 +1,114 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "@aws-cdk/core.Construct", + "version": "0.0.0" + } + }, + "test-stack": { + "id": "test-stack", + "path": "test-stack", + "children": { + "MyFunction1": { + "id": "MyFunction1", + "path": "test-stack/MyFunction1", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "test-stack/MyFunction1/ServiceRole", + "children": { + "Resource": { + "id": "Resource", + "path": "test-stack/MyFunction1/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "test-stack/MyFunction1/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "zipFile": "foo" + }, + "role": { + "Fn::GetAtt": [ + "MyFunction1ServiceRole9852B06B", + "Arn" + ] + }, + "handler": "index.handler", + "runtime": "nodejs14.x" + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-lambda.Function", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/integ.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/integ.json index 08782d8bed7d2..c602dbd383d72 100644 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/integ.json +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/integ.json @@ -4,7 +4,7 @@ "enableLookups": true, "xxxxx.test-with-snapshot-assets-diff": { "stacks": ["test-stack"], - "diffAssets": true, + "diffAssets": false, "allowDestroy": [ "AWS::IAM::Role" ] diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/integ.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/integ.json index dd229432f16b2..0b72458952056 100644 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/integ.json +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/integ.json @@ -4,7 +4,7 @@ "xxxxx.test-with-snapshot-assets": { "stacks": ["test-stack"], "stackUpdateWorkflow": false, - "diffAssets": true, + "diffAssets": false, "allowDestroy": [ "AWS::IAM::Role" ] diff --git a/packages/@aws-cdk/integ-runner/test/test-data/xxxxx.test-with-new-assets-diff.ts b/packages/@aws-cdk/integ-runner/test/test-data/xxxxx.test-with-new-assets-diff.ts new file mode 100644 index 0000000000000..e43a408f7b31c --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/xxxxx.test-with-new-assets-diff.ts @@ -0,0 +1 @@ +/// !cdk-integ test-stack diff --git a/packages/@aws-cdk/integ-runner/test/test-data/xxxxx.test-with-new-assets.ts b/packages/@aws-cdk/integ-runner/test/test-data/xxxxx.test-with-new-assets.ts new file mode 100644 index 0000000000000..e43a408f7b31c --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/xxxxx.test-with-new-assets.ts @@ -0,0 +1 @@ +/// !cdk-integ test-stack diff --git a/packages/@aws-cdk/integ-runner/test/workers/snapshot-worker.test.ts b/packages/@aws-cdk/integ-runner/test/workers/snapshot-worker.test.ts index 69afed10bdd17..015b53861b622 100644 --- a/packages/@aws-cdk/integ-runner/test/workers/snapshot-worker.test.ts +++ b/packages/@aws-cdk/integ-runner/test/workers/snapshot-worker.test.ts @@ -48,7 +48,7 @@ describe('Snapshot tests', () => { // WHEN jest.spyOn(child_process, 'spawnSync').mockRejectedValue; const test = { - fileName: path.join(directory, 'xxxxx.test-with-snapshot-assets.js'), + fileName: path.join(directory, 'xxxxx.test-with-snapshot-assets-diff.js'), discoveryRoot: directory, destructiveChanges: [], };