LoginSignup
12
5

More than 3 years have passed since last update.

はじめに

CodeBuild で使用できる AWS CLI のバージョンはデフォルトでは 1 です。
そのため、 --output yaml 等の一部のオプションが使用できません。
そこで、CodeBuild で AWS CLI のバージョンを 2 にアップデートする方法を調べました。

概要

Installing the AWS CLI version 2 on Linux に則り AWS CLI version 2 にアップデートするだけです。

buildspec.yml
version: 0.2

phases:
  install:
    commands:
      - curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
      - unzip awscliv2.zip
      - ls -l /root/.pyenv/shims/aws
      - ./aws/install --bin-dir /root/.pyenv/shims --install-dir /usr/local/aws-cli --update
  build:
    commands:
      - aws --version

出力結果抜粋

[Container] 2020/08/20 06:25:10 Running command aws --version
aws-cli/2.0.41 Python/3.7.3 Linux/4.14.186-110.268.amzn1.x86_64 exec-env/AWS_ECS_EC2 exe/x86_64.ubuntu.18

補足

aws command のパスは以下の通り

[Container] 2020/08/20 06:25:07 Running command which aws
/root/.pyenv/shims/aws
12
5
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
12
5