在 Amazon AppConfig 中为应用程序创建环境 - Amazon AppConfig
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

在 Amazon AppConfig 中为应用程序创建环境

对于每个 Amazon AppConfig 应用程序,您可以定义一个或多个环境。环境是由 AppConfig 目标组成的逻辑部署组,例如Production环境中的应用程序、Amazon Lambda函数或容器。Beta您也可以为应用程序子组件定义环境,例如应用程序的 WebMobileBack-end。您可以为每个环境配置 Amazon CloudWatch 警报。系统在部署配置期间监控警报。如果触发警报,系统将回滚配置。

开始前的准备工作

如果您想启用回滚配置Amazon AppConfig以响应 CloudWatch 警报,则必须为一个 Amazon Identity and Access Management (IAM) 角色配置一个Amazon AppConfig允许响应 CloudWatch 警报的权限。您可以在以下过程中选择该角色。有关更多信息,请参见 (可选)根据警报配置回滚权限 CloudWatch

创建 Amazon AppConfig 环境(控制台)

可以使用以下过程通过 Amazon Systems Manager 控制台创建 Amazon AppConfig 环境。

创建环境
  1. 打开Amazon Systems Manager控制台,网址为 https://console.aws.amazon.com/systems-manager/appconfig/

  2. Applications (应用程序) 选项卡上,选择您在在 Amazon AppConfig 中为应用程序创建命名空间中创建的应用程序,然后选择 View details (查看详细信息)

  3. Environments (环境) 选项卡上,选择 Create environment (创建环境)

  4. 对于 Name (名称),请输入环境的名称。

  5. 对于 Description (描述),请输入有关环境的信息。

  6. IAM 角色 列表中,选择具有在触发警报时回滚配置的权限的 IAM 角色。

  7. CloudWatch 警报列表中,选择一个或多个要监控的警报。 Amazon AppConfig如果其中一个警报进入警报状态,则回滚您的配置部署。

  8. Tags (标签) 部分中,输入一个键和可选的值。您最多可以为一个资源指定 50 个标签。

  9. 选择创建环境

Amazon AppConfig 将创建环境,然后显示 Environment details (环境详细信息) 页面。继续执行在 Amazon AppConfig 中创建配置文件

创建 Amazon AppConfig 环境(命令行)

以下过程介绍如何使用 Amazon CLI(在 Linux 或 Windows 上)或 Amazon Tools for PowerShell 创建 Amazon AppConfig 环境。

逐步创建环境
  1. 打开 Amazon CLI。

  2. 运行以下命令以创建环境。

    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 中创建配置文件