ccao-data / actions

GitHub Actions for CCAO Data projects
0 stars 0 forks source link

Make `setup-terraform` action more generalizable #7

Open jeancochrane opened 7 months ago

jeancochrane commented 7 months ago

The setup-terraform action is currently tightly coupled to the build-and-run-batch-job workflow due to the interface we use to pass in config-specific variables. Currently, they are passed in as named input parameters, one for each variable:

https://github.com/ccao-data/actions/blob/2f9dd27fa8ff3d18a96562421f47287eb998f784/setup-terraform/action.yaml#L12-L46

This isn't a great design, because the batch-* variables are specific to build-and-run-batch-job, and if we wanted to use setup-terraform to provision resources for a different workflow (e.g. in model-sales-val) we would both A) be required to pass variables that are not used by the workflow's Terraform config and B) not have a way of passing different variables that are used by the workflow's config.

I think a better interface would be one input variable named something like terraform-vars that accepts a newline-delimited string of variables to set in the Terraform config. Then callers could pass in arbitrary key-value pairs to set as variables. See https://github.com/ccao-data/actions/pull/6 for an example of a PR that implements a similar interface.