在 AWS AppConfig 中为应用程序创建环境
对于每个 AWS AppConfig 应用程序,您可以定义一个或多个环境。环境是 AppConfig 目标的逻辑部署组,例如 Beta
或 Production
环境、AWS Lambda 功能或容器中的应用程序。您也可以为应用程序子组件定义环境,例如应用程序的 Web
、Mobile
和 Back-end
。您可以为每个环境配置 Amazon CloudWatch 警报。系统在部署配置期间监控警报。如果触发警报,系统将回滚配置。
开始前的准备工作
如果要允许 AWS AppConfig 回滚配置以响应 CloudWatch 警报,则必须配置一个 AWS Identity and Access Management (IAM) 角色并为其授予允许 AWS AppConfig 响应 CloudWatch 警报的权限。您可以在以下过程中选择该角色。有关更多信息,请参阅 (建议)配置自动回滚权限。
创建 AWS AppConfig 环境(控制台)
可以使用以下过程通过 AWS Systems Manager 控制台创建 AWS AppConfig 环境。
AWS AppConfig 将创建环境,然后显示 Environment details (环境详细信息) 页面。继续执行在 AWS AppConfig 中创建配置文件。
创建 AWS AppConfig 环境(命令行)
以下过程介绍如何使用 AWS CLI(在 Linux 或 Windows 上)或 AWS Tools for PowerShell 创建 AWS AppConfig 环境。
分步创建环境
-
打开 AWS 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_AWS 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_AWS 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_AWS 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
继续执行在 AWS AppConfig 中创建配置文件。