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

fix: main.tf references to files subdir to include module path #416

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Carus11
Copy link

@Carus11 Carus11 commented Dec 27, 2024

Re-opening at the request of Ian

When including the viya4-iac-azure project as a module within a wider terraform codebase, running terraform apply creates the following error:

│ Error: External Program Lookup Failed
│
│   with module.viya4_iac_azure.data.external.git_hash,
│   on .terraform/modules/viya4_iac_azure/main.tf line 274, in data "external" "git_hash":
│  274:   program = ["files/tools/iac_git_info.sh"]
│
│ The data source received an unexpected error while attempting to parse the query. The data source received an unexpected error while attempting to find the program.
│
│ The program must be accessible according to the platform where Terraform is running.
│
│ If the expected program should be automatically found on the platform where Terraform is running, ensure that the program is in an expected directory. On Unix-based platforms, these directories are typically searched based on the '$PATH' environment
│ variable. On Windows-based platforms, these directories are typically searched based on the '%PATH%' environment variable.
│
│ If the expected program is relative to the Terraform configuration, it is recommended that the program name includes the interpolated value of 'path.module' before the program name to ensure that it is compatible with varying module usage. For
│ example: "${path.module}/my-program"
│
│ The program must also be executable according to the platform where Terraform is running. On Unix-based platforms, the file on the filesystem must have the executable bit set. On Windows-based platforms, no action is typically necessary.
│
│ Platform: linux
│ Program: "files/tools/iac_git_info.sh"
│ Error: exec: "files/tools/iac_git_info.sh": stat files/tools/iac_git_info.sh: no such file or directory
╵
╷
│ Error: External Program Lookup Failed
│
│   with module.viya4_iac_azure.data.external.iac_tooling_version,
│   on .terraform/modules/viya4_iac_azure/main.tf line 278, in data "external" "iac_tooling_version":
│  278:   program = ["files/tools/iac_tooling_version.sh"]
│
│ The data source received an unexpected error while attempting to parse the query. The data source received an unexpected error while attempting to find the program.
│
│ The program must be accessible according to the platform where Terraform is running.
│
│ If the expected program should be automatically found on the platform where Terraform is running, ensure that the program is in an expected directory. On Unix-based platforms, these directories are typically searched based on the '$PATH' environment
│ variable. On Windows-based platforms, these directories are typically searched based on the '%PATH%' environment variable.
│
│ If the expected program is relative to the Terraform configuration, it is recommended that the program name includes the interpolated value of 'path.module' before the program name to ensure that it is compatible with varying module usage. For
│ example: "${path.module}/my-program"
│
│ The program must also be executable according to the platform where Terraform is running. On Unix-based platforms, the file on the filesystem must have the executable bit set. On Windows-based platforms, no action is typically necessary.
│
│ Platform: linux
│ Program: "files/tools/iac_tooling_version.sh"
│ Error: exec: "files/tools/iac_tooling_version.sh": stat files/tools/iac_tooling_version.sh: no such file or directory

The lines in main.tf, 274 and 278 refer to shell scripts in the files directory using a relative link.

This pull request adds path.module to the paths in order for it to properly resolve when included as a submodule, or when run as the root module.

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

Successfully merging this pull request may close these issues.

1 participant