tofu-controller
tofu-controller copied to clipboard
Add support for terraform targets
I would like to see support for adding terraform targets. I imagine something like
apiVersion: infra.contrib.fluxcd.io/v1alpha1
kind: Terraform
metadata:
name: vpc
namespace: flux-system
spec:
...
path: ./terraform/test/us-west-2/dev/vpc
targets:
- module.dev_vpc
varsFrom:
- kind: Secret
name: aws-credentials
...
When initially creating the infrastructure we would have the targets section commented out. But afterwards we would want to restrict terraform to a set of targets. This will allows us to do creates and deletes of VPCs and clusters without losing the EIPs in the original tf config. While we can add lifecycle blocks to the EIPs, this prevents the entire tf config from being destroyed as terraform will error out about the EIPs and their prevent deletion lifecycles.
Thank you @wpbeckwith This is a great feature request!
I'll be looking at the tfexec library we're using to see if it supports passing this target set.
It does, https://github.com/hashicorp/terraform-exec/blob/495b9eb3d2cd9daebea6191f5329430ea0a72867/tfexec/plan.go#L21
@chanwit if help is wanted, I can create a PR for this feature.
@akselleirv that would be fantastic. thank you so much!