binbashar / le-docker-leverage-toolbox

Docker image for https://github.com/binbashar/leverage
3 stars 0 forks source link

Bug | Leverage AWS-Cli error pkg dependencies for ARM (M1) #46

Closed marianod92 closed 1 year ago

marianod92 commented 1 year ago

Describe the Bug

When you use the aws-cli component from leverage cli (either to configure your credentials and use them with terraform or using aws-cli directly) on ARM architectures (Apple MacBook Pro M1) you get an error due to a dependency not found.

➜  repository git:(main) leverage credentials configure --type MANAGEMENT

[23:11:47.408] INFO     Reading info from build.env                                                                                                                                                            
[23:11:47.557] INFO     Loading configuration file.                                                                                                                                                            
[23:11:47.558] INFO     Loading project environment configuration file.                                                                                                                                        
[23:11:47.559] INFO     Loading Terraform common configuration.                                                                                                                                                
[23:11:48.041] INFO     Configuring management credentials.                                                                                                                                                    
> Select the means by which you'll provide the programatic keys: Manually
> Key: XXXXXXXXXXXXXXXXXXXXXX
> Secret: ****************************************
[23:12:08.720] ERROR    AWS CLI error: qemu-x86_64: 
Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory    

Expected Behavior

It is expected to be able to configure the aws-cli credentials from the leverage cli and to be able to use aws-cli with the native aws-cli commands, on both x86 and ARM architectures

Steps to Reproduce

Steps to reproduce the behavior:

  1. If you don't have it, clone this repo https://github.com/binbashar/le-tf-infra-aws
  2. Go to the root folder of the cloned repository and try to configure the MANAGEMENT or SECURITY credentials. leverage credentials configure --type MANAGEMENT
  3. Select the Manually option to configure the credentials.
  4. Indicates the Access Key and Secret Access Key values (previously obtained from the AWS console in the IAM section).
  5. See error

Screenshots

image

Environment (please complete the following information):

Server: Docker Desktop 4.17.0 (99724) Engine: Version: 20.10.23 API version: 1.41 (minimum version 1.12) Go version: go1.18.10 Git commit: 6051f14 Built: Thu Jan 19 17:31:28 2023 OS/Arch: linux/arm64 Experimental: false containerd: Version: 1.6.18 GitCommit: 2456e983eb9e37e47538f59ea18f2043c9a73640 runc: Version: 1.1.4 GitCommit: v1.1.4-0-g5fd4c4d docker-init: Version: 0.19.0 GitCommit: de40ad0



## Additional Context
In a similar environment (with M1) @lgallard  does not get the error 

## Describe Ideal Solution
If you change the installer of aws-cli for the appropriate one for ARM (for example, in this [line](https://github.com/binbashar/le-docker-leverage-toolbox/blob/master/Dockerfile#L78)) the error is solved.

![image](https://user-images.githubusercontent.com/35702375/227317647-bb382957-52b2-4b9e-b7d0-933e593a5177.png)

However, that change would generate an error on non-ARM platforms.
It would be necessary to make a refactor in such a way that it can be parameterized and at the time of the build inject the target platform and install the corresponding versions of the different tools for those architectures.
While the erroneous behavior did not occur in other tools in the image, there are several similar references in the Dockerfile to x86 architectures that could be customized for ARM.