

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 建立部署策略
<a name="appconfig-creating-deployment-strategy-create"></a>

如果您不想使用其中一個預先定義的部署策略，您可以建立自己的部署策略。您最多可以建立 20 個部署策略。部署組態時，您可以選擇最適合應用程式和環境的部署策略。

## 建立 AWS AppConfig 部署策略 （主控台）
<a name="appconfig-creating-deployment-strategy-create-console"></a>

使用下列程序，透過 AWS Systems Manager 主控台建立 AWS AppConfig 部署策略。

**建立部署策略**

1. 在 https：//[https://console.aws.amazon.com/systems-manager/appconfig/](https://console.aws.amazon.com/systems-manager/appconfig/) 開啟 AWS Systems Manager 主控台。

1. 在導覽窗格中，選擇**部署策略**，然後選擇**建立部署策略**。

1. 對於 **Name (名稱)**，輸入部署策略的名稱。

1. 對於 **Description (描述)**，輸入有關部署策略的資訊。

1. 對於 **Deployment type (部署類型)**，請選擇類型。

1. 對於 **Step percentage (步驟百分比)**，選擇要在部署的每個步驟期間鎖定的呼叫端百分比。

1. 對於 **Deployment time (部署時間)**，輸入部署的總持續時間 (以分鐘或小時為單位)。

1. 對於**製作時間**，輸入總時間，以分鐘或小時為單位，監控 Amazon CloudWatch 警示，然後再繼續進行部署的下一個步驟或考慮完成部署。

1. 在 **Tags (標籤)** 區段中，輸入一個鍵和一個選用值。您可以為資源指定最多 50 個標籤。

1. 選擇 **Create deployment strategy (建立部署策略)**。

**重要**  
如果您為 建立組態設定檔 AWS CodePipeline，則必須在 CodePipeline 中建立管道，指定 AWS AppConfig 做為*部署提供者*。您不需要執行 [部署組態](appconfig-deploying.md)。不過，您必須設定用戶端來接收應用程式組態更新，如中所述[在沒有 AWS AppConfig 代理程式的情況下擷取組態資料](about-data-plane.md)。如需建立指定 AWS AppConfig 做為部署提供者的管道的相關資訊，請參閱*AWS CodePipeline 《 使用者指南*》中的[教學課程：建立使用 AWS AppConfig 做為部署提供者的管道](https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-AppConfig.html)。

繼續執行「[部署組態](appconfig-deploying.md)」。

## 建立 AWS AppConfig 部署策略 （命令列）
<a name="appconfig-creating-deployment-strategy-create-commandline"></a>

下列程序說明如何使用 AWS CLI （在 Linux 或 Windows 上） 或 AWS Tools for PowerShell 來建立 AWS AppConfig 部署策略。

**逐步建立部署策略**

1. 開啟 AWS CLI。

1. 執行下列命令來建立部署策略。

------
#### [ Linux ]

   ```
   aws appconfig create-deployment-strategy \
     --name A_name_for_the_deployment_strategy \
     --description A_description_of_the_deployment_strategy \
     --deployment-duration-in-minutes Total_amount_of_time_for_a_deployment_to_last \
     --final-bake-time-in-minutes Amount_of_time_AWS AppConfig_monitors_for_alarms_before_considering_the_deployment_to_be_complete \
     --growth-factor The_percentage_of_targets_to_receive_a_deployed_configuration_during_each_interval \
     --growth-type The_linear_or_exponential_algorithm_used_to_define_how_percentage_grows_over_time \
     --replicate-to To_save_the_deployment_strategy_to_a_Systems_Manager_(SSM)_document \
     --tags User_defined_key_value_pair_metadata_of_the_deployment_strategy
   ```

------
#### [ Windows ]

   ```
   aws appconfig create-deployment-strategy ^
     --name A_name_for_the_deployment_strategy ^
     --description A_description_of_the_deployment_strategy ^
     --deployment-duration-in-minutes Total_amount_of_time_for_a_deployment_to_last ^
     --final-bake-time-in-minutes Amount_of_time_AWS AppConfig_monitors_for_alarms_before_considering_the_deployment_to_be_complete ^
     --growth-factor The_percentage_of_targets_to_receive_a_deployed_configuration_during_each_interval ^
     --growth-type The_linear_or_exponential_algorithm_used_to_define_how_percentage_grows_over_time ^
     --name A_name_for_the_deployment_strategy ^
     --replicate-to To_save_the_deployment_strategy_to_a_Systems_Manager_(SSM)_document ^
     --tags User_defined_key_value_pair_metadata_of_the_deployment_strategy
   ```

------
#### [ PowerShell ]

   ```
   New-APPCDeploymentStrategy ` 
     --Name A_name_for_the_deployment_strategy ` 
     --Description A_description_of_the_deployment_strategy `
     --DeploymentDurationInMinutes Total_amount_of_time_for_a_deployment_to_last `
     --FinalBakeTimeInMinutes Amount_of_time_AWS AppConfig_monitors_for_alarms_before_considering_the_deployment_to_be_complete `
     --GrowthFactor The_percentage_of_targets_to_receive_a_deployed_configuration_during_each_interval `
     --GrowthType The_linear_or_exponential_algorithm_used_to_define_how_percentage_grows_over_time `
     --ReplicateTo To_save_the_deployment_strategy_to_a_Systems_Manager_(SSM)_document `
     --Tag Hashtable_type_User_defined_key_value_pair_metadata_of_the_deployment_strategy
   ```

------

   系統會傳回如下資訊。

------
#### [ Linux ]

   ```
   {
      "Id": "Id of the deployment strategy",
      "Name": "Name of the deployment strategy",
      "Description": "Description of the deployment strategy",
      "DeploymentDurationInMinutes": "Total amount of time the deployment lasted",
      "GrowthType": "The linear or exponential algorithm used to define how percentage grew over time",
      "GrowthFactor": "The percentage of targets that received a deployed configuration during each interval",  
      "FinalBakeTimeInMinutes": "The amount of time AWS AppConfig monitored for alarms before considering the deployment to be complete",
      "ReplicateTo": "The Systems Manager (SSM) document where the deployment strategy is saved"
   }
   ```

------
#### [ Windows ]

   ```
   {
      "Id": "Id of the deployment strategy",
      "Name": "Name of the deployment strategy",
      "Description": "Description of the deployment strategy",
      "DeploymentDurationInMinutes": "Total amount of time the deployment lasted",
      "GrowthType": "The linear or exponential algorithm used to define how percentage grew over time",
      "GrowthFactor": "The percentage of targets that received a deployed configuration during each interval",  
      "FinalBakeTimeInMinutes": "The amount of time AWS AppConfig monitored for alarms before considering the deployment to be complete",
      "ReplicateTo": "The Systems Manager (SSM) document where the deployment strategy is saved"
   }
   ```

------
#### [ PowerShell ]

   ```
   ContentLength               : Runtime of the command
   DeploymentDurationInMinutes : Total amount of time the deployment lasted
   Description                 : Description of the deployment strategy
   FinalBakeTimeInMinutes      : The amount of time AWS AppConfig monitored for alarms before considering the deployment to be complete
   GrowthFactor                : The percentage of targets that received a deployed configuration during each interval
   GrowthType                  : The linear or exponential algorithm used to define how percentage grew over time
   HttpStatusCode              : HTTP Status of the runtime
   Id                          : The deployment strategy ID
   Name                        : Name of the deployment strategy
   ReplicateTo                 : The Systems Manager (SSM) document where the deployment strategy is saved
   ResponseMetadata            : Runtime Metadata
   ```

------