Sunday, January 23, 2022

How to Install AWSCLI on Rocky Linux 8 / Centos 8

Note:
    It is assumed that you have a working docker that will be use to build a docker image.


1. add the current user to the root group
[root@DESKTOP-M9QDJVD Alex Madriaga]# useradd -m -s $(which bash) -G root malex
  
2. change user from root to regular user
[root@DESKTOP-M9QDJVD Alex Madriaga]# sudo -i -u malex

3. install awscli as a regular user
[malex@DESKTOP-M9QDJVD ~]$ pip3 install awscli --upgrade --user

4. check the version
[malex@DESKTOP-M9QDJVD ~]$ aws --version
aws-cli/1.22.41 Python/3.6.8 Linux/5.10.16.3-microsoft-standard-WSL2 botocore/1.23.41  

5. configure credentials
[malex@DESKTOP-M9QDJVD ~]$ aws configure
AWS Access Key ID [None]: JKIJ9BFLQ242O9M2HFDR
AWS Secret Access Key [None]: RB8T8EKegNkURW+llpnneELqnlXUwXEhhhpzH7Ij
Default region name [None]: us-east-1
Default output format [None]: json

6. check the 2 files created
[malex@DESKTOP-M9QDJVD ~]$ cat ~/.aws/credentials
[default]
aws_access_key_id = JKIJ9BFLQ242O9M2HFDR
aws_secret_access_key = RB8T8EKegNkURW+llpnneELqnlXUwXEhhhpzH7Ij

[malex@DESKTOP-M9QDJVD ~]$ cat ~/.aws/config
[default]
region = us-east-1
output = json

7. login to aws 
[malex@DESKTOP-M9QDJVD ~]$ aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 867579674613.dkr.ecr.us-east-1.amazonaws.com/test-ecr
-bash: docker: command not found
Exception ignored in: <_io.TextIOWrapper name='' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe
[malex@DESKTOP-M9QDJVD ~]$

8. install docker (see separate guide)

9. install docker-credential-store (see separate guide)

10. after installing docker successfully, try again
[malex@DESKTOP-M9QDJVD ~]$ aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 867579674613.dkr.ecr.us-east-1.amazonaws.com/test-ecr
Login Succeeded

No comments:

Post a Comment