

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

# 为在 Amazon ECS 和 Amazon EKS 中运行的应用程序检索配置数据
<a name="appconfig-integration-containers-agent-retrieving-data"></a>

您可以使用 HTTP localhost 调用，从 AWS AppConfig 代理中检索在 Amazon ECS 和 Amazon EKS 中运行的应用程序的配置数据。以下示例将 `curl` 与 HTTP 客户端一起使用。您可以使用应用程序语言或可用库支持的任何可用 HTTP 客户端调用代理。

**注意**  
如果应用程序使用正斜杠（例如“test-backend/test-service”），要检索配置数据，将需要使用 URL 编码。

**检索任何已部署配置的完整内容**

```
$ curl "http://localhost:2772/applications/application_name/environments/environment_name/configurations/configuration_name"
```

**从 `Feature Flag` 类型的 AWS AppConfig 配置中检索单个标志及其属性**

```
$ curl "http://localhost:2772/applications/application_name/environments/environment_name/configurations/configuration_name?flag=flag_name"
```

**从 `Feature Flag` 类型的 AWS AppConfig 配置访问多个标志及其属性**

```
$ curl "http://localhost:2772/applications/application_name/environments/environment_name/configurations/configuration_name?flag=flag_name_one&flag=flag_name_two"
```

该调用会在 HTTP 标头中返回配置元数据，包括配置版本、内容类型和配置版本标签（如果适用）。Agent 响应的正文包含配置内容。示例如下：

```
HTTP/1.1 200 OK
Configuration-Version: 1
Content-Type: application/json
Date: Tue, 18 Feb 2025 20:20:16 GMT
Content-Length: 31

My test config
```