coder / coder

Provision remote development environments via Terraform
https://coder.com
GNU Affero General Public License v3.0
9.59k stars 859 forks source link

chore: persist template import terraform plan in postgres #17012

Closed aslilac closed 1 month ago

aslilac commented 1 month ago

Adds plumbing to persist terraform plan data from template import provisioner builds.


After some deliberation, I went with storing what I have called the cached_plan in a separate table because these values are incredibly large, the template_versions table already has a lot of columns, and a lot of queries use template_version.* to get those many columns. Accidentally including the cached_plan column in those queries would be very undesirable, and this value mostly exists for future use on the backend. I don't think this is the sort of thing we would ever actually want to send to a client, except maybe a page for debugging the current state.

This also means that we can track it's updated_at time separately quite easily, since we're planning on letting it be "refreshed".

Closes https://github.com/coder/coder/issues/17050

Emyrk commented 1 month ago

The purpose of this is not widely known, so just dropping a note.

The output of terraform plan is going to be used to support dynamic parameters. Specifically, we are keeping the raw outputs (rather than preparsing) as an input to the new parameter engine.

The phasing in of this new feature is that it will live alongside the existing flow for some time. So this new table will be write-only for production instances until we get a bit further with the parameter engine experiment.