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

Prevent terraform init from trying to download git submodules #34917

Open
shellwhale opened this issue Mar 29, 2024 · 2 comments
Open

Prevent terraform init from trying to download git submodules #34917

shellwhale opened this issue Mar 29, 2024 · 2 comments
Labels
enhancement new new issue not yet triaged

Comments

@shellwhale
Copy link

shellwhale commented Mar 29, 2024

Terraform Version

Terraform v1.7.4

Use Cases

I'm trying to init a module that has it's source code stored in a repository where there is a git submodule (that git submodule does not contain terraform code). I would like to tell terraform (or git) to not try to clone any submodules.

module "random_number" {
  source = "git::https://github.com/shellwhale/test-module.git//modules/random_number&depth=1"
  name               = "random_number"
}

Attempted Solutions

I tried shallow cloning with &depth=1 but it seems that the default behavior is to try to pull the submodules. I would like to avoid that.

From my understanding, by default, git clone doesn't pull the submodules. So I think there must be something in terraform's code that's enabling --recurse-submodules. I'm struggling to find that part of the code as I'm unfamiliar with the codebase.

MINIMAL EXAMPLE HERE : https://github.com/shellwhale/test-module/blob/main/global/main.tf
You can try it the above minimal example. I expect terraform NOT to clone the submodule located here https://github.com/shellwhale/test-module/tree/main/app/src

Proposal

No response

References

No response

@shellwhale shellwhale added enhancement new new issue not yet triaged labels Mar 29, 2024
@shellwhale shellwhale changed the title Prevent terraform init from trying to download submodules Prevent terraform init from trying to download git submodules Mar 29, 2024
@crw
Copy link
Collaborator

crw commented Mar 29, 2024

Thanks for this feature request! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!

@apparentlymart
Copy link
Member

Terraform implements git fetching using the upstream shared library go-getter, which currently fetches submodules unconditionally as part of its work.

Since that's a shared dependency with other software, and isn't maintained directly by the Terraform team, I think supporting this would require consensus with all of the other callers about whether and how to support it.

Unfortunately this particular library has become very resistant to change due to its high exposure to security-related concerns, and so adding additional options to it might not be desirable due to the overhead of maintaining yet another codepath in something that is already quite hard to maintain. I think to start we'll have to see if the maintainers are even comfortable with adding a new option for this. If the answer is yes, then we can think about how best to expose it. (Adding yet another random pseudo-query-string argument isn't ideal, but I don't really see any other way to specify it dynamically for a particular call. 🤷‍♂️ )

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

No branches or pull requests

3 participants