くろひょうのぶろぐ

macOSにAWS CLIをインストールする
2022-04-01 20:36 ( edited 2022-04-04 22:53 )

概要

手順

% brew install awscli
% aws --version
aws-cli/2.5.1 Python/3.9.12 Darwin/21.4.0 source/arm64 prompt/off
% aws configure --profile blackle0pard     
AWS Access Key ID [None]: PDRASKRNPVFQKFZJ4FCE
AWS Secret Access Key [None]: fal2uVOv29zYq5FoKuvqUZqx+brRs+lXKICwZ5Jk
Default region name [None]: ap-northeast-3
Default output format [None]: json
% aws configure list --profile blackle0pard
      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile             blackle0pard           manual    --profile
access_key     ****************4FCE shared-credentials-file    
secret_key     ****************Z5Jk shared-credentials-file    
    region           ap-northeast-3      config-file    ~/.aws/config
% cat ~/.aws/config 
[profile blackle0pard]
region = ap-northeast-3
output = json
% cat ~/.aws/credentials 
[blackle0pard]
aws_access_key_id = PDRASKRNPVFQKFZJ4FCE
aws_secret_access_key = fal2uVOv29zYq5FoKuvqUZqx+brRs+lXKICwZ5Jk
% aws iam list-users --profile blackle0pard
{
    "Users": [
        {
            "Path": "/",
            "UserName": "hoge",
            "UserId": "WQDAF7I7UMPQXP30SI18E",
            "Arn": "arn:aws:iam::438948287776:user/hoge",
            "CreateDate": "2017-03-07T13:31:10+00:00",
            "PasswordLastUsed": "2022-03-31T11:46:47+00:00"
        }
    ]
}
% which aws_completer
/opt/homebrew/bin/aws_completer
% echo $SHELL
/bin/zsh
% vi ~/.zshrc 
export PATH="/opt/homebrew/bin/:$PATH"
% source ~/.zshrc 
% vi ~/.zshrc 
autoload bashcompinit && bashcompinit
autoload -Uz compinit && compinit
complete -C '/opt/homebrew/bin/aws_completer' aws
% source ~/.zshrc 
% aws s<TAB>
s3                              schemas                         sesv2                           ssm-incidents
s3api                           sdb                             shield                          sso
s3control                       secretsmanager                  signer                          sso-admin
s3outposts                      securityhub                     sms                             sso-oidc
sagemaker                       serverlessrepo                  snow-device-management          stepfunctions
sagemaker-a2i-runtime           service-quotas                  snowball                        storagegateway
sagemaker-edge                  servicecatalog                  sns                             sts
sagemaker-featurestore-runtime  servicecatalog-appregistry      sqs                             support
sagemaker-runtime               servicediscovery                ssm                             swf
savingsplans                    ses                             ssm-contacts                    synthetics

% rm -f ~/.aws/config 
% rm -f ~/.aws/credentials

環境

% uname -mprsv
Darwin 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:47:26 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T8101 arm64 arm
% sw_vers
ProductName:    macOS
ProductVersion: 12.3.1
BuildVersion:   21E258
# Amazon Web Services # macOS