本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
步驟 1:準備申請
若要準備應用程式,您必須先建立應用程式、指派復原則,然後從輸入來源匯入應用程式資源。如需有關用來準備 AWS Resilience Hub APIs應用程式的詳細資訊,請參閱下列主題:
建立應用程式
若要在中建立新的應用程式 AWS Resilience Hub,您必須呼叫CreateApp
API並提供唯一的應用程式名稱。如需此項目的詳細資訊API,請參閱https://docs.aws.amazon.com/resilience-hub/latest/APIReference/API_CreateApp.html。
下面的例子演示了如何在使用創建一個新newApp
的應 AWS Resilience Hub 用程序CreateApp
API。
請求
aws resiliencehub create-app --name newApp
回應
{ "app": { "appArn": "
<App_ARN>
", "name": "newApp", "creationTime": "2022-10-26T19:48:00.434000+03:00", "status": "Active", "complianceStatus": "NotAssessed", "resiliencyScore": 0.0, "tags": {}, "assessmentSchedule": "Disabled" } }
建立復原原則
建立應用程式之後,您必須建立復原原則,讓您能夠使用. CreateResiliencyPolicy
API 如需此項目的詳細資訊API,請參閱https://docs.aws.amazon.com/resilience-hub/latest/APIReference/API_CreateResiliencyPolicy.html。
下面的例子演示了如何在使newPolicy
用創建您的應 AWS Resilience Hub 用程序CreateResiliencyPolicy
API。
請求
aws resiliencehub create-resiliency-policy \ --policy-name newPolicy --tier NonCritical \ --policy '{"AZ": {"rtoInSecs": 172800,"rpoInSecs": 86400}, \ "Hardware": {"rtoInSecs": 172800,"rpoInSecs": 86400}, \ "Software": {"rtoInSecs": 172800,"rpoInSecs": 86400}}'
回應
{ "policy": { "policyArn": "
<Policy_ARN>
", "policyName": "newPolicy", "policyDescription": "", "dataLocationConstraint": "AnyLocation", "tier": "NonCritical", "estimatedCostTier": "L1", "policy": { "AZ": { "rtoInSecs": 172800, "rpoInSecs": 86400 }, "Hardware": { "rtoInSecs": 172800, "rpoInSecs": 86400 }, "Software": { "rtoInSecs": 172800, "rpoInSecs": 86400 } }, "creationTime": "2022-10-26T20:48:05.946000+03:00", "tags": {} } }
從輸入來源匯入資源並監視匯入狀態
AWS Resilience Hub 提供下列項目,APIs將資源匯入至您的應用程式:
-
ImportResourcesToDraftAppVersion
— 這API可讓您將資源從不同的輸入來源匯入應用程式的草稿版本。如需此項目的詳細資訊API,請參閱https://docs.aws.amazon.com/resilience-hub/latest/APIReference/API_ImportResourcesToDraftAppVersion.html。 -
PublishAppVersion
-這將API發布應用程序的新版本以及更新版本 AppComponents。如需此項目的詳細資訊API,請參閱https://docs.aws.amazon.com/resilience-hub/latest/APIReference/API_PublishAppVersion.html。 -
DescribeDraftAppVersionResourcesImportStatus
— 這API可讓您監視資源至應用程式版本的匯入狀態。如需此項目的詳細資訊API,請參閱https://docs.aws.amazon.com/resilience-hub/latest/APIReference/API_DescribeDraftAppVersionResourcesImportStatus.html。
下面的例子演示了如何在使用中將資源導入到您的應 AWS Resilience Hub 用程序ImportResourcesToDraftAppVersion
API。
請求
aws resiliencehub import-resources-to-draft-app-version \ --app-arn
<App_ARN>
\ --terraform-sources '[{"s3StateFileUrl":<S3_URI>
}]'
回應
{ "appArn": "
<App_ARN>
", "appVersion": "draft", "sourceArns": [], "status": "Pending", "terraformSources": [ { "s3StateFileUrl":<S3_URI>
} ] }
下列範例會示範如何在使用中手動將資源新增至應 AWS Resilience Hub 用程式CreateAppVersionResource
API。
請求
aws resiliencehub create-app-version-resource \ --app-arn
<App_ARN>
\ --resource-name "backup-efs" \ --logical-resource-id '{"identifier": "backup-efs"}' \ --physical-resource-id '<Physical_resource_id_ARN>
' \ --resource-type AWS::EFS::FileSystem \ --app-components '["new-app-component"]'
回應
{ "appArn": "
<App_ARN>
", "appVersion": "draft", "physicalResource": { "resourceName": "backup-efs", "logicalResourceId": { "identifier": "backup-efs" }, "physicalResourceId": { "identifier": "<Physical_resource_id_ARN>
", "type": "Arn" }, "resourceType": "AWS::EFS::FileSystem", "appComponents": [ { "name": "new-app-component", "type": "AWS::ResilienceHub::StorageAppComponent", "id": "new-app-component" } ] } }
下列範例顯示如何監視 AWS Resilience Hub 使用中資源的匯入狀態DescribeDraftAppVersionResourcesImportStatus
API。
請求
aws resiliencehub describe-draft-app-version-resources-import-status \ --app-arn
<App_ARN>
回應
{ "appArn": "
<App_ARN>
", "appVersion": "draft", "status": "Success", "statusChangeTime": "2022-10-26T19:55:18.471000+03:00" }
發佈應用程式的草稿版本並指派恢復原則
在執行評估之前,您必須先發佈應用程式的草稿版本,並將復原原則指派給應用程式的已發行版本。
若要發佈應用程式的草稿版本並指派恢復原則
-
若要發佈應用程式的草稿版本,請使用
PublishAppVersion
API。如需此項目的詳細資訊API,請參閱https://docs.aws.amazon.com/resilience-hub/latest/APIReference/API_PublishAppVersion.html。下列範例會示範如何在使用中發佈應 AWS Resilience Hub 用程式的草稿版本
PublishAppVersion
API。請求
aws resiliencehub publish-app-version \ --app-arn
<App_ARN>
回應
{ "appArn": "
<App_ARN>
", "appVersion": "release" } -
使用將復原原則套用至應用
UpdateApp
API程式的發行版本。如需此項目的詳細資訊API,請參閱https://docs.aws.amazon.com/resilience-hub/latest/APIReference/API_UpdateApp.html。下列範例顯示如何將復原原則套用至使用中的應 AWS Resilience Hub 用
UpdateApp
API程式發行版本。請求
aws resiliencehub update-app \ --app-arn
<App_ARN>
\ --policy-arn<Policy_ARN>
回應
{ "app": { "appArn": "
<App_ARN>
", "name": "newApp", "policyArn": "<Policy_ARN>
", "creationTime": "2022-10-26T19:48:00.434000+03:00", "status": "Active", "complianceStatus": "NotAssessed", "resiliencyScore": 0.0, "tags": { "resourceArn": "<App_ARN>
" }, "assessmentSchedule": "Disabled" } }