terraform-k8s
terraform-k8s copied to clipboard
Customize workspace name
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Description
Presently, the name of TFE/TFC workspace gets constructed using k8s Namespace and Name specified in CRD
ref: https://github.com/hashicorp/terraform-k8s/blob/0c0b52b36cfff48a1ca721707e65115800593561/workspacehelper/workspace_helper.go#L128 .
Provided, in multi-tenant with vast complexity environments, namespaces can be quite long and descriptive, that makes the construct of the workspace name quite lengthy, hence ability to override the name of the workspace to shorten it, would be quite of utility.
Potential Terraform Configuration
In case of k8s namespace as my-very-lengthy-namespace-0 combined with workspace from CRD as demo, makes actual TFC workspace my-very-lengthy-namespace-0-demo. By specifying key tfc_name one could shorten the name to my-ns0-demo.
apiVersion: app.terraform.io/v1alpha1
kind: Workspace
metadata:
name: demo
#
# Shorter name of the workspace
#
tfc_name: my-ns0-demo
spec:
organization: demo
secretsMountPath: "/tmp/secrets"
variables:
- key: CONFIRM_DESTROY
value: "1"
sensitive: false
environmentVariable: true
outputs:
- key: pet
moduleOutputName: rofl
References
n/a
You can specify omitNamespacePrefix in the Workspace resource that will omit the namespace from the name of the TFC Workspace. Then the Workspace is names as the Workspace resource is named:
...
metadata:
name: my-ns0-demo
...
spec:
omitNamespacePrefix: true
...