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

[Feature Request] pass a plan file instead of generating inside rover #115

Open
yu-iskw opened this issue Aug 17, 2022 · 9 comments
Open

Comments

@yu-iskw
Copy link

yu-iskw commented Aug 17, 2022

Motivation

We use terraform to set up Google Cloud. And we store terraform states in GCS buckets. So, we need permissions and credentials to execute terraform plan.
I would like to integrate rover with GitHub Actions. But when we use a custom container action, it is quite difficult to pass credentials of Google Cloud SDK to it. So, I would like to separate the step to generate a plan file from the other to run rover.

Expected behavior

  1. We would like to generate a plan file with the terraform plan command in place of rover.
  2. rover recieves the plan file.
@captaindanila
Copy link

What you can currently do is to create your plan through terraform and parse it as json to rover:

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

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

That's how I'm currently running rover due to plugins issues

@yu-iskw
Copy link
Author

yu-iskw commented Aug 17, 2022

@captaindanila That looks like what I am looking for. I will give it a try. Thank you.

@lkurzyniec
Copy link

lkurzyniec commented Dec 28, 2022

What you can currently do is to create your plan through terraform and parse it as json to rover:

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

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

That's how I'm currently running rover due to plugins issues

It works like a charm! 💣

You can even simplify the command to send just a plan file: docker run --rm -it -p 9000:9000 -v $(pwd)/plan.json:/src/plan.json im2nguyen/rover:latest -planJSONPath=plan.json

image

image

Worth mention that plan.json file should be generated in Linux version - Unix (LF), UTF-8. My first try ended up with an error because I generated it on Windows (CR LF, UTF-16).

@captaindanila IMHO worth adding this approach (run capability) into the README file.

@yu-iskw
Copy link
Author

yu-iskw commented Sep 22, 2023

@lkurzyniec Sorry for the delay of my reply. I made sure the measure enables me to start the server and generate the zip file. Thank you.

#115 (comment)

Let me another question to generate a SVG image with the measure. I tried to use the -genImage option with a pre-made plan.json using the docker image. However, it didn't create a SVG image. Is there any way to solve the issue?

$ docker run --rm -it -p 9000:9000 -v $(pwd):/src im2nguyen/rover:latest -planJSONPath=plan.json -genImage true -standalone true
2023/09/22 00:02:22 Starting Rover...
2023/09/22 00:02:22 Using provided JSON plan...
2023/09/22 00:02:22 Generating resource overview...
2023/09/22 00:02:22 No submodule configurations found...
2023/09/22 00:02:22 Generating resource map...
2023/09/22 00:02:22 Generating resource graph...
2023/09/22 00:02:22 Done generating assets.
2023/09/22 00:02:22 Rover is running on 0.0.0.0:9000
2023/09/22 00:02:23 context canceled

$ docker run --rm -it -p 9000:9000 -v $(pwd):/src im2nguyen/rover:latest -planJSONPath=plan.json -genImage 
2023/09/22 00:02:32 Starting Rover...
2023/09/22 00:02:32 Using provided JSON plan...
2023/09/22 00:02:32 Generating resource overview...
2023/09/22 00:02:32 No submodule configurations found...
2023/09/22 00:02:33 Generating resource map...
2023/09/22 00:02:33 Generating resource graph...
2023/09/22 00:02:33 Done generating assets.
2023/09/22 00:02:33 Rover is running on 0.0.0.0:9000
2023/09/22 00:02:34 context canceled

@yu-iskw
Copy link
Author

yu-iskw commented Sep 22, 2023

According to my research, rover take a screenshot using github.com/chromedp/chromedp. The documentations describes the error. But, I haven't understand we can handle it with the docker image of rover.

I'm seeing "context canceled" errors

When the connection to the browser is lost, chromedp cancels the context, and it may result in this error. This occurs, for example, if the browser is closed manually, or if the browser process has been killed or otherwise terminated.

https://github.com/chromedp/chromedp#frequently-asked-questions

@lkurzyniec
Copy link

lkurzyniec commented Sep 25, 2023

@yu-iskw everything is working fine. Here is my command and result:
image

@yu-iskw
Copy link
Author

yu-iskw commented Sep 26, 2023

@lkurzyniec Thank you for sharing the screen capture. I am assuming there is anything wrong with the consiguration of docker on my machine. I am going to look into it more.

  • MacOS: 12.5.1
  • Docker Desktop: 4.22.1 (118664)
  • docker: 24.0.5, build ced0996

Tough I built a docker image with the rover repository, that doesn't work. And I tried a couple of values to --platform option of the docker command, that doesn't solve my issue.

@lkurzyniec
Copy link

@yu-iskw double-check your JSON terraform plan file

Worth mention that plan.json file should be generated in Linux version - Unix (LF), UTF-8. My first try ended up with an error because I generated it on Windows (CR LF, UTF-16).

@yu-iskw
Copy link
Author

yu-iskw commented Sep 26, 2023

Thanks. Indeed, I’m able to launch the sever of rover and generate the static HTML with the docker image. I think the plan.json file is probably fine. I will investigate something around chromedp, as apparently there is any issue to internally launch it to capture an screenshot inside the docker container on my laptop.

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

No branches or pull requests

3 participants