Amazon Linux 컨테이너에서 aws cli를 실행하는 방법은 무엇입니까?

Amazon Linux 컨테이너에서 aws cli를 실행하는 방법은 무엇입니까?

gitlab 파이프라인의 일부로 Amazon Linux 명령을 실행하고 싶습니다.

그래서 도커 이미지를 러너로 사용하려고 하면,AmazonLinux:최신

따라서 docker 컨테이너에 연결하고 아래 명령을 실행했습니다.

yum -yq install aws-cli

aws-cli를 설치했습니다.

그런 다음 aws cli를 구성했습니다.

aws configure set region $AWS_REGION
aws configure set aws_access_key_id $AWS_ACCESS_KEY
aws configure set aws_secret_access_key $AWS_SECRET_KEY
aws configure set plugins.bolt awscli-plugin-bolt

그런 다음 아래 명령을 실행하여 신원을 확인했지만 aws-cli-plugin-bolt가 없다는 오류가 발생했습니다.

aws sts get-caller-identity

그런 다음 python pip install을 실행했는데 python 2.7 지원 중단 오류가 발생하고 모듈을 찾을 수 없습니다.

pip install awscli-plugin-bolt
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip install --user` instead.
ERROR: Could not find a version that satisfies the requirement awscli-plugin-bolt (from versions: none)
ERROR: No matching distribution found for awscli-plugin-bolt

따라서 아래 명령과 참조를 사용하여 Python을 기본 버전으로 Python 3으로 변경했습니다.페이지.

amazon-linux-extras enable python3.8
yum install python3.8
update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1

그런 다음 pip3을 사용하여 볼트 플러그를 설치했습니다.

yum install python3-pip
pip3 install awscli-plugin-bolt

그러나 여전히 아래 명령은 여전히 ​​Python 2를 찾고 실패합니다.

aws sts get-caller-identity

따라서 해당 컨테이너를 삭제하고 새 컨테이너를 만든 후 첫 번째 단계로 Python 버전 3을 기본 버전으로 변경했습니다.

하지만 이번에는 aws-cli 자체의 yum 설치가 실패했습니다.

 bash-4.2# yum -yq install aws-cli
  File "/usr/bin/yum", line 30
    except KeyboardInterrupt, e:
                            ^
SyntaxError: invalid syntax

amazonlinux docker 이미지에서 aws cli 명령에 액세스하는 방법을 제안해 주세요.

이미지를 다음으로 변경하면 작동하는 것 같습니다.

  image: 
    name: amazon/aws-cli
    entrypoint: [""]

따라서 aws cli를 직접 설치할 필요가 없습니다. 그러나 기본적으로 3.7이 제공되며 이를 이미지의 일부로 변경하는 방법이 있습니다. 그리고 주요 질문은 위의 이미지가 gitlab에서 작동하고 있는데 docker run을 사용하면 이미지를 직접 사용할 수 없었습니다. 개별 aws 명령만 즉시 컨테이너를 수락하고 닫습니다.

관련 정보