LoginSignup
2
1

More than 3 years have passed since last update.

AWS CodeBuildでサポートされているはずのランタイムが利用できない場合の対処

Last updated at Posted at 2020-07-08

※ 2020年7月8日現在
※ AWSにはフィードバック済み

イメージのバージョンを上げると解決する。

現象

GitHubとAWS CodeBuildを連携して、テストの自動実行をしていた。
プロジェクトで利用しているNode.jsのバージョンを10から12に上げる機会があり、同じくCodeBuildで扱うNode.jsのバージョンも上げることにした。

CodeBuildで扱うNode.jsは、CodeBuildでサポートされているランタイムを利用していた。
また、バージョンはbuildspec.ymlで管理していた。

12.xに対応していない可能性があるので、ドキュメントも念のため確認した。

https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html
phases/install/runtime-versions
The following supported runtimes can be specified.

Runtime name Version Specific version Specific major and latest minor version Latest version Image/Images
nodejs 12 nodejs: 12 nodejs: 12.x nodejs: latest All Amazon Linux 2 images
Ubuntu standard:3.0
Ubuntu standard:4.0

(追記)AWSにフィードバックを送信したところ、"All Amazon Linux 2 images"の部分を"All supported Amazon Linux 2 images"に変更してくれました。

イメージはamazonlinux2-x86_64-standard:1.0を利用していた。
表のImage/Imagesの値には、All Amazon Linux 2 imagesと書かれている。
どうやらうまいこと12.xに上げることができそうだ。

そこで、buildspec.ymlの内容を以下のように変更してみた。


version: 0.2

phases:
  install:
    runtime-versions:
-     nodejs: 10
+     nodejs: 12

  pre_build:
    commands:
      - npm install

  build:
    commands:
      - npm test -- --coverage

artifacts:
  files:
    - coverage/lcov-report/**/*

早速CIを実行してみたら。。エラーが発生してしまった。


YAML_FILE_ERROR: Unknown runtime version named '12' of nodejs. This build image has the following versions: 10, 8

12がサポートされていない。。ドキュメントではサポートしている記載があるのにどうして。。
12という記述方法がまずかったのかもしれない。12.xで修正し、再度実行してみたが、今度は違うエラーが発生してしまった。


YAML_FILE_ERROR: Major version of alias '12.x' is not supported in runtime 'nodejs'.

対処

もしかしたらイメージに問題があるのかもしれない。
試しに利用しているイメージを以下のように変更してみた。

amazonlinux2-x86_64-standard:1.0amazonlinux2-x86_64-standard:3.0

CIを実行してみたところ、エラーが発生しなくなった!
どうやらAWSのドキュメントの修正漏れだったようだ。(もしくは私が何か見逃しているか)

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