ablog

不器用で落着きのない技術者のメモ

Amazon Linux 2 に AWS CLI v2 をインストールする

インストール

  • インストールする
$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
$ unzip awscliv2.zip
$ sudo ./aws/install
  • バージョンを確認する
$ /usr/local/bin/aws --version
aws-cli/2.2.14 Python/3.8.8 Linux/4.14.232-176.381.amzn2.x86_64 exe/x86_64.amzn.2 prompt/off

使ってみる

  • S3 アクセスポイント経由でアップロードする
$ /usr/local/bin/aws s3 cp test.txt s3://arn:aws:s3:ap-northeast-1:123456789012:accesspoint/s3-access-point-vpc1/
upload: ./test.txt to s3://arn:aws:s3:ap-northeast-1:123456789012:accesspoint/s3-access-point-vpc1/test.txt

アンインストール

$ sudo rm /usr/local/bin/aws
$ sudo rm /usr/local/bin/aws_completer
$ sudo rm -rf /usr/local/aws-cli

参考

Uploading to an S3 access point

The following cp command uploads a single file (mydoc.txt) to the access point (myaccesspoint) at the key (mykey):

aws s3 cp mydoc.txt s3://arn:aws:s3:us-west-2:123456789012:accesspoint/myaccesspoint/mykey

Output:

upload: mydoc.txt to s3://arn:aws:s3:us-west-2:123456789012:accesspoint/myaccesspoint/mykey
Downloading from an S3 access point

The following cp command downloads a single object (mykey) from the access point (myaccesspoint) to the local file (mydoc.txt):

aws s3 cp s3://arn:aws:s3:us-west-2:123456789012:accesspoint/myaccesspoint/mykey mydoc.txt

Output:

download: s3://arn:aws:s3:us-west-2:123456789012:accesspoint/myaccesspoint/mykey to mydoc.txt
cp — AWS CLI 2.2.14 Command Reference