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

diff ui: replace is as dangerous as destroy - so should be in red #1458

Closed
ranguard opened this issue Dec 31, 2018 · 1 comment · Fixed by #1542
Closed

diff ui: replace is as dangerous as destroy - so should be in red #1458

ranguard opened this issue Dec 31, 2018 · 1 comment · Fixed by #1542
Labels
feature-request A feature should be added or improved. package/tools Related to AWS CDK Tools or CLI

Comments

@ranguard
Copy link
Contributor

ranguard commented Dec 31, 2018

Adding an attribute to Cognito user group destroys the old one (with manually added users) with no warning..

Diff show's replace against the top level, but that's not as clear as when I remove an attribute and it has destroy in red!

I didn't realise it was replacing the whole thing, not just the schema change I'd made.. maybe : change it to replace (e.g. destroy/create) on the diff output? and have it in red?

@rix0rrr rix0rrr added feature-request A feature should be added or improved. package/tools Related to AWS CDK Tools or CLI labels Jan 2, 2019
@rix0rrr
Copy link
Contributor

rix0rrr commented Jan 2, 2019

Yes, that seems appropriate. Thanks for the report.

rix0rrr added a commit that referenced this issue Jan 16, 2019
Contains the following changes:

- Print table to STDOUT instead of STDERR. This ensures the diff output and the "confirm (y/n)" prompt that follows it don't interleave on the terminal, degrading readability.
- Control table width to not exceed the terminal width, so that it doesn't wrap and lead to a mess of lines.
- Switch back to the new version of the `table` library (instead of `cli-table`) which now has in-cell newline support, to get rid of the rendering bugs in `cli-table` that would occasionally eat newlines.
- Render resource `replace` impact as red instead of yellow, to indicate that data loss will be happening here (fixes #1458).
- Change replacement diffing in order to not trigger IAM changes dialog (fixes #1495).
- Print a message instead of an empty table if 'cdk context' has no information in it (fixes #1549).

Explanation: 

We used to modify the new target template in place, causing changes to
the logical ids of replaced resources, which would trigger downstream
changes, which would further trigger potential downstream replacements, etc. 

This would properly calculate the set of impacted resources, but would also lead to the modified logical ID popping up in the IAM diff, which was not desirable.

In this change, we do the same processing but we throw away the
template after all changes have been propagated, and only copy
the resultant property *statuses* onto the diff object that gets
returned to the user. This leads to the same displayed result
without the changes to the template actually propagating.

In the course of this modification, the diff classes have been changed
to also have objects in places of resources and properties that
didn't actually change (so that they could be modified in-place),
and diff objects have a boolean telling whether they are actual
changes or not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants