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

visualization tfplan created outside tftui #62

Open
Mykhailo-Roit opened this issue Mar 12, 2024 · 4 comments
Open

visualization tfplan created outside tftui #62

Mykhailo-Roit opened this issue Mar 12, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@Mykhailo-Roit
Copy link

Does it possible to visualization tfplan created outside tftui (e.g. by terragrunt with extra options like several dynamic generated links to vars files)?

@idoavrah
Copy link
Owner

idoavrah commented Mar 12, 2024

Hi Mykhailo,

I'm not a terragrunt user myself, so I'll need more input.

  1. Does the plan output look exactly like a standard terraform plan, so that it'll parse the same way?

  2. Can you give me an example of such a terragrunt command? Maybe I'll add the option to manually edit the plan command on-screen, or get it from an environment variable / command parameter, etc.

@Mykhailo-Roit
Copy link
Author

Hi @idoavrah
terragrunt is a wrapper for a terraform. It only makes easy terraform execution.
Terragrunt as terraform wrapper generate plan:
terragrunt plan -out tfplan can execute command like this terraform plan -var-file=../configs/identity-prd.tfvars -var-file=../configs/resources-prd.tfvars -var-file=../configs/subnets-prd.tfvars -out tfplan

So you can use only terraform to generate tfplan file
terraform plan -out tfplan

FYI my today pain is analyze a huge list after terraform plan: "Plan: 476 to add, 0 to change, 38 to destroy."

@idoavrah
Copy link
Owner

I can't use an existing plan file, because I'm parsing the OUTPUT text, not the binary file itself.

Is the only difference between a "regular" plan command and the one you've written is the number of var-files? If I add support for multiple varfiles, will it suffice? (assuming you're running terragrunt as the executable).

@Mykhailo-Roit
Copy link
Author

Mykhailo-Roit commented Mar 13, 2024

  1. I can run terraform show tfplan -no-color >tfplan.txt to convert plan to the plain text format or generate json using terraform show -json tfplan > tfplan.json. This is not a problem

  2. What terraform command do you use for getting plan to analyze?

  3. I'm parsing the OUTPUT text, not the binary file itself.

But here I see that you use binary format https://github.com/idoavrah/terraform-tui/blob/main/tftui/plan.py#L36

  1. Is the only difference between a "regular" plan command and the one you've written is the number of var-files?

yes, but names for these vars file generated based on execution directory name
Here part of the terragrunt config with generating var-file names

    arguments = [
      "-var-file=./resources-${local.env}.json",
      "-var-file=./subnets-${local.env}.json",
      "-var-file=./../tf-configs/${local.zone}/terraform-${local.env}.tfvars"
    ]

@idoavrah idoavrah added the enhancement New feature or request label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants