2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

RHEL9にAWS CLIをセットアップする

Posted at

前書き

RHEL9にAWS CLIをセットアップする時のメモです。

環境確認

  • OSを確認:RHEL9 64bit
$ cat /etc/redhat-release
Red Hat Enterprise Linux release 9.3 (Plow)
$ arch
x86_64

AWS CLI をインストール

Redhat9公式サイトに記載してたコマンドでインストールしてみたが、エラーになったため、AWSの公式サイトに記載した方法でインストールする

Redhat9公式サイト

AWS公式サイト

  • AWS CLI をインストールするコマンド
# curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
  • AWS CLI のバージョンを確認
# aws --version
aws-cli/2.15.15 Python/3.11.6 Linux/5.14.0-362.18.1.el9_3.x86_64 exe/x86_64.rhel.9 prompt/off
  • AWSのアクセスキーとシークレットアクセスキーを使ってAWS へのアクセスを設定
    ※AWSの(アクセスキーとシークレットアクセスキー)設定は他の記事で説明します。
# aws configure
AWS Access Key ID [None]: ABCDEFGHIJKLMN
AWS Secret Access Key [None]: xxxxxxxxxxxxxxxxxx
Default region name [None]: us-west-2
Default output format [None]: 
  • AWSに接続してみる(123456789012はAWSのアカウントIDです)
# export DOCKER_URI=https://123456789012.dkr.ecr.us-west-2.amazonaws.com
# aws ecr get-login-password | docker login --username AWS --password-stdin $DOCKER_URI
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
Login Succeeded!

AWSのECRにdockerイメージをプッシュしてみる

  • dockerイメージのIMAGE IDを確認し、メモする
# buildah images
REPOSITORY               TAG      IMAGE ID       CREATED          SIZE
localhost/jenkins_demo   latest   d92185b1bbe5   15 minutes ago   434 MB
  • ECRのリポジトリURIを設定する。
export REPOSITORY_URI=123456789012.dkr.ecr.us-west-2.amazonaws.com/cicd_demo

AWS ECRのリポジトリのURI
Screenshot from 2024-01-28 22-05-10.png

  • イメージタグ(今回はローカルリポジトリーと一致する)
export IMAGE_TAG=latest
  • dockerタグを変更(ローカルリポジトリーをECRリポジトリに変更)
docker tag d92185b1bbe5 123456789012.dkr.ecr.us-west-2.amazonaws.com/cicd_demo:latest
  • dockerタグを変更後、同じタグのイメージが2つあります。
# buildah images
REPOSITORY                                               TAG      IMAGE ID       CREATED             SIZE
localhost/jenkins_demo                                   latest   d92185b1bbe5   About an hour ago   434 MB
123456789012.dkr.ecr.us-west-2.amazonaws.com/cicd_demo   latest   d92185b1bbe5   About an hour ago   434 MB
  • イメージファイルをECRにプッシュする
# docker push $REPOSITORY_URI:$IMAGE_TAG
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
Getting image source signatures
Copying blob eeea83030af7 done  
Copying blob d2210512edb4 done  
Copying blob 8e87ff28f1b5 done  
Copying blob dc1ab3dbc381 done  
Copying blob c7ec3cf032a3 done  
Copying blob 16d554cd6418 done  
Copying config d92185b1bb done  
Writing manifest to image destination

PS:プッシュ時間かかります。

  • ECRにプッシュ結果を確認する
    Screenshot from 2024-01-28 22-14-53.png

成功

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?