-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Feature Programmatic Inspection of Diff #679
Comments
That's an awesome idea. At the minimum, perhaps we can just expose a |
Great idea and quick to get some feedback with |
We would very much like this. Actually, just in general, we would like to do |
Would greatly benefit from this as well. Terraform has a terraform show command which is super useful. Eg _terraform show -json tfplan.binary > tfplan.json _ I used the output to detect if there were any changes in RDS for example and create a snapshot. Might also help integrate with other tools such as OPA |
I've been wanting this too and have devised two potential solutions (barring first class support from CDK):
I favour 1 as it provides a more complete answer. In 2, we are comparing templates. What this doesn't tell you is if any resources will be replaced - there are some scenarios where resource replacement is undesired. The change set includes this information, in addition to the cause (some of which is bizarre, such as security group description changes yielding replacement!). To add a bit more context, my use case is wanting to convert a YAML defined stack into a CDK stack. The best process for doing this that I've seen is described here:
I'm wanting to add a step between 2 and 3: perform a diff of the now CDK defined stack and the running infrastructure. If the diff is 0, then it is safe to deploy and continue to step 3. Would love to hear if the AWS team have more thoughts on this. |
Hey @akash1810 , a few minor points:
Hope this helps! Thanks, |
Thanks for the response.
Ah yes! I am using
From what I understand, the The questions I'm looking to answer during a YAML to CDK migration are:
Additionally, I'd ask these questions on each iteration within step 3. AFAICT only change sets can provide complete answers here, so adding the |
But isn't the idea to include the template, run the diff, see if there are any differences - if there are, fix and repeat, if not, you are done? Migration should be a one-time thing, not something that needs to be done constantly. |
Not quite in our use-case. The ambition is to stop using YAML entirely, meaning "done" is achieved when each YAML resource has been replaced by a CDK construct/pattern and the YAML file has been deleted. CDK is opinionated. The way it, for example, grants access to a bucket doesn't necessarily match the way access was granted in the YAML template. Whilst we could create a custom CDK construct that matches the YAML version, using the CDK provided policy is easier to maintain (read less code!). Consequently, we have found it simplest, safest and easiest to follow and review changes, when a single resource is moved at a time. This means our cycle is:
As described above, comparing templates provides a limited amount of confidence - only at runtime do you know for certain if a particular change would result in a running resource being updated or replaced. (You don't want stateful resources such as databases, load balancers or DNS being unintentionally replaced). More context
CDK directly solves these two problems (and more!). We're building a library of components and patterns that encode our best practices. When best practice evolves, we publish a new version of the library and update downstream repository's Summary |
@akash1810 I wonder if you realize that Here's some example output:
So maybe you can simplify the cycle? (I assume you've already completed step 1, and have the template included in your CDK code, and deployed with the include)
Does this make sense? |
Oh gosh, you're totally right! I've just performed a YAML to CDK migration using totally vanilla AWS CDK and JSON output from Thank you for your patience @skinny85 ! |
This would really help with building approval workflows. +1 for |
This issue has received a significant amount of attention so we are automatically upgrading its priority. A member of the community will see the re-prioritization and provide an update on the issue. |
Hi team, This will be an important feature to include. We are currently leveraging CDK Deploy through GHA, and we like to include custom checks based on the results of the DIFF. With the current logs of the CDK Diff, it is very hard to parse. JSON, YAML, or any machine-readable format will be fine. |
How can it be that this capability hasn't progressed in 5 years |
We will handle it as part of aws/aws-cdk-rfcs#300 |
|
The Diff operation is very useful. Users may want to control or conditionally apply a ChangeSet based on the Diff information. However, we need to expose that information to an API.
For example, if I have a rolling update type of ec2 deployment a diff that replaces a Launch Configuration is expected and the deployment should proceed. However, a diff that replaces a subnet is likely not safe and should require a human review. There are many use cases like this that become available with programmatic access to the diff results.
The text was updated successfully, but these errors were encountered: