配置 Amazon AppConfig 代理以将配置副本写入磁盘 - Amazon AppConfig
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

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

配置 Amazon AppConfig 代理以将配置副本写入磁盘

您可以将 Amazon AppConfig Agent 配置为以纯文本形式自动将配置副本存储到磁盘。此功能使客户能够将从磁盘读取配置数据的应用程序与 Amazon AppConfig集成。

此功能不是为用作配置备份功能而设计的。 Amazon AppConfig 代理无法读取复制到磁盘的配置文件。如果要将配置备份到磁盘,请参阅在 Amazon 上使用 Amazon AppConfig 代理 EC2或在 Amazon ECS BACKUP_DIRECTORY 和 Amazon EKS 上使用 Amazon AppConfig 代理的和PRELOAD_BACKUP环境变量

警告

请注意有关此功能的以下重要信息:

  • 保存到磁盘的配置以纯文本 形式存储,便于用户阅读。请勿为包含敏感数据的配置启用此功能。

  • 此功能将内容写入本地磁盘。对文件系统权限使用最低权限原则。有关更多信息,请参阅 实施最低权限访问

启用将配置副本写入磁盘
  1. 编辑清单。

  2. 选择 Amazon 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" } } }
  3. 保存您的更改。每次部署新的配置数据时,都会更新 configuration.json 文件。

验证将配置副本写入磁盘是否正常工作

您可以通过查看 Amazon AppConfig 代理日志来验证配置副本是否正在写入磁盘。带有 “INFO 将配置写入 'application:environment: configuration '到file_path” 的INFO日志条目表示 Amazon 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