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

The require-executable module forces an external program lookup on the terraform running environment even not used #62

Open
kewei5zhang opened this issue Jun 28, 2022 · 0 comments

Comments

@kewei5zhang
Copy link

kewei5zhang commented Jun 28, 2022

We are trying to use Terraform Cloud to plan and apply the eks-cluster-control-plane module and require-executable is a hard downstream dependency. It always fails because TFC runner has no python installed and there is no way we can disable terraform from checking the python executable even we are not using the required-executable functions.

Understand that we could just use the tf resources directly if not leveraging those basic validations gruntwork provided out of the box, but It is always good to provide options for users to work around without affecting the default behavior, especially for the use cases where people are migrating from self-hosted runners to terraform cloud.

Error Log:

with module.eks_cluster.module.require_kubergrunt.data.external.required_executable
on .terraform/modules/eks_cluster.require_kubergrunt/modules/require-executable/main.tf line 9, in data "external" "required_executable":
  program = ["python", "${path.module}/require_executable.py"]
The data source received an unexpected error while attempting to find the program.
Platform: linux
Program: python
Error: exec: "python": executable file not found in $PATH

Proposed Solution:
Using count to mute terraform plan if length(required_executable) == 0. (inspired by the executable-dependency module)

data "external" "required_executable" {
  count = length(var.required_executables) > 0 ? 1 : 0
  program = ["python3", "${path.module}/require_executable.py"]

  # Currently the external data source provider does not support list values in the query, so we convert the input list
  # to be a comma separated string.
  # See https://github.com/terraform-providers/terraform-provider-external/issues/2
  query = {
    required_executables = join(",", var.required_executables)
    error_message        = var.error_message
  }
}

Let me know what do you guys think, happy to contribute PRs.

@kewei5zhang kewei5zhang changed the title require-executable force a external program lookup on the terraform environment even not used The require-executable module forces an external program lookup on the terraform running environment even not used Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant