LoginSignup
6
3

More than 3 years have passed since last update.

EC2 Image Builderのパイプラインをアップデートする方法

Last updated at Posted at 2019-12-14

EC2 Image Builderとは

AMI作成を自動化してくれるツール(パッケージインストール等をやってくれる)。

Developers.IO:EC2のイメージ作成を劇的に効率化するEC2 Image Builderが発表されました! #reinvent
Qiita:EC2 Image Builder を触ってみました。

パイプラインのアップデートできない

早速使ってみたのだが、
AMI作成用のパイプライン(Image pipelines)を作った後、コンソールを見てもパッケージ(ビルドコンポーネント)の追加方法が分からなかった。
後で追加したいパッケージが増えたらどうすんの?
正確に言うと、レシピのNew Versionは作れるのだが、パイプラインに反映できない(なんじゃこりゃ)。

パイプラインのアップデートできた

コンソールだけだとできなくて、AWS CLIだとできる事が判明1

update-image-pipeline
get-image-pipeline

<手順>

アップデート前はこんな感じ
Screenshot from 2019-12-13 23-39-44.png

  1. まずはコンソールから、レシピのNew Versionを作る。

    Image Builderコンソール→Recipes

    Screenshot from 2019-12-14 02-37-12.png
    対象のレシピを選択して、Actions→Create New Version

    Screenshot from 2019-12-13 23-40-53.png
    設定をしていく。※「Version」の入力を忘れないように。
    Screenshot from 2019-12-13 23-41-22.png
    レシピの作成が終わったところ。
    Screenshot from 2019-12-13 23-42-02.png

  2. AWS CLIで「Image pipelines」の設定を取得。

    aws imagebuilder get-image-pipeline \
    --image-pipeline-arn \
    <Image pipelinesのARN> \
    --query 'imagePipeline.{imageRecipeArn:imageRecipeArn,infrastructureConfigurationArn:infrastructureConfigurationArn}'
    
    {
        "imageRecipeArn": "arn:aws:imagebuilder:<Region>:<accountID>:image-recipe/<RecipeName>/1.0.0",
        "infrastructureConfigurationArn": "arn:aws:imagebuilder:<Region>:<accountID>:infrastructure-configuration/<PipelineName>-infrastructureconfiguration-xxxxxxxxxxxx"
    }
    
    # エラーが出たら、AWS CLIのバージョンが低いかも(コマンドが存在しないのでエラーになる)。  
    usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
    To see help text, you can run:
    
      aws help
      aws <command> help
      aws <command> <subcommand> help
    aws: error: argument command: Invalid choice, valid choices are:
    
    # 少なくとも 1.16.302 で動く事を確認。
    $ aws --version
    aws-cli/1.16.302 Python/3.7.4 Linux/5.3.12-1-MANJARO botocore/1.13.38
    $ aws imagebuilder help
    IMAGEBUILDER()                                                  IMAGEBUILDER()
    
    NAME
           imagebuilder -
    
    DESCRIPTION
           Amazon  Elastic Compute Cloud Image Builder provides a one-stop-shop to
           automate the image management processes.  You  configure  an  automated 
    
  3. AWS CLIで「Image pipelines」のレシピを更新する。

    aws imagebuilder update-image-pipeline \
    --image-pipeline-arn \
    <Image pipelinesのARN> \
    --infrastructure-configuration-arn \
    <2.で取得した"infrastructureConfigurationArn"> \
    --image-recipe-arn \
    <1.で新しく作ったRecipesのARN>
    
    {
     "requestId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    }
    
  4. AWS CLIで「Image pipelines」の設定を確認(2. と同じコマンド)。

    aws imagebuilder get-image-pipeline \
    --image-pipeline-arn \
    <Image pipelinesのARN> \
    --query 'imagePipeline. 
    {imageRecipeArn:imageRecipeArn,infrastructureConfigurationArn:infrastructureConfigurationArn}'
    
    {
        "imageRecipeArn": "arn:aws:imagebuilder:<Region>:<accountID>:image-recipe/<RecipeName>/1.0.1",
        "infrastructureConfigurationArn": "arn:aws:imagebuilder:<Region>:<accountID>:infrastructure-configuration/<PipelineName>-infrastructureconfiguration-xxxxxxxxxxxx"
    }
    

    ※imageRecipeArnの末尾のバージョンが上がってる

コンソールでもアップデートできてる事を確認!
Screenshot from 2019-12-13 23-45-50.png


  1. AWSサポートに問い合わせた結果、APIはあるが現時点(2019/12/03)で、コンソールから操作できないとのこと(こういうパターンはまれによくある)。 

6
3
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
6
3