【发布时间】:2015-02-08 14:54:39
【问题描述】:
我正在尝试通过 web api 将 SNS 消息发送到 android。 从http://aws.amazon.com/developers/getting-started/php/下载并安装SDK
运行 sample.php 时出现以下错误:
Fatal error: Uncaught exception 'Aws\Common\Exception\InstanceProfileCredentialsException' with message 'Error retrieving credentials from the instance profile metadata server. When you are not running inside of Amazon EC2, you must provide your AWS access key ID and secret access key in the "key" and "secret" options when creating a client or provide an instantiated Aws\Common\Credentials\CredentialsInterface object. ([curl] 28: Connection timed out after 5016 milliseconds [url] http://169.254.169.254/latest/meta-data/iam/security-credentials/)' in C:\xampp\htdocs\aws-php\vendor\aws\aws-sdk-php\src\Aws\Common\InstanceMetadata\InstanceMetadataClient.php:85 Stack trace: #0 C:\xampp\htdocs\aws-php\vendor\aws\aws-sdk-php\src\Aws\Common\Credentials\RefreshableInstanceProfileCredentials.php(52): Aws\Common\InstanceMetadata\InstanceMetadataClient->getInstanceProfileCredentials() #1 C:\xampp\htdocs\aws-php\vendor\aws\aws-sdk-php\src\Aws\Common\Credentials\AbstractRefreshableCredentials.php(54): Aws\Common\Credentials\Refreshable in C:\xampp\htdocs\aws-php\vendor\aws\aws-sdk-php\src\Aws\Common\InstanceMetadata\InstanceMetadataClient.php on line 85
关于这个主题的一些指导会对我有很大帮助
【问题讨论】:
-
这意味着您没有正确配置您的凭据。请参阅 AWS SDK for PHP 用户指南中的 Providing Credentials to the SDK。
-
我已经使用 AWS_ACCESS_KEY_ID 和 AWS_SECRET_ACCESS_KEY 配置了 /.aws/credentials 文件,如此处所述。还是不行
-
@Ravindra 你找到解决方案了吗?我也有同样的问题
-
@JeremyLindblom 我正在为创建这个文件的文档而苦苦挣扎。我正在运行一个 EC2 实例,并通过 Putty 尝试了
sudo nano ~/.aws/credentials、sudo mkdir /.aws+cd /.aws+sudo nano credentials- 没有任何东西想要工作,而且网络上的信息很少。有什么想法吗? -
凭证文件最适合用于本地开发环境。我会在 EC2 上使用 IAM 角色凭证:docs.aws.amazon.com/aws-sdk-php/guide/latest/…
标签: php amazon-web-services google-cloud-messaging aws-sdk amazon-sns