Azure / alz-terraform-accelerator

Azure Landing Zones Terraform Accelerator
MIT License
98 stars 32 forks source link

bug: hcl2json_linux_arm64 is missing the x permission flag #135

Closed arne21a closed 3 months ago

arne21a commented 5 months ago

Is there an existing issue for this?

Bootstrap or Starter Module Deployment? (Required)

bootstrap

ALZ-PowerShell-Module Version (Required)

2.0.3

alz-terraform-accelerator Version (Required)

1.0.6

Starter Module (Required)

basic

Input arguments of the ALZ-PowerShell-Module (Required)

Deploy-Accelerator -i "terraform" -b "alz_local"

Contents of the configuration file used for the complete starter module. (Optional)

No response

Debug Output/Panic Output (Optional)

Deploy-Accelerator -i "terraform" -b "alz_local"
Getting ready to deploy the accelerator with you...

Checking you have the latest version of Terraform installed...

Checking and Downloading the bootstrap module...
The directory for ./bootstrap/v1.0.6 has been created and populated.                                                    

Checking and Downloading the starter module...
The directory for ./starter/v2.0.3 has been created and populated.                                                      
Please select the starter module you would like to use, you can enter one of the following keys:
- basic
- complete
- complete_vnext
- hubnetworking
: basic
ResourceUnavailable: /usr/local/share/powershell/Modules/ALZ/2.0.3/Private/Config-Helpers/Convert-HCLVariablesToUserInputConfig.ps1:21:9
Line |
  21 |          $terraformVariables = & $hclParserToolPath $targetVariableFil …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Program 'hcl2json_linux_arm64' failed to run: An error occurred trying to start process '/workspaces/dev-container/bootstrap/v1.0.6/hcl2json_linux_arm64' with working directory '/workspaces/dev-container'. Permission deniedAt
     | /usr/local/share/powershell/Modules/ALZ/2.0.3/Private/Config-Helpers/Convert-HCLVariablesToUserInputConfig.ps1:21 char:31 + … terraformVariables = & $hclParserToolPath $targetVariableFile | Conve … +                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
ResourceUnavailable: /usr/local/share/powershell/Modules/ALZ/2.0.3/Private/Config-Helpers/Convert-HCLVariablesToUserInputConfig.ps1:21:9
Line |
  21 |          $terraformVariables = & $hclParserToolPath $targetVariableFil …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Program 'hcl2json_linux_arm64' failed to run: An error occurred trying to start process '/workspaces/dev-container/bootstrap/v1.0.6/hcl2json_linux_arm64' with working directory '/workspaces/dev-container'. Permission deniedAt
     | /usr/local/share/powershell/Modules/ALZ/2.0.3/Private/Config-Helpers/Convert-HCLVariablesToUserInputConfig.ps1:21 char:31 + … terraformVariables = & $hclParserToolPath $targetVariableFile | Conve … +                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
ResourceUnavailable: /usr/local/share/powershell/Modules/ALZ/2.0.3/Private/Config-Helpers/Convert-HCLVariablesToUserInputConfig.ps1:21:9
Line |
  21 |          $terraformVariables = & $hclParserToolPath $targetVariableFil …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Program 'hcl2json_linux_arm64' failed to run: An error occurred trying to start process '/workspaces/dev-container/bootstrap/v1.0.6/hcl2json_linux_arm64' with working directory '/workspaces/dev-container'. Permission deniedAt
     | /usr/local/share/powershell/Modules/ALZ/2.0.3/Private/Config-Helpers/Convert-HCLVariablesToUserInputConfig.ps1:21 char:31 + … terraformVariables = & $hclParserToolPath $targetVariableFile | Conve … +                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.

Expected Behaviour (Required)

The binary hcl2json_linux_arm64 should be configured to be executable.

Actual Behaviour (Required)

The permissions of the binary are missing thx x flag. Therefore it can not be executed.

Workaround:

Steps to Reproduce (Optional)

I am building a devcontainer to use with alz.

FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04

ARG PS_VERSION=7.4.2

RUN sudo apt-get update

# Install az cli
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

# Install powershell
RUN sudo mkdir /usr/local/bin/powershell
RUN wget https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/powershell-7.4.2-linux-$(dpkg --print-architecture).tar.gz -O powershell.tar.gz
RUN sudo tar -xf powershell.tar.gz -C /usr/local/bin/powershell
RUN rm powershell.tar.gz 

# Install ALZ Module
USER root
RUN /usr/local/bin/powershell/pwsh -c "Install-Module -Name ALZ -Force -Scope AllUsers"

# Install kubectl
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/$(dpkg --print-architecture)/kubectl"
RUN sudo install -o vscode -g vscode -m 0755 kubectl /usr/local/bin/kubectl
RUN rm kubectl

# Install terraform
RUN wget https://releases.hashicorp.com/terraform/1.8.2/terraform_1.8.2_linux_$(dpkg --print-architecture).zip -O terraform.zip
RUN unzip terraform.zip
RUN sudo install -o vscode -g vscode -m 0755 terraform /usr/local/bin/terraform
RUN rm terraform LICENSE.txt terraform.zip

Important Factoids (Optional)

No response

References (Optional)

No response

jaredfholgate commented 4 months ago

@arne21a This is interesting as we do set this switch here: https://github.com/Azure/ALZ-PowerShell-Module/blob/cc905c81af9baf502ea729986514dfdc279e25dc/src/ALZ/Private/Tools/Get-HCLParserTool.ps1#L29

Our e2e tests all pass successfully on linux and macos, so wondering what is different for you?

jaredfholgate commented 3 months ago

Closing as no response and unable to replicate.