Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅
中国的 Amazon Web Services 服务入门
(PDF)。
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
在 Amazon AppConfig中为应用程序创建环境
您可以为每个 Amazon AppConfig 应用程序定义一个或多个环境。环境是由 AppConfig 目标组成的逻辑部署组,例如Production
环境中的应用程序、 Amazon Lambda 函数或容器。Beta
您也可以为应用程序子组件定义环境,例如应用程序的 Web
、Mobile
和 Back-end
。您可以为每个环境配置 Amazon CloudWatch 警报。系统在部署配置期间监控警报。如果触发警报,系统将回滚配置。
开始前的准备工作
如果您想启用回滚配置 Amazon AppConfig 以响应 CloudWatch 警报,则必须为一个 Amazon Identity and Access Management (IAM) 角色配置一个 Amazon AppConfig 允许响应 CloudWatch 警报的权限。您可以在以下过程中选择该角色。有关更多信息,请参阅 (可选)根据警报配置回滚权限 CloudWatch 。
创建 Amazon AppConfig 环境(控制台)
使用以下过程通过 Amazon Systems Manager
控制台创建 Amazon AppConfig 环境。
创建环境
打开 Amazon Systems Manager 控制台,网址为 https://console.aws.amazon.com/systems-manager/appconfig/。
-
在应用程序选项卡上,选择应用程序的名称以打开详细信息页面。
选择 “环境” 选项卡,然后选择 “创建环境”。
-
对于 Name (名称),请输入环境的名称。
-
对于 Description (描述),请输入有关环境的信息。
-
(可选)在监控器部分中,选择 IAM 角色字段,然后选择一个有权在触发警报时回滚配置的 IAM 角色。
-
在CloudWatch 警报列表中,选择一个或多个要监控的警报。 Amazon AppConfig 如果其中一个警报进入警报状态,则回滚您的配置部署。
(可选)在关联分机部分中,从列表中选择一个分机。有关更多信息,请参阅 关于 Amazon AppConfig 扩展。
-
(可选)在标签部分,输入密钥和可选值。您最多可以为一个资源指定 50 个标签。
-
选择创建环境。
Amazon AppConfig 创建环境,然后显示环境详细信息页面。继续执行在 Amazon AppConfig中创建配置文件。
创建 Amazon AppConfig 环境(命令行)
以下过程介绍如何使用 Amazon CLI (在 Linux 或 Windows 上)或 Amazon Tools for PowerShell 如何创建 Amazon AppConfig 环境。
分步创建环境
-
打开 Amazon CLI.
-
运行以下命令以创建环境。
- Linux
-
aws appconfig create-environment \
--application-id The_application_ID
\
--name A_name_for_the_environment
\
--description A_description_of_the_environment
\
--monitors "AlarmArn=ARN_of_the_Amazon_CloudWatch_alarm
,AlarmArnRole=ARN_of_the_IAM role_for_Amazon AppConfig_to_monitor_AlarmArn
" \
--tags User_defined_key_value_pair_metadata_of_the_environment
- Windows
-
aws appconfig create-environment ^
--application-id The_application_ID
^
--name A_name_for_the_environment
^
--description A_description_of_the_environment
^
--monitors "AlarmArn=ARN_of_the_Amazon_CloudWatch_alarm
,AlarmArnRole=ARN_of_the_IAM role_for_Amazon AppConfig_to_monitor_AlarmArn
" ^
--tags User_defined_key_value_pair_metadata_of_the_environment
- PowerShell
-
New-APPCEnvironment `
-Name Name_for_the_environment
`
-ApplicationId The_application_ID
-Description Description_of_the_environment
`
-Monitors @{"AlarmArn=ARN_of_the_Amazon_CloudWatch_alarm
,AlarmArnRole=ARN_of_the_IAM role_for_Amazon AppConfig_to_monitor_AlarmArn
"} `
-Tag Hashtable_type_user_defined_key_value_pair_metadata_of_the_environment
系统将返回类似于以下内容的信息。
- Linux
-
{
"ApplicationId": "The application ID",
"Id": "The_environment ID",
"Name": "Name of the environment",
"State": "The state of the environment",
"Description": "Description of the environment",
"Monitors": [
{
"AlarmArn": "ARN of the Amazon CloudWatch alarm",
"AlarmRoleArn": "ARN of the IAM role for AppConfig to monitor AlarmArn"
}
]
}
- Windows
-
{
"ApplicationId": "The application ID",
"Id": "The environment ID",
"Name": "Name of the environment",
"State": "The state of the environment"
"Description": "Description of the environment",
"Monitors": [
{
"AlarmArn": "ARN of the Amazon CloudWatch alarm",
"AlarmRoleArn": "ARN of the IAM role for AppConfig to monitor AlarmArn"
}
]
}
- PowerShell
-
ApplicationId : The application ID
ContentLength : Runtime of the command
Description : Description of the environment
HttpStatusCode : HTTP Status of the runtime
Id : The environment ID
Monitors : {ARN of the Amazon CloudWatch alarm, ARN of the IAM role for AppConfig to monitor AlarmArn}
Name : Name of the environment
Response Metadata : Runtime Metadata
State : State of the environment
继续执行在 Amazon AppConfig中创建配置文件。