terraform-exec icon indicating copy to clipboard operation
terraform-exec copied to clipboard

Plan/Apply `-json` support missing

Open thrashr888 opened this issue 4 years ago • 2 comments

Plans and applies now support streaming json with the -json flag. Adding support for the flag may not be enough--including streamed data structures from stdout would be preferred.

thrashr888 avatar May 25 '21 21:05 thrashr888

As a workaround:

        ctx := context.Background()
        outfile := "./mystate.state"
	tfexec.Plan(context, tfexec.Out(outfile))

	tfjson, _ := txexec.ShowPlanFile(context, outfile)

	b, _ := json.Marshal(tfjson)

	jsonOutfile := "./mystate.json"
	os.WriteFile(jsonOutfile, b, 0666)

till avatar Feb 16 '22 17:02 till

We have a use case for being able to stream JSON with the -json flag in Ability to test whether warnings are raised during test steps.

The intention is to modify the acceptance testing framework so that the -json flag can be used with terraform-exec to allow parsing of the streamed JSON in order to be able to verify that warning diagnostics are being emitted in specific tests.

bendbennett avatar Dec 20 '22 08:12 bendbennett