在 中為您的應用程式建立環境 AWS AppConfig - AWS AppConfig

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

在 中為您的應用程式建立環境 AWS AppConfig

對於每個 AWS AppConfig 應用程式,您可以定義一或多個環境。環境是 AppConfig 目標的邏輯部署群組,例如 BetaProduction環境、 AWS Lambda 函數或容器中的應用程式。您也可以定義應用程式子元件的環境,例如 WebMobileBack-end。您可以為每個環境設定 Amazon CloudWatch 警示。系統會在組態部署期間監控警示。如果觸發了警示,系統會回復組態。

開始之前

如果您想要讓 AWS AppConfig 復原組態以回應 CloudWatch 警示,則必須設定具有 許可的 AWS Identity and Access Management (IAM) 角色,以啟用 AWS AppConfig 來回應 CloudWatch 警示。您可以在下列程序中選擇此角色。如需詳細資訊,請參閱(建議) 設定自動復原的許可

建立 AWS AppConfig 環境 (主控台)

使用下列程序,透過 AWS Systems Manager 主控台建立 AWS AppConfig 環境。

建立環境
  1. 在 https://https://console.aws.amazon.com/systems-manager/appconfig/ 開啟 AWS Systems Manager 主控台。

  2. 在導覽窗格中,選擇應用程式,然後選擇應用程式的名稱以開啟詳細資訊頁面。

  3. 選擇環境索引標籤,然後選擇建立環境

  4. 對於 Name (名稱),輸入環境的名稱。

  5. 對於 Description (描述),輸入有關環境的資訊。

  6. (選用) 在監控區段中,選擇 IAM 角色欄位,然後選擇具有許可的 IAM 角色,以cloudwatch:DescribeAlarms呼叫您要監控警示的指標。

  7. CloudWatch 警示清單中,輸入要監控的 Amazon Resource Name ARNs) 一或多個指標。如果其中一個指標進入 ALARM 狀態, 便會 AWS AppConfig 轉返您的組態部署。如需建議指標的相關資訊,請參閱 監控部署的自動復原

  8. (選用) 在關聯延伸項目區段中,從清單中選擇延伸項目。如需詳細資訊,請參閱了解 AWS AppConfig 擴充功能

  9. (選用) 在標籤區段中,輸入索引鍵和選用值。您可以為資源指定最多 50 個標籤。

  10. 選擇 Create environment (建立環境)。

AWS AppConfig 會建立環境,然後顯示環境詳細資訊頁面。繼續執行「在 中建立組態設定檔 AWS AppConfig」。

建立 AWS AppConfig 環境 (命令列)

下列程序說明如何使用 AWS CLI (在 Linux 或 Windows 上) 或 AWS Tools for PowerShell 來建立 AWS AppConfig 環境。

逐步建立環境
  1. 開啟 AWS 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_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」。