im2nguyen / rover

Interactive Terraform visualization. State and configuration explorer.
MIT License
3.04k stars 181 forks source link

[Feature Request] Terragrunt Support #21

Open wouter-toppy opened 3 years ago

wouter-toppy commented 3 years ago

Is it possible to implement Terragrunt support?

We would like to generate a Visual for our Terragrunt infrastructure.

bmaltais commented 3 years ago

I sort of got it working... but the resulting visualisation does not correspond to the terragrunt plan output. To try it, call rover with the following syntax to test on your end:

rover -tfPath /usr/local/bin/terragrunt

wouter-toppy commented 3 years ago

is terragrunt installed than?

Got this error:

Unable to parse Plan: fork/exec /usr/local/bin/terragrunt: no such file or directory

bmaltais commented 3 years ago

This is where I have my terragrunt binaries on my linux distro. Your terragrunt binary might be elsewhere... especially if you use Windows. Adapt the path to your personal environment.

wouter-toppy commented 3 years ago

ah, you mean on your local PC. i was refering to the docker container. Ill check it, moment.

bmaltais commented 3 years ago

Here is an example of the visualisation output with terragrunt:

image

and here is the plan for it:

Terraform will perform the following actions:

  # azurerm_monitor_action_group.alert_email[0] will be destroyed
  - resource "azurerm_monitor_action_group" "alert_email" {
      - enabled             = true -> null
      - id                  = "/subscriptions/75eea6e9-de40-430f-886f-21a5eb5f150d/resourceGroups/ScDc-CIO_ESLZ_light_Management-rg/providers/microsoft.insights/actionGroups/Email Owners And Contributors" -> null
      - name                = "Email Owners And Contributors" -> null
      - resource_group_name = "ScDc-CIO_ESLZ_light_Management-rg" -> null
      - short_name          = "mailOwnCont" -> null
      - tags                = {} -> null

      - email_receiver {
          - email_address           = "test@test.com" -> null
          - name                    = "alert_email" -> null
          - use_common_alert_schema = false -> null
        }

      - timeouts {}
    }

  # azurerm_monitor_activity_log_alert.ActivityLogs_Alert[0] will be destroyed
  - resource "azurerm_monitor_activity_log_alert" "ActivityLogs_Alert" {
      - description         = "This alert will monitor changes on ActivityLogs Alert." -> null
      - enabled             = true -> null
      - id                  = "/subscriptions/75eea6e9-de40-430f-886f-21a5eb5f150d/resourceGroups/ScDc-CIO_ESLZ_light_Management-rg/providers/microsoft.insights/activityLogAlerts/ActivityLogs Alert" -> null
      - name                = "ActivityLogs Alert" -> null
      - resource_group_name = "ScDc-CIO_ESLZ_light_Management-rg" -> null
      - scopes              = [
          - "/subscriptions/75eea6e9-de40-430f-886f-21a5eb5f150d",
        ] -> null
      - tags                = {
          - "branch"            = "CIO"
          - "classification"    = "pbmm"
          - "cloudusageprofile" = "3"
          - "contact"           = "<some email>; <some email>; etc"
          - "costcentre"        = "566811"
          - "env"               = "dev"
          - "owner"             = "<some email>; <some email>; etc"
        } -> null

      - action {
          - action_group_id    = "/subscriptions/75eea6e9-de40-430f-886f-21a5eb5f150d/resourceGroups/ScDc-CIO_ESLZ_light_Management-rg/providers/microsoft.insights/actionGroups/Email Owners And Contributors" -> null
          - webhook_properties = {} -> null
        }

      - criteria {
          - category      = "Administrative" -> null
          - resource_type = "microsoft.insights/activitylogalerts" -> null
        }
    }

  # azurerm_monitor_activity_log_alert.Route_Tables_Alert[0] will be destroyed
  - resource "azurerm_monitor_activity_log_alert" "Route_Tables_Alert" {
      - description         = "This alert will monitor changes on Route Tables." -> null
      - enabled             = true -> null
      - id                  = "/subscriptions/75eea6e9-de40-430f-886f-21a5eb5f150d/resourceGroups/ScDc-CIO_ESLZ_light_Network-rg/providers/microsoft.insights/activityLogAlerts/Route Tables Alert" -> null
      - name                = "Route Tables Alert" -> null
      - resource_group_name = "ScDc-CIO_ESLZ_light_Network-rg" -> null
      - scopes              = [
          - "/subscriptions/75eea6e9-de40-430f-886f-21a5eb5f150d",
        ] -> null
      - tags                = {
          - "branch"            = "CIO"
          - "classification"    = "pbmm"
          - "cloudusageprofile" = "3"
          - "contact"           = "<some email>; <some email>; etc"
          - "costcentre"        = "566811"
          - "env"               = "dev"
          - "owner"             = "<some email>; <some email>; etc"
        } -> null

      - action {
          - action_group_id    = "/subscriptions/75eea6e9-de40-430f-886f-21a5eb5f150d/resourceGroups/ScDc-CIO_ESLZ_light_Management-rg/providers/microsoft.insights/actionGroups/Email Owners And Contributors" -> null
          - webhook_properties = {} -> null
        }

      - criteria {
          - category      = "Administrative" -> null
          - resource_type = "microsoft.network/routetables" -> null
        }
    }

  # azurerm_monitor_activity_log_alert.VNet_Alert[0] will be destroyed
  - resource "azurerm_monitor_activity_log_alert" "VNet_Alert" {
      - description         = "This alert will monitor changes on VNets." -> null
      - enabled             = true -> null
      - id                  = "/subscriptions/75eea6e9-de40-430f-886f-21a5eb5f150d/resourceGroups/ScDc-CIO_ESLZ_light_Network-rg/providers/microsoft.insights/activityLogAlerts/VNets Alert" -> null
      - name                = "VNets Alert" -> null
      - resource_group_name = "ScDc-CIO_ESLZ_light_Network-rg" -> null
      - scopes              = [
          - "/subscriptions/75eea6e9-de40-430f-886f-21a5eb5f150d",
        ] -> null
      - tags                = {
          - "branch"            = "CIO"
          - "classification"    = "pbmm"
          - "cloudusageprofile" = "3"
          - "contact"           = "<some email>; <some email>; etc"
          - "costcentre"        = "566811"
          - "env"               = "dev"
          - "owner"             = "<some email>; <some email>; etc"
        } -> null

      - action {
          - action_group_id    = "/subscriptions/75eea6e9-de40-430f-886f-21a5eb5f150d/resourceGroups/ScDc-CIO_ESLZ_light_Management-rg/providers/microsoft.insights/actionGroups/Email Owners And Contributors" -> null
          - webhook_properties = {} -> null
        }

      - criteria {
          - category      = "Administrative" -> null
          - resource_type = "microsoft.network/virtualnetworks" -> null
        }
    }

Plan: 0 to add, 0 to change, 4 to destroy.
wouter-toppy commented 3 years ago

Yes, Ive got this. but its not aligning the blocks correctly. any idea why?

image

bmaltais commented 3 years ago

I suspect rover is expecting pure terraform config files but when you use terragrunt it is not able to interpret them properly (terragrunt.hcl). I have a feeling rover will be hard to make work with terragrunt unless it can somehow leverage just the state file and the plan to do its work...

im2nguyen commented 3 years ago

Yep, what Rover does is parses the configuration and the plan to generate the visualization. Since there's no configuration for terragrunt, the visualization doesn't render correctly.

Will work on a version where it generates a visualization from plan only, which should solve this issue.

mustafa89 commented 3 years ago

Getting this with Terragrunt workflow.

docker run --rm -it -p 9000:9000 -v $(pwd):/src im2nguyen/rover
2021/09/24 19:02:13 Starting Rover...
2021/09/24 19:02:13 Initializing Terraform...
2021/09/24 19:02:14 Unable to parse Plan: configuration is invalid

Really awesome project. Look forward to the Terragrunt support. :)

im2nguyen commented 3 years ago

https://github.com/im2nguyen/rover/pull/32 will "address" this. This PR will enable you to generate a visualization from a plan file

$ rover -planPath "plan.out"

I'm unfamiliar with Terragrunt... but it seems like it's not recommended practice to generate a plan file with Terragrunt?

Do you think the -planPath flag will be enough to support Terragrunt? If not, what do you suggest we do?

angeloskaltsikis commented 3 years ago

https://github.com/im2nguyen/rover/pull/32 will "address" this. This PR will enable you to generate a visualization from a plan file

$ rover -planPath "plan.out"

I'm unfamiliar with Terragrunt... but it seems like it's not recommended practice to generate a plan file with Terragrunt?

Do you think the -planPath flag will be enough to support Terragrunt? If not, what do you suggest we do?

I wouldn't say that with Terragrunt it is not the best practice to generate plan files. (Maybe that's the case for run-all commands only but i am 100% sure that this is still possible).

BTW great idea with Rover 💡

almoore commented 3 years ago

32 will "address" this. This PR will enable you to generate a visualization from a plan file

$ rover -planPath "plan.out"

I'm unfamiliar with Terragrunt... but it seems like it's not recommended practice to generate a plan file with Terragrunt?

Do you think the -planPath flag will be enough to support Terragrunt? If not, what do you suggest we do?

I think that being able to run rover with a terraform/terragrunt output plan would be a good intermediary step for supporting other workflows.

im2nguyen commented 3 years ago

Can you test to see if the new planPath flag works for Terragrunt? Thanks!

wouter-toppy commented 3 years ago

ive got working it locally with terragrunt and a pregenerated plan. but its still the same. all elements stacked together in the diagram

im2nguyen commented 3 years ago

Hi @wouter-toppy, thanks for testing it out. Can you open up the browser console and c/p the error message? Thank you!

wouter-toppy commented 3 years ago

image