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

CLI triggered plans losing file permissions #1773

Open
aniekgul opened this issue Feb 7, 2025 · 2 comments
Open

CLI triggered plans losing file permissions #1773

aniekgul opened this issue Feb 7, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@aniekgul
Copy link
Contributor

aniekgul commented Feb 7, 2025

Bug description 🐞

Running a plan triggered off the CLI I saw the following errors from a data source that uses a shell script:

��� 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: "../scripts/cloudrun_digest.sh"
��� Error: exec: "../scripts/cloudrun_digest.sh": permission denied
���

Taking a look at the file permissions in the executor pod it seems like the file is missing the execute bit:

cnb@job-71-v7mlh:/workspace$ ls -la /home/cnb/.terraform-spring-boot/executor/acc9516c-d292-43f2-ba08-329f7c1caca5/835d9bfd-84d0-4489-a36d-ab59ed982c9d/scripts
total 32
drwxr-xr-x  2 cnb cnb 4096 Feb  7 00:26 .
drwxr-xr-x 12 cnb cnb 4096 Feb  7 00:26 ..
-rw-r--r--  1 cnb cnb 1793 Feb  7 00:26 cloudrun_digest.sh

versus the same files in a run created on the UI

cnb@job-73-v4nwd:/workspace$ ls -la /home/cnb/.terraform-spring-boot/executor/acc9516c-d292-43f2-ba08-329f7c1caca5/835d9bfd-84d0-4489-a36d-ab59ed982c9d/scripts
total 32
drwxr-xr-x  2 cnb cnb 4096 Feb  7 00:35 .
drwxr-xr-x 13 cnb cnb 4096 Feb  7 00:35 ..
-rwxr-xr-x  1 cnb cnb 1793 Feb  7 00:35 cloudrun_digest.sh

Steps to reproduce

  1. Create a data source that uses an external script, example
  2. Run a plan via the UI (should pass)
  3. Run a plan via CLI (should fail)

Expected behavior

No response

Example repository

No response

Anything else?

No response

@aniekgul aniekgul added the bug Something isn't working label Feb 7, 2025
@alfespa17
Copy link
Member

You could add a small script to run chmod something like

flow:
  - type: "terraformPlan"
    step: 100
    commands:
      - runtime: "BASH"
        priority: 100
        before: true
        script: |
          echo $PATH
          Chmod +x my_script.sh
  - type: "terraformApply"
    step: 300

That could be a workaround

@aniekgul
Copy link
Contributor Author

aniekgul commented Feb 7, 2025

Yeah that works as a workaround, good call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants