本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
在 AWS AppConfig中为应用程序创建环境
您可以为每个 AWS AppConfig 应用程序定义一个或多个环境。环境是由 AppConfig 目标组成的逻辑部署组,例如Production
环境中的应用程序、 AWS Lambda 函数或容器。Beta
您也可以为应用程序子组件定义环境,例如应用程序的 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 创建环境,然后显示环境详细信息页面。继续执行在 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中创建配置文件。