rover icon indicating copy to clipboard operation
rover copied to clipboard

[Feature Request] Terragrunt Support

Open wouter-toppy opened this issue 2 years ago • 16 comments

Is it possible to implement Terragrunt support?

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

wouter-toppy avatar Sep 24 '21 09:09 wouter-toppy

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

bmaltais avatar Sep 24 '21 11:09 bmaltais

is terragrunt installed than?

Got this error:

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

wouter-toppy avatar Sep 24 '21 11:09 wouter-toppy

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.

bmaltais avatar Sep 24 '21 11:09 bmaltais

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

wouter-toppy avatar Sep 24 '21 11:09 wouter-toppy

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           = "[email protected]" -> 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.

bmaltais avatar Sep 24 '21 11:09 bmaltais

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

image

wouter-toppy avatar Sep 24 '21 11:09 wouter-toppy

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...

bmaltais avatar Sep 24 '21 11:09 bmaltais

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.

im2nguyen avatar Sep 24 '21 15:09 im2nguyen

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. :)

mustafa89 avatar Sep 24 '21 19:09 mustafa89

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?

im2nguyen avatar Sep 28 '21 09:09 im2nguyen

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 💡

angeloskaltsikis avatar Sep 29 '21 20:09 angeloskaltsikis

#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.

almoore avatar Sep 30 '21 23:09 almoore

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

im2nguyen avatar Sep 30 '21 23:09 im2nguyen

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

wouter-toppy avatar Oct 01 '21 11:10 wouter-toppy

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

im2nguyen avatar Oct 01 '21 14:10 im2nguyen

image

wouter-toppy avatar Oct 04 '21 05:10 wouter-toppy