Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConfigMap as module source #179

Open
reegnz opened this issue Jul 13, 2023 · 5 comments
Open

ConfigMap as module source #179

reegnz opened this issue Jul 13, 2023 · 5 comments
Labels

Comments

@reegnz
Copy link

reegnz commented Jul 13, 2023

What problem are you facing?

My kubernetes cluster does not have network access to my git server.
Concatenating all of the tf files into a single string and using it with Inline is my only option today that doesn't try to pull the module source from a system outside kubernetes (unless I host tar.gz-d modules in-cluster).

How could Official Terraform Provider help solve your problem?

A more kubernetes-native way would be to support terraform modules stored in configmaps.

If one could define module source to come from a configmap, then it would be very easy to package up an existing terraform module into kubernetes manifests and deploy them like any other kubernetes resource.
This would be a welcome improvement over Inline module sources.

Example:

kustomization.yaml:

configMapGenerator:
- name: my-terrfaorm-module
  files:
  - main.tf
  - variables.tf
  - outputs.tf
  - versions.tf
kustomize build | kubectl apply -n crossplane-system -

workspace.yaml:

apiVersion: tf.upbound.io/v1beta1
kind: Workspace
metadata:
  name: my-terraform-module
spec:
  forProvider:
    source: ConfigMap
    module:
      name: my-terraform-module
      namespace: crossplane-system
@reegnz reegnz added enhancement New feature or request needs:triage labels Jul 13, 2023
@ytsarev
Copy link
Member

ytsarev commented Jul 17, 2023

The feature makes sense! Thanks for documenting it.

@alkuzad
Copy link

alkuzad commented Oct 20, 2023

I just use Helm. File.Get loop to include all files inside the inline. Therefore we just copied our current TF structure into folder "terraform" inside a chart. This enables normal TF work if you want to (assuming you extend provider.tf with configuration for the real cloud, provider.tf to be include has to be ONLY for aliases, not for the provider configured in crossplane ProviderConfig).

{{/*
Helper to setup Terraform Files

Include like this to ensure proper formatting:

{{ include "compositionTerraform.include" . | trim | indent 14 }}

*/}}
{{- define "compositionTerraform.include" -}}
{{- $currentScope := .}}
{{- with $currentScope}}
{{- range (tuple "provider" "variables" "locals" "data" "main" "outputs") }}
{{- $file := $currentScope.Files.Glob (printf "terraform/%s.tf" .) }}
{{- if $file }}
{{ $currentScope.Files.Get (printf "terraform/%s.tf" .) | trim }}
{{ end -}}
{{- end }}
{{- end }}
{{- end }}

@reegnz
Copy link
Author

reegnz commented Oct 20, 2023

Thanks @alkuzad, that sounds like a reasonable alternative.

@vrabbi
Copy link

vrabbi commented May 5, 2024

this would be extremely beneficial for us as well

@senare
Copy link

senare commented Sep 24, 2024

Yes, I would like this to ...

or atleast the possibility to have a way of including the TF into the configuration once I build/bundle crossplane into a OCI image (sry I am not sure of the correct terminology here )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants