Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 Amazon Web Services 服务入门。本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
第 4 步:创建部署策略
网络 ACL 和安全组都允许 (因此可到达您的实例) 的发起 ping 的Amazon AppConfig部署策略定义配置部署的以下重要内容。
设置 |
说明 |
Deployment type (部署类型)
|
部署类型定义配置部署或推出方式。Amazon AppConfig 支持线性和指数部署类型。
-
线性:对于这种类型,Amazon AppConfig按在部署中均匀分布的增长系数处理部署。例如,使用步骤百分比 20 的线性部署最初使配置可用于 20% 的目标。在部署时间的五分之一过后,系统将百分比更新为 40%。这将一直持续到 100% 的目标设置为接收部署的配置。
-
指数的:对于这种类型,Amazon AppConfig使用以下公式以指数方式处理部署:G*(2^N) . 在这个公式中,G 是用户指定的步长百分比,N 是在配置部署到所有目标之前的步骤数。例如,如果将增长系数指定为 2,则系统将按如下方式推出配置:
2*(2^0)
2*(2^1)
2*(2^2)
以数字表示,部署的推出情况如下:2% 的目标、4% 的目标、8% 的目标,并持续到将配置部署到所有目标为止。
|
步骤百分比(增长系数)
|
该设置指定在部署的每个步骤中作为目标的调用方百分比。
|
Deployment time (部署时间)
|
该设置指定 Amazon AppConfig 部署到主机所花的时间。这不是超时值。这是一个按间隔处理部署的时段。 |
Bake time (烘焙时间)
|
此设置指定时间长度Amazon AppConfig亚马逊监视器CloudWatch在执行部署的下一步或将部署视为完成之前发出警报。如果在此期间触发了警报,Amazon AppConfig 将回滚部署。您必须为 Amazon AppConfig 配置权限以根据 CloudWatch 警报回滚。有关更多信息,请参阅 (可选)配置基于 CloudWatch 警报的回滚权限。
|
预定义的部署策略
Amazon AppConfig 包括预定义的部署策略,以帮助您快速部署配置。您可以在部署配置时选择以下选项之一,而不是创建自己的策略。
部署策略 |
说明 |
AppConfig.AllAtOnce
|
快速:
此策略会立即将配置部署到所有目标。系统监控亚马逊CloudWatch警报达 10 分钟。如果此时未收到任何警报,则部署已完成。如果在此期间触发了警报,AppConfig 将回滚部署。
|
AppConfig.Linear50PercentEvery30 秒
|
测试/演示:
此策略每 30 秒将配置部署到所有目标的一半,以进行一分钟部署。系统监控亚马逊CloudWatch警报达 1 分钟。如果此时未收到任何警报,则部署已完成。如果在此期间触发了警报,AppConfig 将回滚部署。 我们建议仅将此策略用于测试或演示目的,因为它持续时间和烘焙时间短。
|
AppConfig. Canary10%20 分钟
|
Amazon推荐:
此策略在 20 分钟内使用 10% 的增长系数以指数方式处理部署。系统监控亚马逊CloudWatch警报达 10 分钟。如果此时未收到任何警报,则部署已完成。如果在此期间触发了警报,AppConfig 将回滚部署。 我们建议将此策略用于生产部署,因为它与Amazon配置部署的最佳实践。
|
创建部署策略
您最多可以创建 20 个部署策略。在部署配置时,您可以选择最适合应用程序和环境的部署策略。
创建Amazon AppConfig部署策略(控制台)
使用以下过程可创建Amazon AppConfig通过使用Amazon Systems Manager控制台。
创建部署策略
打开Amazon Systems Manager控制台https://console.aws.amazon.com/systems-manager/appconfig/.
-
在导航窗格中,请选择 Amazon AppConfig。
-
选择 Deployment Strategies (部署策略) 选项卡,然后选择 Create deployment strategy (创建部署策略)。
-
对于 Name (名称),请输入部署策略的名称。
-
对于 Description (描述),请输入有关部署策略的信息。
-
对于 Deployment type (部署类型),选择类型。
-
对于 Step percentage (步骤百分比),请选择在部署的每个步骤中作为目标的调用方百分比。
-
对于 Deployment time (部署时间),请输入部署的总持续时间(以分钟或小时为单位)。
-
适用于Bake time (烘焙时间),请输入监控 Amazon 的总时间(以分钟或小时为单位)CloudWatch在执行部署的下一步或将部署视为完成之前发出警报。
-
在 Tags (标签) 部分中,输入一个键和可选的值。您最多可以为一个资源指定 50 个标签。
-
选择 Create deployment strategy (创建部署策略)。
继续执行第 5 步:部署配置。
创建Amazon AppConfig部署策略(命令行)
以下过程介绍如何使用Amazon CLI(在 Linux 或 Windows 上)或Amazon Tools for PowerShell要创建Amazon AppConfig部署策略。
逐步创建部署策略
安装并配置 Amazon CLI 或 Amazon Tools for PowerShell(如果尚未执行该操作)。
有关信息,请参阅安装或升级 Amazon 命令行工具。
-
运行以下命令以创建部署策略。
- 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_Amazon 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_Amazon 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_Amazon 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 Amazon 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 Amazon 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 Amazon 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