

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# 適切なパイプラインのタイプの選択
<a name="pipeline-types-planning"></a>

パイプラインのタイプは、各パイプラインバージョンでサポートされている一連の特徴と機能に基づいて決定します。

以下に、各タイプのパイプラインのユースケースと特徴をまとめました。


****  

|  | V1 タイプ | V2 タイプ | 特性 |  |  | 
| --- | --- | --- | --- | --- | --- | 
| ユースケース |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/codepipeline/latest/userguide/pipeline-types-planning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/codepipeline/latest/userguide/pipeline-types-planning.html)  | 
| [アクションレベルの変数](https://docs.aws.amazon.com/codepipeline/latest/userguide/reference-variables.html) | サポート対象 | サポート | 
| [PARALLEL 実行モード](https://docs.aws.amazon.com/codepipeline/latest/userguide/welcome.html#concepts-how-it-works-executions-parallel) | サポート外 | サポート | 
| [パイプラインレベルの変数](https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-pipeline-variables.html) | サポート外 | サポート | 
| [QUEUED 実行モード](https://docs.aws.amazon.com/codepipeline/latest/userguide/welcome.html#concepts-how-it-works-executions-queued) | サポート外 | サポート | 
| [パイプラインステージのロールバック](https://docs.aws.amazon.com/codepipeline/latest/userguide/stage-rollback.html) | サポート外 | サポート | 
| [ソースリビジョンの上書き](https://docs.aws.amazon.com/codepipeline/latest/userguide/pipelines-trigger-source-overrides.html) | サポート外 | サポート | 
| [ステージ条件](https://docs.aws.amazon.com/codepipeline/latest/userguide/stage-conditions.html) | サポート外 | サポート | 
| [Git タグ、プルリクエスト、ブランチ、またはファイルパスのトリガーとフィルタリング](https://docs.aws.amazon.com/codepipeline/latest/userguide/pipelines-filter.html) | サポート外 | サポート | 
| [コマンドアクション](https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-Commands.html) | サポート外 | サポート | 
| [ スキップ結果を使用した入力条件の作成](https://docs.aws.amazon.com/codepipeline/latest/userguide/stage-conditions.html#stage-conditions-entry-skip) | サポート外 | サポート | 
| [ステージ障害時の自動再試行を設定する](https://docs.aws.amazon.com/codepipeline/latest/userguide/stage-retry.html#stage-retry-auto) | サポート外 | サポート | 

CodePipeline の料金については、[料金](https://aws.amazon.com/codepipeline/pricing/)を参照してください。

Python スクリプトを作成して実行することで、V1 タイプのパイプラインを V2 タイプのパイプラインに移行する潜在的なコストを分析できます。

**注記**  
以下のサンプルスクリプトは、デモンストレーションと評価のみを目的としています。これは見積もりツールではなく、V2 タイプのパイプラインを実際に使用した場合のコストを保証するものではありません。また、適用される可能性のある税金も含まれていません。CodePipeline の料金については、[料金](https://aws.amazon.com/codepipeline/pricing/)を参照してください。

**V1 タイプのパイプラインを V2 タイプのパイプラインに移行するコストを評価するのに役立つスクリプトを作成して実行するには**

1. Python をダウンロードしてインストールします。

1. ターミナルウィンドウを開きます。次のコマンドを実行して、**PipelineCostAnalyzer.py** という名前の新しい Python スクリプトを作成します。

   ```
   vi PipelineCostAnalyzer.py
   ```

1. 次のコードをコピーして、**PipelineCostAnalyzer.py** スクリプトに貼り付けます。

   ```
   import boto3
   import sys
   import math
   from datetime import datetime, timedelta, timezone
   
   if len(sys.argv) < 3:
       raise Exception("Please provide region name and pipeline name as arguments. Example usage: python PipelineCostAnalyzer.py us-east-1 MyPipeline")
   session = boto3.Session(profile_name='default', region_name=sys.argv[1])
   pipeline = sys.argv[2]
   codepipeline = session.client('codepipeline')
   
   def analyze_cost_in_v2(pipeline_name):
       if codepipeline.get_pipeline(name=pipeline)['pipeline']['pipelineType'] == 'V2':
           raise Exception("Provided pipeline is already of type V2.")
       total_action_executions = 0
       total_blling_action_executions = 0
       total_action_execution_minutes = 0
       cost = 0.0
       hasNextToken = True
       nextToken = ""
   
       while hasNextToken:
           if nextToken=="":
               response = codepipeline.list_action_executions(pipelineName=pipeline_name)
           else:
               response = codepipeline.list_action_executions(pipelineName=pipeline_name, nextToken=nextToken)
           if 'nextToken' in response:
               nextToken = response['nextToken']
           else:
               hasNextToken= False
           for action_execution in response['actionExecutionDetails']:
               start_time = action_execution['startTime']
               end_time = action_execution['lastUpdateTime']
               if (start_time < (datetime.now(timezone.utc) - timedelta(days=30))):
                   hasNextToken= False
                   continue
               total_action_executions += 1
               if (action_execution['status'] in ['Succeeded', 'Failed', 'Stopped']):
                   action_owner = action_execution['input']['actionTypeId']['owner']
                   action_category = action_execution['input']['actionTypeId']['category']
                   if (action_owner == 'Custom' or (action_owner == 'AWS' and action_category == 'Approval')):
                       continue
                   
                   total_blling_action_executions += 1
                   action_execution_minutes = (end_time - start_time).total_seconds()/60
                   action_execution_cost = math.ceil(action_execution_minutes) * 0.002
                   total_action_execution_minutes += action_execution_minutes
                   cost = round(cost + action_execution_cost, 2)
   
       print ("{:<40}".format('Activity in last 30 days:'))
       print ("| {:<40} | {:<10}".format('___________________________________', '__________________'))
       print ("| {:<40} | {:<10}".format('Total action executions:', total_action_executions))
       print ("| {:<40} | {:<10}".format('Total billing action executions:', total_blling_action_executions))
       print ("| {:<40} | {:<10}".format('Total billing action execution minutes:', round(total_action_execution_minutes, 2)))
       print ("| {:<40} | {:<10}".format('Cost of moving to V2 in $:', cost - 1))
   
   analyze_cost_in_v2(pipeline)
   ```

1. ターミナルまたはコマンドプロンプトから、アナライザースクリプトを作成したディレクトリに変更します。

   そのディレクトリから次のコマンドを実行します。*region* は、分析する V1 パイプラインを作成した AWS リージョン です。必要に応じて、特定のパイプラインの名前を指定して評価することもできます。

   ```
   python3 PipelineCostAnalyzer.py region --pipelineName
   ```

   例えば、**PipelineCostAnalyzer.py** という名前の Python スクリプトを実行するには、次のコマンドを使用します。この例で、リージョンは `us-west-2` です。

   ```
   python3 PipelineCostAnalyzer.py us-west-2
   ```
**注記**  
このスクリプトは、特定のパイプライン名を指定しない限り、指定した AWS リージョン 内のすべての V1 パイプラインを分析します。

1. 次のスクリプト出力例では、アクション実行のリスト、請求対象のアクション実行のリスト、アクション実行の合計ランタイム、アクションを V2 パイプラインで実行した場合の推定コストを確認できます。

   ```
   Activity in last 30 days: 
    | ___________________________________      | __________________
    | Total action executions:                 | 9         
    | Total billing action executions:         | 9         
    | Total billing action execution minutes:  | 5.59      
    | Cost of moving to V2 in $:               | -0.76
   ```

   この例で、最後の行の負の値は、V2 タイプのパイプラインに移行することで節約できる推定金額を表します。
**注記**  
スクリプト出力および関連するコストやその他の情報を示す例は、あくまでも推定です。デモンストレーションと評価のみを目的としており、実際の節約を保証するものではありません。CodePipeline の料金については、[料金](https://aws.amazon.com/codepipeline/pricing/)を参照してください。