Giter Site home page Giter Site logo

im2nguyen / rover Goto Github PK

View Code? Open in Web Editor NEW
2.9K 28.0 169.0 5.78 MB

Interactive Terraform visualization. State and configuration explorer.

License: MIT License

HCL 2.05% Go 52.46% JavaScript 0.38% HTML 0.70% CSS 0.28% Vue 43.02% Dockerfile 1.11%
terraform visualization interactive-visualizations diagram

rover's Introduction

Rover - Terraform Visualizer

Rover is a Terraform visualizer.

In order to do this, Rover:

  1. generates a plan file and parses the configuration in the root directory or uses a provided plan.
  2. parses the plan and configuration files to generate three items: the resource overview (rso), the resource map (map), and the resource graph (graph).
  3. consumes the rso, map, and graph to generate an interactive configuration and state visualization hosts on 0.0.0.0:9000.

Feedback (via issues) and pull requests are appreciated!

Rover Screenshot

Quickstart

The fastest way to get up and running with Rover is through Docker.

Run the following command in any Terraform workspace to generate a visualization. This command copies all the files in your current directory to the Rover container and exposes port :9000.

$ docker run --rm -it -p 9000:9000 -v $(pwd):/src im2nguyen/rover
2021/07/02 06:46:23 Starting Rover...
2021/07/02 06:46:23 Initializing Terraform...
2021/07/02 06:46:24 Generating plan...
2021/07/02 06:46:25 Parsing configuration...
2021/07/02 06:46:25 Generating resource overview...
2021/07/02 06:46:25 Generating resource map...
2021/07/02 06:46:25 Generating resource graph...
2021/07/02 06:46:25 Done generating assets.
2021/07/02 06:46:25 Rover is running on 0.0.0.0:9000

Once Rover runs on 0.0.0.0:9000, navigate to it to find the visualization!

Run on Terraform plan file

Use -planJSONPath to start Rover on Terraform plan file. The plan.json file should be in Linux version - Unix (LF), UTF-8.

First, generate the plan file in JSON format.

$ terraform plan -out plan.out
$ terraform show -json plan.out > plan.json

Then, run Rover on it.

$ docker run --rm -it -p 9000:9000 -v $(pwd)/plan.json:/src/plan.json im2nguyen/rover:latest -planJSONPath=plan.json

Standalone mode

Standalone mode generates a rover.zip file containing all the static assets.

$ docker run --rm -it -p 9000:9000 -v "$(pwd):/src" im2nguyen/rover -standalone true

After all the assets are generated, unzip rover.zip and open rover/index.html in your favourite web browser.

Set environment variables

Use --env or --env-file to set environment variables in the Docker container. For example, you can save your AWS credentials to a .env file.

$ printenv | grep "AWS" > .env

Then, add it as environment variables to your Docker container with --env-file.

$ docker run --rm -it -p 9000:9000 -v "$(pwd):/src" --env-file ./.env im2nguyen/rover

Define tfbackend, tfvars and Terraform variables

Use -tfBackendConfig to define backend config files and -tfVarsFile or -tfVar to define variables. For example, you can run the following in the example/random-test directory to overload variables.

$ docker run --rm -it -p 9000:9000 -v "$(pwd):/src" im2nguyen/rover -tfBackendConfig test.tfbackend -tfVarsFile test.tfvars -tfVar max_length=4

Image generation

Use -genImage to generate and save the visualization as a SVG image.

$ docker run --rm -it  -v "$(pwd):/src" im2nguyen/rover -genImage true

Installation

You can download Rover binary specific to your system by visiting the Releases page. Download the binary, unzip, then move rover into your PATH.

Build from source

You can build Rover manually by cloning this repository, then building the frontend and compiling the binary. It requires Go v1.21+ and npm.

Build frontend

First, navigate to the ui.

$ cd ui

Then, install the dependencies.

$ npm install

Finally, build the frontend.

$ npm run build

Compile binary

Navigate to the root directory.

$ cd ..

Compile and install the binary. Alternatively, you can use go build and move the binary into your PATH.

$ go install

Build Docker image

First, compile the binary for linux/amd64.

$ env GOOS=linux GOARCH=amd64 go build .

Then, build the Docker image.

$ docker build . -t im2nguyen/rover --no-cache

Basic usage

This repository contains two examples of Terraform configurations in example.

Navigate into random-test example configuration. This directory contains configuration that showcases a wide variety of features common in Terraform (modules, count, output, locals, etc) with the random provider.

$ cd example/random-test

Run Rover. Rover will start running in the current directory and assume the Terraform binary lives in /usr/local/bin/terraform by default.

$ rover
2021/06/23 22:51:27 Starting Rover...
2021/06/23 22:51:27 Initializing Terraform...
2021/06/23 22:51:28 Generating plan...
2021/06/23 22:51:28 Parsing configuration...
2021/06/23 22:51:28 Generating resource overview...
2021/06/23 22:51:28 Generating resource map...
2021/06/23 22:51:28 Generating resource graph...
2021/06/23 22:51:28 Done generating assets.
2021/06/23 22:51:28 Rover is running on 0.0.0.0:9000

You can specify the working directory (where your configuration is living) and the Terraform binary location using flags.

$ rover -workingDir "example/eks-cluster" -tfPath "/Users/dos/terraform"

Once Rover runs on 0.0.0.0:9000, navigate to it to find the visualization!

rover's People

Contributors

aathith avatar alisajid avatar chenrui333 avatar eugenmayer avatar im2nguyen avatar jackflukinger avatar jessfdm-codes avatar palmobar avatar severeone avatar sujithq avatar tenzer avatar vladdoster avatar xide avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rover's Issues

remote state s3

Hi,

I keep the remote-state on an s3 bucket. When I try to run the docker command it gives

2021/10/09 23:09:49 Starting Rover...
2021/10/09 23:09:49 Using provided plan...
2021/10/09 23:09:50 Unable to parse Plan: Unable to read Plan (/src/tfplan): exit status 1

Error: error configuring S3 Backend: no valid credential sources for S3 Backend found.

commands
terraform plan -var-file=qa-4.tfvars -out=tfplan -->no-error
terraform graph | dot -Tsvg > graph.svg --> no-error

docker run --rm -it -p 9000:9000 -v $path:/src im2nguyen/rover -planPath tfplan -->Error: error configuring S3 Backend: no valid credential sources for S3 Backend found`

passing the credentials does not solve the problem.

cat .env
access_key=sdfsd
secret_key=asdsdf

or

cat .env
aws_access_key_id=sdfsdf
aws_secret_access_key=sdfsdf

docker run --rm -it -p 9000:9000 -v $path:/src --env-file ./.env im2nguyen/rover -planPath tfplan -->Error: error configuring S3 Backend: no valid credential sources for S3 Backend found`

Does rover support remote state?

How can I use rover when module sources are in custom locations

For example I have the following folder structure

./../../../
├── README.md
├── modules
│   └── vnet
├── products
│   ├── product1
│   │   ├── main.tf
│   │   ├── variables.tf
│   │   ├── outputs.tf
│   ├── product2
│   │   ├── main.tf
│   │   ├── variables.tf
│   │   ├── outputs.tf

Is there any way where I can run rover to consume the modules from the "modules" directory and initialize terraform from "product1" folder?

Attribute dependencies cause graph rendering to crash

Hello !

I am tying to use your project, however when the diagram is generated, resources are located at the same coordinates, and i have to move them manually in order to see what it looks like.
The project i am working on have more than 200 nodes to display, it is very cumberstone to move around manually each time.
This issue happens both on live and standalone modes (generated .png for standalone looks exactly likt the first example below)

When i look at the console logs of the browser, it seems that the rendering is interrupted by an exception:

Uncaught (in promise) Error: Can not create edge `output.gcp_sa_report_email->google_service_account.sa_report.email` with nonexistant target `google_service_account.sa_report.email`
    Pe vue-cytoscape.common.js:2465
    restore vue-cytoscape.common.js:14039
    Xe vue-cytoscape.common.js:2877
    add vue-cytoscape.common.js:14474
    renderGraph Graph.vue:336
    renderGraph Graph.vue:332
    mounted Graph.vue:501
    promise callback*mounted Graph.vue:499
    VueJS 11
    56d7 main.js:13
    Webpack 6
vue-cytoscape.common.js:2465:8
    Pe vue-cytoscape.common.js:2465
    restore vue-cytoscape.common.js:14039
    Xe vue-cytoscape.common.js:2877
    add vue-cytoscape.common.js:14474
    renderGraph Graph.vue:336
    forEach self-hosted:205
    renderGraph Graph.vue:332
    renderGraph self-hosted:1175
    mounted Graph.vue:501
    (Async: promise callback)
    mounted Graph.vue:499
    VueJS 11
    56d7 main.js:13
    Webpack 6

This happens because google_service_account.sa_report.email is not present in the nodes array fetched from http://localhost:9000/api/graph. However, the google_service_account.sa_report is indeed present in nodes :

        {
            "data": {
                "id": "google_service_account.sa_report",
                "label": "sa_report",
                "type": "resource",
                "parent": "google_service_account",
                "parentColor": "white",
                "change": "no-op"
            },
            "classes": "resource-name no-op"
        },

The .email is a valid field exposed by the google_service_account resource: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_service_account#attributes-reference

Therefore, it seems like the graph rendering / generation does not take into account implicit dependencies based on resources attributes.

I belive a quick fix might be to sanitize the JSON graph in the API at generation with the following pseudocode heuristic:

FOR node in nodes
  FOR edge in node
    WHILE !nodes[edge.target]
      IF edge.target == "": return error
      trim rightmost part by splitting at "."

Let me know if you are open to a pull request fixing the issue with this implementation. If it looks good for you, i'll be happy to have a look at it.

Additional informations

Browsers

  • Mozilla Firefox 91.0
  • Chromium 92.0.4515.131 Arch Linux

Misc

  • Docker image used: sha256:247418191f414ba592c236db9f5dceb9a36eb090b89902283f7e35ef34eae185
  • Script used:
#!/usr/bin/env bash

set -eu

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
TERRAFORM_DIR="${DIR}/terraform"


vfile=$(mktemp)

# JSON -> KV variables
cat ${DIR}/config/dev.tfvars.json | \
  jq -r '. as $in | keys[] | [.]+["=\""]+[$in[.]]+["\""] | map(tostring) | add' > \
  $vfile

docker run \
  --rm \
  -it \
  --entrypoint sh \
  -p 9000:9000 \
  -e AWS_PROFILE="${AWS_PROFILE:-default}" \
  -e AWS_DEFAULT_REGION=us-east-1 \
  -v ${HOME}/.aws:/root/.aws:ro \
  -v "${vfile}:/vars:ro" \
  -v ${TERRAFORM_DIR}:/src \
  im2nguyen/rover \
  -c "apk add bash jq curl; \
  /bin/rover \
  -tfVar "stage=dev" \
  -tfVarsFile /vars"

Display before move

https://i.ibb.co/0fgZZCG/before-move.png

Display after move

https://i.ibb.co/hgmzrfB/after-move.png

Add documentation for new features/flags

Would be nice to also include:

  • Common use cases and rover commands
  • A full list of flags (potentially short flags? for example, --standalone is -s)
  • A website with an interactive demo of the visualization

Graph items are overlapping each other

Hi,
As said before me, it's a cool project, I hope it will work for me as well (:

My Env:

  • rover_0.1.3_windows_amd64
  • Terraform v1.0.10
  • azurerm v2.84.0

My CLI:

terraform init
terraform plan -out tfplan
rover -tfPath "C:\Program Files\terraform\terraform.exe"

I applied the Rover my full infra project including ~26 resources and the graph items were overlapping each other like a stack.

I then tried to use a simpler infra with only 3 resources, and it also had all the items one above the other

Is there an issue there or am I doing something wrong?

image

Rover looks for Terraform in specific location

Startup logs:

2021/10/04 09:17:50 Unable to parse Plan: fork/exec /usr/local/bin/terraform: no such file or directory

Now my Terraform is located in another location as it is set up to easily upgrade per user. Is there a way to override this?

[Feature Request] A way to create the PNG only.

Hi,

Our usecase is to update the documentation with a static image only.
So ideally the rover would create the png and we can archive it in our gitlab CI pipeline.

Ive tried with the static assets zip file but it does no appear to be included.

Interactive console is not required.

Use predefined TF plan for visualization

Hi. Thanks for developing this tool. I am not able to run the tool as it tries to generate the TF plan but my configuration uses symlinked files and environment variables to generate the plan. Could you support loading the details directly from a specified plan file instead of generating it on the fly?

terraform modules in relative subdirectories

Hi,
we do have the terraform modules relative to the environment related files. Is it possible to use rover with this setup?
/env/env_name/main.tf
/env/env_name/state.conf ... configuration.auto.tfvars.... etc
/terraform_modules/mod1
/terraform_modules/mod2

Where e.g. main.tf points to module ../../terraform_modules/module1

Thanks

[feature] visualizing the state file

Instead of just relying on diffs, would it make sense to supply a state backend directly and visualize the infra structure? I see other issues related to TF Cloud integration. I think it would be cool to visualize a workspace.

Update docker-image to terraform 1.1.2

Not a big deal, could you just retrigger / reparam the CI to use terraform 1.1.2?

If this is a critical update due to the minor bumb, could you then just user im2nguyen/rover:1.1 for the time being?

Doing this locally right now

docker build --build-arg=TF_VERSION=1.1.2 . -t im2nguyen/rover

Generate standalone html

It would be very useful to be able to generate the visualisation in a format that can be generated as part of a build pipeline triggered by a pull request or other terraform automated workflows. These situations cant leave servers up and running in order to browse to the visualisation, so in a nutshell we need standalone "archiving" versions of the visualisations in these situations.

It can be as simple as generating a zipped up folder full of HTML/CSS/JS, but having some kind of standalone archivable output would be fantastic.

Hangs with "Initializing Terraform..." (please introduce verbose logging option)

I tried both Linux and Windows versions of rover 0.2.2 amd64, and they are getting stuck and freezing at Initializing Terraform.... It appears frozen for a very long time, and I have no idea what it is doing. The usual output from terraform plan is silenced when it's run through rover and I couldn't find any option to enable verbose logging.

I have to press Ctrl+C to kill it. Note that I'm using the executable directly, and not using the Docker image.

How can I run rover while passing tfvars locally

Hello,

Very excited to try this out. I have downloaded the file locally in mac and trying to run from root of TF, how can I pass *.tfvars file when running rover?

Looks like there is option for passing some kind of config but did not see example of how pass this.

Appreciate suggestions on this.

Thanks

[Feature Request] How can rover use an already generated plan ?

Thank you for this great tool!
It is really useful for a 4-eye plan checking.
But it will be really cool to be able to use rover directly with an already existing plan file (json or not) since some organization (as mine) are using some automation and abstraction stuff to generate plans and then apply them.
So as a for eye checking it will be very interesting.

Cheers :)

Versions number do not match

Hi.

The version number for the release and for the output of -version for the v0.2.2 release do not match.

$ cat rover_0.2.2_SHA256SUMS 
0338d32703e19ca647d5eb1193b79f530b8481fa30ef3863221a5b640814520b  rover_0.2.2_freebsd_amd64.zip
0a87f7f21a47ee9843056cb87ba93f4376f67431b370177dea1c6a4087147648  rover_0.2.2_windows_amd64.zip
18e60561db8c5c3b5ffb5f7763e86463fd72cdba0970070a9e38082b90b40aa3  rover_0.2.2_freebsd_386.zip
1aab2f4a45ffc1d3cc8bcd0e390f7460b5b7ef6bdb31d7445aca6acb5df8a668  rover_0.2.2_darwin_amd64.zip
25b1e9dbe2dfb2cafdd63a11e7a6cf8fdfc71dbe720403947b8b6e0a8203ae4e  rover_0.2.2_linux_arm64.zip
28de7ed9da7359124c1fa4a57154a6aeb7aaeee4d54fc3812f06a505425adb89  rover_0.2.2_freebsd_arm64.zip
4128aee148b1c1a0f81e7661672b852145abbaf95853c14b55b92201f060f8c3  rover_0.2.2_linux_386.zip
4c96041ff15f1c476f5f13942b43ea33b26740ddcd54c184eaae66fe6a4e2453  rover_0.2.2_linux_amd64.zip
511e955aac40f0590d936aeef92867122cfe60d7d1cf24283761a4a3aeaefdfb  rover_0.2.2_windows_arm.zip
6b7a7882dde99e3af22c4c6b487db62cf8aa99d859af3c0138129f1fe11ded72  rover_0.2.2_windows_386.zip
77cdc506721c2f961908a3aca0fcb7243255e653979138eb178b9ef853ad3444  rover_0.2.2_darwin_arm64.zip
78622ba76535cc4244240553764e9143b38ae525253eaafff62d40c3b372474b  rover_0.2.2_windows_arm64.zip
91f06e61fd110f704cec330985c79d4f520c13b7fd01a54bb4b7cfc1bdbca654  rover_0.2.2_linux_arm.zip
eefe31b1c1737279aee7484728bfa8b64d35845e6f5acdfec95589a0f954dc1f  rover_0.2.2_freebsd_arm.zip
$ sha256sum rover_0.2.2_darwin_amd64.zip 
1aab2f4a45ffc1d3cc8bcd0e390f7460b5b7ef6bdb31d7445aca6acb5df8a668  rover_0.2.2_darwin_amd64.zip
$ unzip rover_0.2.2_darwin_amd64.zip 
Archive:  rover_0.2.2_darwin_amd64.zip
  inflating: LICENSE                 
  inflating: README.md               
  inflating: rover_v0.2.2            
$ ./rover_v0.2.2 -version
Rover v0.2.1

module terraform provider error

I use some modules in the terraform code but it seems rover looks the provider under the .terraform/providers directory and gives errors

docker run --rm -it -p 9000:9000 -v $path:/src im2nguyen/rover -planPath tfplan 

021/10/09 23:48:38 Unable to parse Plan: Unable to read Plan (/src/tfplan): 
Error: Could not load plugin


Plugin reinitialization required. Please run "terraform init".

Plugins are external binaries that Terraform uses to access and manipulate
resources. The configuration provided requires plugins which can't be
located,
don't satisfy the version constraints, or are otherwise incompatible.

Terraform automatically discovers provider requirements from your
configuration, including providers used in child modules. To see the
requirements and constraints, run "terraform providers".

1 problem:


- failed to instantiate provider "registry.terraform.io/hashicorp/aws" to
obtain schema: there is no package for registry.terraform.io/hashicorp/aws
3.62.0 cached in .terraform/providers

but model provider list under the module directory

terraform providers
Providers required by configuration:
.
├── provider[registry.terraform.io/hashicorp/aws]
├── provider[registry.terraform.io/hashicorp/template]
├── module.abc
│   ├── provider[registry.terraform.io/hashicorp/aws]
│   └── module.aws_security_group
│       └── provider[registry.terraform.io/hashicorp/aws] >= 3.62.0 cached 
...

signal SIGSEGV: segmentation violation when running rover v0.2.2

Hi

Issue

I'm running the following:

$ rover_v0.2.2 -planPath terraform.plan -tfConfigExists=false

OR

$ rover_v0.2.2 -planPath terraform.plan

And it gives me:

2021/11/22 13:51:23 Starting Rover...
2021/11/22 13:51:23 Using provided plan...
2021/11/22 13:51:27 Generating resource overview...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x758fa8]

goroutine 1 [running]:
main.(*rover).GenerateResourceOverview(0xc0001ec000)
	rover/rso.go:166 +0x1168
main.(*rover).generateAssets(0xc0001ec000)
	rover/main.go:172 +0x167
main.main()
	rover/main.go:118 +0xa19

Any idea what the problem is?

Terraform

Version

Terraform v1.0.11
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v3.64.2
+ provider registry.terraform.io/hashicorp/cloudinit v2.2.0
+ provider registry.terraform.io/hashicorp/kubernetes v2.6.1
+ provider registry.terraform.io/hashicorp/local v2.1.0
+ provider registry.terraform.io/hashicorp/random v3.1.0
+ provider registry.terraform.io/hashicorp/tls v3.1.0
+ provider registry.terraform.io/terraform-aws-modules/http v2.4.1

Plan commands

How I got my terraform plan:

$ terraform init -backend-config="conn_str=postgresql://XXX"
$ terraform plan -out=./terraform.plan

panic: runtime error: invalid memory address or nil pointer dereference

I am getting the following panic from Rover:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x758fa8]

goroutine 1 [running]:
main.(*rover).GenerateResourceOverview(0xc000214000)
	/src/rso.go:166 +0x1168
main.(*rover).generateAssets(0xc000214000)
	/src/main.go:172 +0x167
main.main()
	/src/main.go:118 +0xa19

However, terraform plan works just fine, but it prints the following warning at the end:

Plan: 0 to add, 0 to change, 3 to destroy.

───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now.

Any ideas?

Plan files cannot be transferred between different Terraform versions

Hello,

I have an issue with terraform binary version used with rover (output bellow)
It impose to use the exact same version as the one used to generate plan :/
It is very hard when time come to work with different plan sources (in team tf plan 4-eyes checking for example)

$ rover -planPath /plans/output.plan
2021/10/15 11:07:22 Starting Rover...
2021/10/15 11:07:22 Using provided plan...
2021/10/15 11:07:23 Unable to parse Plan: Unable to read Plan (/plans/output.plan): exit status 1

Error: Invalid plan file

Failed to read plan from plan file: plan file was created by Terraform
0.13.0-beta2, but this is 0.13.7; plan files cannot be transferred between
different Terraform versions.

Rover & CDK for Terraform & Azure CLI

Hi,

First of all Rover seems great!

But, I'm trying to use Rover on a CDK for Terraform -project (CDKTF). It is understandable, that Rover does not work in the basedir of the CDK project. So, I cd to the dir where CDKTF creates the Terraform JSON. In that dir what happens is:

% ls
cdk.tf.json     plan
% docker run --rm -it -p 9000:9000 -v $(pwd):/src im2nguyen/rover
2021/09/24 07:50:10 Starting Rover...
2021/09/24 07:50:10 Initializing Terraform...
2021/09/24 07:50:10 Unable to parse Plan: exit status 1

Error: Error building ARM Config: Please ensure you have installed Azure CLI version 2.0.79 or newer. Error parsing json result from the Azure CLI: Error launching Azure CLI: exec: "az": executable file not found in $PATH.


% az --version                                                   
azure-cli                         2.28.0

core                              2.28.0
telemetry                          1.0.6

Python location '/usr/local/Cellar/azure-cli/2.28.0/libexec/bin/python'
Extensions directory '/Users/andreas.asuja/.azure/cliextensions'

Python (Darwin) 3.9.7 (default, Sep  3 2021, 12:37:55) 
[Clang 12.0.5 (clang-1205.0.22.9)]

Legal docs and information: aka.ms/AzureCliLegal


Your CLI is up-to-date.

I'm sorry I don't have time to dig more into this, but just to inform you.

[Feature Request] Terraform Cloud integration

Integrate with Terraform Cloud. When you provide rover TFC credentials, rover should be able to pull the latest plan and generate a visualization

Would be nice if we could create a GitHub action with this integration

Deleted resources are not visualised at all

As part of testing Rover, I crafted a pull request for our Terraform repository that removes some resources and changes some parameters. But to my surprise, the output of Rover does not show the deleted resources at all. Am I doing wrong, or is this a known behaviour of Rover? I am using v0.2.2, for the record.

My pull request looks like this:

$ git diff --staged
diff --git a/terraform/clusters/dev-us-central-0/main.tf b/terraform/clusters/dev-us-central-0/main.tf
index 937d1cc6a8..ddc03aabe9 100644
--- a/terraform/clusters/dev-us-central-0/main.tf
+++ b/terraform/clusters/dev-us-central-0/main.tf
@@ -47,16 +47,6 @@ module "node_pool_main-n2s8-1" {
   }
 }

-module "node_pool_preemptible-n2s8-1" {
-  source         = "../../modules/gke/node_pool"
-  name           = "preemptible-n2s8-1"
-  cluster        = module.cluster.name
-  region         = local.region
-  machine_type   = "n2-standard-8"
-  preemptible    = true
-  max_node_count = 25
-}
-
 // node pool for GEM performance testing, not meant to
 // be utilized permanently
 module "node_pool_perf-n2s16-1" {
@@ -83,7 +73,7 @@ module "node_pool_perf-n2s8-1" {
   cluster        = module.cluster.name
   region         = local.region
   machine_type   = "n2-standard-8"
-  max_node_count = 10
+  max_node_count = 20
   taints = [
     {
       key    = "type"
@@ -186,16 +176,6 @@ module "insight-logs-gateway-dev-us-central-0-dns" {
   ttl    = 60
 }

-// dns record for amixr-03 dev environment.
-// It is needed for the services using ingress.
-module "amixr-03-dev-us-central-0-dns" {
...
-}
-
 module "network_data" {
   source = "../../modules/network_data"
 }

The output from Terraform looks like this:

Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the last "terraform apply":

  # module.insight-logs-gateway-dev-us-central-0-dns.ns1_record.main has been changed
  ~ resource "ns1_record" "main" {
        id                = "6149ec28b8d8b600afdf141c"
      + meta              = {}
        # (5 unchanged attributes hidden)

      ~ answers {
          + meta   = {}
            # (1 unchanged attribute hidden)
        }
    }
  # module.cluster.google_container_cluster.main has been changed
  ~ resource "google_container_cluster" "main" {
        id                          = "projects/..."
        name                        = "dev-us-central-0"
        # (28 unchanged attributes hidden)










      ~ node_pool {
            name                = "main-n2s8-1"
          ~ node_count          = 98 -> 129
            # (5 unchanged attributes hidden)





            # (5 unchanged blocks hidden)
        }
      ~ node_pool {
            name                = "preemptible-n2s8-1"
          ~ node_count          = 0 -> 2
            # (5 unchanged attributes hidden)





            # (5 unchanged blocks hidden)
        }






        # (17 unchanged blocks hidden)
    }
  # module.node_pool_preemptible-n2s8-1.google_container_node_pool.main has been changed
  ~ resource "google_container_node_pool" "main" {
        id                  = "projects/..."
        name                = "preemptible-n2s8-1"
      ~ node_count          = 0 -> 2
        # (8 unchanged attributes hidden)




        # (4 unchanged blocks hidden)
    }
  # module.node_pool_main-n2s8-1.google_container_node_pool.main has been changed
  ~ resource "google_container_node_pool" "main" {
        id                  = "projects/..."
        name                = "main-n2s8-1"
      ~ node_count          = 98 -> 129
        # (8 unchanged attributes hidden)




        # (4 unchanged blocks hidden)
    }

Unless you have made equivalent changes to your configuration, or ignored the relevant attributes using ignore_changes, the following plan may include actions
to undo or respond to these changes.

───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place
  - destroy

Terraform will perform the following actions:

  # module.amixr-03-dev-us-central-0-dns.ns1_record.main will be destroyed
  - resource "ns1_record" "main" {
      - id                = "611b910118fbde00a7c861d5" -> null
      ...
    }

  # module.node_pool_perf-n2s8-1.google_container_node_pool.main will be updated in-place
  ~ resource "google_container_node_pool" "main" {
        id                  = "projects/..."
        name                = "perf-n2s8-1"
        # (9 unchanged attributes hidden)

      ~ autoscaling {
          ~ max_node_count = 10 -> 20
            # (1 unchanged attribute hidden)
        }



        # (3 unchanged blocks hidden)
    }

  # module.node_pool_preemptible-n2s8-1.google_container_node_pool.main will be destroyed
  - resource "google_container_node_pool" "main" {
      - cluster             = "dev-us-central-0" -> null
      ...
    }

Plan: 0 to add, 1 to change, 2 to destroy.

───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now.

Any ideas why Rover does not show the deleted resources?

Support ARM (M1 mac)

Error response from daemon: image with reference im2nguyen/rover was found but does not match the specified platform: wanted linux/arm64, actual: linux/amd64

Azure isn't supported?

Trying to run Rover tool on Azure-based terraform, but it fails with

2021/08/31 12:48:38 Initializing Terraform...
2021/08/31 12:48:45 Unable to parse Plan: exit status 1

Error: Error building ARM Config: Please ensure you have installed Azure CLI version 2.0.79 or newer. Error parsing json result from the Azure CLI: Error launching Azure CLI: exec: "az": executable file not found in $PATH.

[Feature Request] Hosting as SaaS?

Team,
Is it possible to host it as SaaS so that any user can evaluate its plan as part of CI pipeline. I can see that at the time of starting. it generates visualization for one selected plan and expose it over a selected port.

Please correct me if I'm wrong, if I use this command as part of pipeline and assigning random ports again and again still, I have to be aware of the state. Because, the moment user closes the web page this container will not stop on its own. I'm not sure though.
docker run --rm -it -p 9000:9000 -v $(pwd):/src im2nguyen/rover

How to instruct rover to validate others plans in parallel(while running) so that any other user can also view their plan's visuals. Basically, my ask is to use it as a web app & expose on one final port in docker and multiple users are passing their projects for the visualization before hitting terraform apply.

Regards,

[Feature Request] allow to modify the listening port/interface

Hello,

I just discover this new tool that is wonderful!

But do you think it's possible to allow the modification of the port/IP (0.0.0.0 instead 127.0.0.1) via a parameter?

Can be useful in the case that we use the binary (instead docker) and the 9000 is already used by another stuff.

Best regards,

Possibility to reference tfvars file path

Hi!
Thanks for your effort. I was trying to play around with it but stumbled upon this "problem". Our setup divides stage dependent variables into tfvars in subfolders that are referenced in our CI environment.
Maybe its possible to imitate the -var-file="testing.tfvars" syntax from terraform here?

nested modules not shown in rover.

Great project first of all ! I have a tf state with main module in the main.tf/seed.tf . This module utilizes/depends on other modules so there are nested modules. Once I do a plan I can see it generated in tf plan (section of plan file here) :

  # module.search-query.aws_route53_record.route53 will be created
  + resource "aws_route53_record" "route53" {
      + allow_overwrite = (known after apply)
      + fqdn            = (known after apply)
      + id              = (known after apply)
      + name            = ""
      + records         = (known after apply)
      + ttl             = 60
      + type            = "CNAME"
      + zone_id         = ""
    }

  # module.search-query.module.acm.module.acm_certificate.aws_route53_record.validation[0] will be created
  + resource "aws_route53_record" "validation" {
      + allow_overwrite = true
      + fqdn            = (known after apply)
      + id              = (known after apply)
      + name            = (known after apply)
      + records         = (known after apply)
      + ttl             = 300
      + type            = (known after apply)
      + zone_id         = ""
    }

  # module.search-query.module.acm.module.acm_certificate.aws_route53_record.validation[1] will be created
  + resource "aws_route53_record" "validation" {
      + allow_overwrite = true
      + fqdn            = (known after apply)
      + id              = (known after apply)
      + name            = (known after apply)
      + records         = (known after apply)
      + ttl             = 300
      + type            = (known after apply)
      + zone_id         = ""
    }

  # module.search-query.module.acm.module.acm_certificate.aws_route53_record.validation[2] will be created
  + resource "aws_route53_record" "validation" {
      + allow_overwrite = true
      + fqdn            = (known after apply)
      + id              = (known after apply)
      + name            = (known after apply)
      + records         = (known after apply)
      + ttl             = 300
      + type            = (known after apply)
      + zone_id         = ""
    }

Plan: 13 to add, 0 to change, 0 to destroy.

^ here, you see how the first change is the main module but the rest are nested modules and all of them are going to be created. Im running rover on this :

(venv) ➜  virginia git:(master) ✗ ./rover_v0.2.2 -planPath plan.out -tfConfigExists=false -tfPath terraform1.0 -standalone true
2021/10/15 14:52:04 Starting Rover...
2021/10/15 14:52:04 Using provided plan...
2021/10/15 14:52:06 Generating resource overview...
2021/10/15 14:52:06 Generating resource map...
2021/10/15 14:52:06 Generating resource graph...
2021/10/15 14:52:06 Done generating assets.
2021/10/15 14:52:06 Generated zip file: rover.zip

This creates the following :
Screen Shot 2021-10-15 at 2 59 00 PM

where you can see the main module and the resources created in the module directly but not the nested module. What is interesting is that it knows about it though as if I scroll down to resources, I can see it being listed just not displayed in graph ( you can see the nested modules at the end of the main module - search-query) :

Screen Shot 2021-10-15 at 2 59 13 PM

[Feature request] look for `terraform` in `$PATH`

If your terraform location isn't /usr/local/bin/terraform you have to specify your own location, which makes it inconvenient for people using Homebrew on new ARM based macs, and people using tfenv. Using the Unix standard $PATH would make it work correctly for most people.

Issue: Save Graph not working

First off, this is a great tool!

Im trying to save the output to present in documentation etc etc
When the image is downloaded, it says its always empty.
Tried different browsers etc and no change.

Can workaround using straight screenshots of the display.

Bonus : Could we get a full screen mode of the actual visualization ? i.e remove the legend and what not so we can move around large TF code

Platform : OSX
Version : rover_0.2.2_darwin_amd64

Rover does not work with Terraform 1.0.4

docker run --rm -it -p 9000:9000 -v $(pwd):/src --env-file ./.env im2nguyen/rover
2021/09/24 10:42:45 Starting Rover...
2021/09/24 10:42:45 Initializing Terraform...
2021/09/24 10:42:46 Unable to parse Plan: terraform core version not supported by configuration

tfenv list
* 1.0.4 (set by /usr/local/Cellar/tfenv/2.2.2/version)

If this is not yet implemented for newer versions could you please update the README file?
Or maybe point out if I'm doing something wrong.

Heads up

What an awesome piece you have build - and so much needed.

During building our entire openstack/k8s cluster with terraform used for everything, I ran into the "I did not read the plan and typed yes" and then nuked an entire section without the indeed. Reading the inline diff on the cli becomes really hard with a lot of resources and your project here nails it.

Thank you so much creating and sharing this!

[Feature Request] Support for Git credentials

When terraform module source is a private git repository prompts for login details

$ docker run --rm -it -p 9000:9000 -v $(pwd):/src im2nguyen/rover
2021/09/24 10:09:46 Starting Rover...
2021/09/24 10:09:46 Initializing Terraform.
Username for 'https://gitlab.com': 

After entering username just sits there.

main.tf

module "some-module" {
  source              = "git::https://gitlab.com/group/module-name.git//?ref=v1.0.0"
  name                = "blah"
}

Panic on deleting resource from tf file

Rover fails with panic if I delete a resource from .tf file:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7e222f]

goroutine 1 [running]:
main.GenerateResourceOverview(0xc000076de0, 0x1)
        /home/lera/go/src/github.com/im2nguyen/rover/rso.go:125 +0xf2f
main.generateAssets(0x89c21b, 0x5, 0x7fff859df85e, 0x32, 0x7fff859df83f, 0x12, 0xc0000eca70, 0x1, 0x1, 0xc0000eca80, ...)
        /home/lera/go/src/github.com/im2nguyen/rover/main.go:114 +0x2b9
main.main()
        /home/lera/go/src/github.com/im2nguyen/rover/main.go:61 +0x625

The problem is the absence of an entry for deleted resource in map[string]*ResourceOverview. It's created for each resource in a plan, but if it was deleted then it appears only in changes.
Anyway, creating this entry before saving a corresponding change just saves from an error. Rover won't create a node for it in the resulting overview.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.