本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
在 中為您的應用程式建立環境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環境。
建立環境
在 https://https://console.aws.amazon.com/systems-manager/appconfig/ 開啟AWS Systems Manager主控台。
-
在導覽窗格中,選擇應用程式,然後選擇應用程式的名稱以開啟詳細資訊頁面。
-
選擇環境索引標籤,然後選擇建立環境。
-
對於 Name (名稱),輸入環境的名稱。
-
對於 Description (描述),輸入有關環境的資訊。
-
(選用) 在監控區段中,選擇 IAM 角色欄位,然後選擇具有許可的 IAM 角色,以cloudwatch:DescribeAlarms呼叫您要監控警示的指標。
-
在 CloudWatch 警示清單中,輸入要監控的 Amazon Resource Name ARNs) 一或多個指標。如果其中一個指標進入 ALARM 狀態, 會AWS AppConfig復原您的組態部署。如需建議指標的資訊,請參閱 監控部署以進行自動復原
-
(選用) 在關聯延伸項目區段中,從清單中選擇延伸項目。如需詳細資訊,請參閱了解 AWS AppConfig 延伸模組。
-
(選用) 在標籤區段中,輸入索引鍵和選用值。您可以為資源指定最多 50 個標籤。
-
選擇 Create environment (建立環境)。
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」。