Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This patch brings the [fix](https://github.com/aws/aws-cdk/issues/29420) into the regression suite.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Skipping the test to fix issue https://github.com/aws/aws-cdk/issues/29420.
# cli-integ tests failing for the old tests with the new cli changes for list stacks.

cdk ls --show-dependencies --json
Original file line number Diff line number Diff line change
Expand Up @@ -886,10 +886,10 @@ integTest('cdk ls --show-dependencies --json', withDefaultFixture(async (fixture
id: 'list-stacks',
dependencies: [
{
id: 'liststacksDependentStack',
id: 'list-stacks/DependentStack',
dependencies: [
{
id: 'liststacksDependentStackInnerDependentStack',
id: 'list-stacks/DependentStack/InnerDependentStack',
dependencies: [],
},
],
Expand All @@ -900,11 +900,11 @@ integTest('cdk ls --show-dependencies --json', withDefaultFixture(async (fixture
id: 'list-multiple-dependent-stacks',
dependencies: [
{
id: 'listmultipledependentstacksDependentStack1',
id: 'list-multiple-dependent-stacks/DependentStack1',
dependencies: [],
},
{
id: 'listmultipledependentstacksDependentStack2',
id: 'list-multiple-dependent-stacks/DependentStack2',
dependencies: [],
},
],
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cdk/lib/list-stacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function listStacks(toolkit: CdkToolkit, options: ListStacksOptions

for (const stack of collectionOfStacks.stackArtifacts) {
const data: StackDetails = {
id: stack.id,
id: stack.displayName ?? stack.id,
name: stack.stackName,
environment: stack.environment,
dependencies: [],
Expand All @@ -82,7 +82,7 @@ export async function listStacks(toolkit: CdkToolkit, options: ListStacksOptions
}
} else {
data.dependencies.push({
id: depStack.stackArtifacts[0].id,
id: depStack.stackArtifacts[0].displayName ?? depStack.stackArtifacts[0].id,
dependencies: [],
});
}
Expand Down
92 changes: 90 additions & 2 deletions packages/aws-cdk/test/list-stacks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe('list', () => {
dependencies: [],
},
{
id: 'Test-Stack-B',
id: 'Test-Stack-A/Test-Stack-B',
name: 'Test-Stack-B',
environment: {
account: '123456789012',
Expand All @@ -185,7 +185,7 @@ describe('list', () => {
}]));
});

test('stacks with nested dependencies', async () => {
test('stacks with display names and have nested dependencies', async () => {
let cloudExecutable = new MockCloudExecutable({
stacks: [
MockStack.MOCK_STACK_A,
Expand All @@ -201,9 +201,84 @@ describe('list', () => {
],
},
depends: ['Test-Stack-A'],
displayName: 'Test-Stack-A/Test-Stack-B',
},
{
stackName: 'Test-Stack-C',
template: { Resources: { TemplateName: 'Test-Stack-C' } },
env: 'aws://123456789012/bermuda-triangle-1',
metadata: {
'/Test-Stack-C': [
{
type: cxschema.ArtifactMetadataEntryType.STACK_TAGS,
},
],
},
depends: ['Test-Stack-B'],
displayName: 'Test-Stack-A/Test-Stack-B/Test-Stack-C',
},
],
});

// GIVEN
const toolkit = new CdkToolkit({
cloudExecutable,
configuration: cloudExecutable.configuration,
sdkProvider: cloudExecutable.sdkProvider,
deployments: cloudFormation,
});

// WHEN
const workflow = await listStacks( toolkit, { selectors: ['Test-Stack-A', 'Test-Stack-A/Test-Stack-B', 'Test-Stack-A/Test-Stack-B/Test-Stack-C'] });

// THEN
expect(JSON.stringify(workflow)).toEqual(JSON.stringify([{
id: 'Test-Stack-A',
name: 'Test-Stack-A',
environment: {
account: '123456789012',
region: 'bermuda-triangle-1',
name: 'aws://123456789012/bermuda-triangle-1',
},
dependencies: [],
},
{
id: 'Test-Stack-A/Test-Stack-B',
name: 'Test-Stack-B',
environment: {
account: '123456789012',
region: 'bermuda-triangle-1',
name: 'aws://123456789012/bermuda-triangle-1',
},
dependencies: [{
id: 'Test-Stack-A',
dependencies: [],
}],
},
{
id: 'Test-Stack-A/Test-Stack-B/Test-Stack-C',
name: 'Test-Stack-C',
environment: {
account: '123456789012',
region: 'bermuda-triangle-1',
name: 'aws://123456789012/bermuda-triangle-1',
},
dependencies: [{
id: 'Test-Stack-A/Test-Stack-B',
dependencies: [{
id: 'Test-Stack-A',
dependencies: [],
}],
}],
}]));
});

test('stacks with nested dependencies', async () => {
let cloudExecutable = new MockCloudExecutable({
stacks: [
MockStack.MOCK_STACK_A,
{
stackName: 'Test-Stack-B',
template: { Resources: { TemplateName: 'Test-Stack-B' } },
env: 'aws://123456789012/bermuda-triangle-1',
metadata: {
Expand All @@ -213,6 +288,19 @@ describe('list', () => {
},
],
},
depends: ['Test-Stack-A'],
},
{
stackName: 'Test-Stack-C',
template: { Resources: { TemplateName: 'Test-Stack-C' } },
env: 'aws://123456789012/bermuda-triangle-1',
metadata: {
'/Test-Stack-C': [
{
type: cxschema.ArtifactMetadataEntryType.STACK_TAGS,
},
],
},
depends: ['Test-Stack-B'],
},
],
Expand Down