

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

# 設定 AWS AppConfig 代理程式將組態副本寫入磁碟
<a name="appconfig-agent-how-to-use-additional-features-write-to-disk"></a>

您可以設定 AWS AppConfig 代理程式自動將組態副本以純文字形式儲存到磁碟。此功能可讓具有從磁碟讀取組態資料的應用程式的客戶與 整合 AWS AppConfig。

此功能並非設計做為組態備份功能使用。 AWS AppConfig 代理程式不會從複製到磁碟的組態檔案讀取。如果您想要將組態備份到磁碟，請參閱[將 AWS AppConfig 代理程式與 Amazon EC2 ](https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-integration-ec2.html#appconfig-integration-ec2-configuring)搭配使用或[將 AWS AppConfig 代理程式與 Amazon ECS 和 Amazon EKS 搭配使用的 和](https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-integration-containers-agent.html#appconfig-integration-containers-agent-configuring) `BACKUP_DIRECTORY``PRELOAD_BACKUP`環境變數。

**警告**  
請注意有關此功能的下列重要資訊：  
儲存到磁碟的組態會以*純文字*形式儲存，且可供人類讀取。請勿針對包含敏感資料的組態啟用此功能。
此功能會寫入本機磁碟。使用檔案系統許可的最低權限原則。如需詳細資訊，請參閱[實作最低權限存取](appconfig-security.md#appconfig-security-least-privilege-access)。

**啟用寫入組態複製到磁碟**

1. 編輯資訊清單。

1. 選擇 AWS AppConfig 您要寫入磁碟的組態，並新增`writeTo`元素。請見此處範例：

   ```
   {
       "application_name:environment_name:configuration_name": {
           "writeTo": {
               "path": "path_to_configuration_file"
           }
       }
   }
   ```

   請見此處範例：

   ```
   {
       "MyTestApp:MyTestEnvironment:MyNewConfiguration": {
           "writeTo": {
               "path": "/tmp/aws-appconfig/mobile-app/beta/enable-mobile-payments"
           }
       }
   }
   ```

1. 儲存您的變更。每次部署新的組態資料時， configuration.json 檔案都會更新。

**驗證寫入組態複製到磁碟是否正常運作**  
您可以透過檢閱 AWS AppConfig 代理程式日誌來驗證組態的副本是否正在寫入磁碟。具有「INFO 將組態 '*application*：*environment*：*configuration*' 寫入 *file\$1path*」的`INFO`日誌項目表示 AWS AppConfig 代理程式將組態副本寫入磁碟。

請見此處範例：

```
[appconfig agent] 2023/11/13 11:33:27 INFO AppConfig Agent 2.0.x
[appconfig agent] 2023/11/13 11:33:28 INFO serving on localhost:2772
[appconfig agent] 2023/11/13 11:33:28 INFO retrieved initial data for 'MobileApp:Beta:EnableMobilePayments' in XX.Xms
[appconfig agent] 2023/11/13 17:05:49 INFO wrote configuration 'MobileApp:Beta:EnableMobilePayments' to /tmp/configs/your-app/your-env/your-config.json
```