通过 AWS PHP SDK 和 AWS AppConfig 访问时,内容字段为空

问题描述

每个人都知道如何将 AWS AppConfig 与 AWS SDK PHP 结合使用。 我的特定用例是,我在 EC2 实例上运行一个简单的 PHP 应用程序,并希望接收在 AppConfig 中编写的 JSON 配置。

use Aws\AppConfig\Exception\AppConfigException;
use Aws\AppConfig\AppConfigClient;

$appConfigClient = new AppConfigClient(['version' => 'latest','region' => 'ap-south-1']);
$clientid  = uniqid('',true);
$params = [
    'Application' => $APP_CONfig_APP,'ClientId' => $clientid,'Configuration' => $APP_CONfig_CONfigURATION_PROFILE,'Environment' => $APP_CONfig_ENVIRONMENT
];

$response = $appConfigClient->getConfiguration($params);
$config = $response['Content'];

此外,我正在通过管理员 IAM 角色授权 AppConfig,因此,在这方面没有问题,我能够获得以下输出

{ "Content": {},"ConfigurationVersion": "1","ContentType": "application\/octet-stream","@Metadata": { "statusCode": 200,client_id=60696",and some more fields...}

但问题是我没有获得 AppConfig 内容,但能够提取有关数据的元数据。 所以,任何尝试过这个的人请帮助我。

解决方法

我还没有使用 AppConfig,但正在阅读它。

如果您查看下面链接页面上“重要”框中的信息,则会显示如果 appconfig 数据没有更改,则不会返回内容部分。

因此,原始请求可能有数据,但随后的任何请求都没有检测到更改,因此不会通过

发送任何内容

可能值得更新 AppConfig 中的数据,然后运行新请求以查看内容是否按要求填充。

见: https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-retrieving-the-configuration.html