AWS CLI

Setup

Setup on MacOS

The following steps show how to install the latest version of the AWS CLI by using the standard macOS user interface and your browser.

  1. In your browser, download the macOS pkg file: https://awscli.amazonaws.com/AWSCLIV2.pkg

  2. Run your downloaded file and follow the on-screen instructions. You can choose to install the AWS CLI in the following ways:

  3. For all users on the computer (requires sudo)

    • You can install to any folder, or choose the recommended default folder of /usr/local/aws-cli.
    • The installer automatically creates a symlink at /usr/local/bin/aws that links to the main program in the installation folder you chose.
  4. For only the current user (doesn't require sudo)

    • You can install to any folder to which you have write permission.
    • Due to standard user permissions, after the installer finishes, you must manually create a symlink file in your $PATH that points to the aws and aws_completer programs by using the following commands at the command prompt. If your $PATH includes a folder you can write to, you can run the following command without sudo if you specify that folder as the target's path. If you don't have a writable folder in your $PATH, you must use sudo in the commands to get permissions to write to the specified target folder. The default location for a symlink is /usr/local/bin/.

      $ sudo ln -s /folder/installed/aws-cli/aws /usr/local/bin/aws
      $ sudo ln -s /folder/installed/aws-cli/aws_completer /usr/local/bin/aws_completer
      

Note You can view debug logs for the installation by pressing Cmd+L anywhere in the installer. This opens a log pane that enables you to filter and save the log. The log file is also automatically saved to /var/log/install.log.

  1. To verify that the shell can find and run the aws command in your $PATH, use the following commands.
    $ which aws
    /usr/local/bin/aws 
    $ aws --version
    aws-cli/2.4.5 Python/3.8.8 Darwin/18.7.0 botocore/2.4.5
    

If the aws command cannot be found, you may need to restart your terminal or follow the instructions in Adding the AWS CLI to your path.

Setup on Windows

  1. Download and run the AWS CLI MSI installer for Windows (64-bit):

https://awscli.amazonaws.com/AWSCLIV2.msi

Alternatively, you can run the msiexec command to run the MSI installer.

C:\> msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi For various parameters that can be used with msiexec, see msiexec on the Microsoft Docs website.

  1. To confirm the installation, open the Start menu, search for cmd to open a command prompt window, and at the command prompt use the aws --version command.

C:\> aws --version aws-cli/2.4.5 Python/3.8.8 Windows/10 exe/AMD64 prompt/off If Windows is unable to find the program, you might need to close and reopen the command prompt window to refresh the path, or Adding the AWS CLI to your path.

Setup on Linux

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

Create Access key

IAM > Users > Security credentials > Create access key

Commands

# 設定access key
aws configure

# 列出 iam 所有 users
aws iam list-users

Add Profile

https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html

vi ~/.aws/credentials
[username]
aws_access_key_id = xxxx
aws_secret_access_key = aaaa

Select Profile

aws s3 ls --profile username
© Kimi Tsai all right reserved.            Updated : 2023-07-12 09:04:54

results matching ""

    No results matching ""

    results matching ""

      No results matching ""