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

add the ability to run terraform plan only #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

myjaffoo
Copy link

@myjaffoo myjaffoo commented Mar 8, 2022

No description provided.

@isaaguilar
Copy link
Collaborator

Thanks @myjaffoo, this is cool! I do have a tiny issue with a "dry run" which I'll explain:

One of the reasons I love terraform plan is the fact that what you see is what you get. However, that plan is only guaranteed if you apply that same "plan.out". If dry run is set, a plan is shown. The next time dry run is not set, TFO will generate a new plan and apply it. And unfortunately, there could have been changes to the targets which means the plan might look different than before and it will be applied anyway.

This brings up a good conversation. The way the TFO volumeMount is set, it keeps all the plans in unique directories. For instance:

  1. Generation 1 (ie a brand new TFO k8s-resource created) will store the plan in $HOME/generations/1/main/plan.out.
  2. When changes are made to the TFO k8s-resource, generation 2 will store the plan in $HOME/generations/2/main/plan.out.

One could be clever store the last successful "dry run" generation in "$HOME/dryrun.index. We can make the following assumptions to make use of this file. The dryrun.index file contains a single line and keeps a single index. But then how does the user tell TFO that the next run should consume the plan from the dry-run? I haven't given much thought to this yet.

My initial thoughts before this PR was planning on using a "postPlanScript" to pause TFO. The script would accept some event (that I also haven't determined) to continue or just error out which stops the execution.

I'm going to brew on this PR for a while. If you think of a good way to use the dry-run's plan.out so a new plan isn't generated, I'd love to hear from you.

Maybe something like

...
kind: terraform
spec:
  plan: "DryRun" 
  #plan:  "UseDryRun" # looks for `dryrun.index` 
  #plan: "" #  when not matching above, or null, defaults to generate plan and apply

I'm not sold on my ideas for this lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants