Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(CLI): synth displays "AssertDescription: CDK bootstrap stack version 6 required" #31092

Merged
merged 8 commits into from
Aug 17, 2024
Merged
Changes from 2 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
37 changes: 31 additions & 6 deletions packages/aws-cdk/lib/cdk-toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class CdkToolkit {

public async metadata(stackName: string, json: boolean) {
const stacks = await this.selectSingleStackByName(stackName);
data(serializeStructure(stacks.firstStack.manifest.metadata ?? {}, json));
printSerializedObject(stacks.firstStack.manifest.metadata ?? {}, json);
}

public async acknowledge(noticeId: string) {
Expand Down Expand Up @@ -632,7 +632,7 @@ export class CdkToolkit {
});

if (options.long && options.showDeps) {
data(serializeStructure(stacks, options.json ?? false));
printSerializedObject(stacks, options.json ?? false);
return 0;
}

Expand All @@ -646,7 +646,7 @@ export class CdkToolkit {
});
}

data(serializeStructure(stackDeps, options.json ?? false));
printSerializedObject(stackDeps, options.json ?? false);
return 0;
}

Expand All @@ -660,7 +660,7 @@ export class CdkToolkit {
environment: stack.environment,
});
}
data(serializeStructure(long, options.json ?? false));
printSerializedObject(long, options.json ?? false);
return 0;
}

Expand All @@ -687,7 +687,7 @@ export class CdkToolkit {
// if we have a single stack, print it to STDOUT
if (stacks.stackCount === 1) {
if (!quiet) {
data(serializeStructure(stacks.firstStack.template, json ?? false));
printSerializedObject(obscureTemplate(stacks.firstStack.template), json ?? false);
}
return undefined;
}
Expand All @@ -701,7 +701,7 @@ export class CdkToolkit {
// behind an environment variable.
const isIntegMode = process.env.CDK_INTEG_MODE === '1';
if (isIntegMode) {
data(serializeStructure(stacks.stackArtifacts.map(s => s.template), json ?? false));
printSerializedObject(stacks.stackArtifacts.map(s => obscureTemplate(s.template)), json ?? false);
}

// not outputting template to stdout, let's explain things to the user a little bit...
Expand Down Expand Up @@ -1045,6 +1045,13 @@ export class CdkToolkit {
}
}

/**
* Print a serialized object (YAML or JSON) to stdout.
*/
function printSerializedObject(obj: any, json: boolean) {
data(serializeStructure(obj, json));
}

export interface DiffOptions {
/**
* Stack names to diff
Expand Down Expand Up @@ -1526,3 +1533,21 @@ function buildParameterMap(parameters: {

return parameterMap;
}

/**
* Remove any template elements that we don't want to show users.
*/
function obscureTemplate(template: any = {}) {
if (template.Rules) {
// see https://github.com/aws/aws-cdk/issues/17942
if (template.Rules.CheckBootstrapVersion) {
if (Object.keys(template.Rules).length > 1) {
delete template.Rules.CheckBootstrapVersion;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought you had mentioned that the rules would only be deleted if the check bootstrap version was the only rules. Did I misinterpret that, or did we switch to always removing the bootstrap version check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention is to always remove the Rule, but to remove the entire Rules section if that is the only rule.

} else {
delete template.Rules;
}
}
}

return template;
}
Loading