AWS PHP SDK凭证误差ε [英] AWS PHP SDK Credentials error S

查看:1835
本文介绍了AWS PHP SDK凭证误差ε的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到想要创建一个 SNSClient 对象时,下面的错误。

  InstanceProfileCredentialsException在InstanceMetadataClient.php行85:从实例配置文件元数据服务器错误检索凭证。如果你是不是亚马逊的EC2中运行,你必须创建客户端时提供的AWS访问的键和秘密选项键ID和秘密访问键或提供实例化的AWS \公用\证书\ CredentialsInterface对象。 (客户端错误响应
[状态code] 404
[原因短语]未找到
[URL] http://169.254.169.254/latest/meta-data/iam/security-credentials/)
 

我不明白为什么我有这样的错误,当我有我的 aws.php 在我laravel设置的config文件夹中。这里的访问密钥和秘密密钥存储

我真的不喜欢这一点,因为这将导致我的凭据存储在文件夹的设置,而其他的可能SFTP成。

我也有在我的服务器根目录文件夹中的AWS证书和配置文件,在这样的路径:〜/ .aws / ,但由于某些原因,应用程序不开心。

下面就是我的code是这样的:

 有关公共函数(){

    //实例化一个客户端从PROJECT1配置文件的凭据
    $ snsClient = SnsClient ::工厂(阵列(
            '个人资料'=> '默认',
            '区域'=> 美西2',
        ));

    //获取应用程序的终结点

    $ iOS_AppArn =ARN:AWS:SNS:美国西2:235418406768:应用程序/ APNS_SANDBOX / ClashTarget;

    $ iOS_model = $ snsClient-> listEndpointsByPlatformApplication(阵列('PlatformApplicationArn'=> $ iOS_AppArn));
}
 

请注意,我现在用的是默认轮廓,其应采取的凭据从哪里配置和证书文件存储在根目录AWS

目前,作为一种临时解决方案,我这样做: HTTP: //blog.ianholden.com/aws-s3-with-php-on-apache/ 这使得一切工作,但我不快乐有我的生活在应用程序code凭证键。这感觉不对。

有人能指导我得到这个错误解决了吗?

更新1:评论:什么是配置的含量在〜/ .aws / 这是在〜/ .aws / 文件夹中的配置文件

内容

  [默认]
输出= JSON
地区= US-西2
 

解决方案

从@他的问题,帕文的评论中,他显示了证书的内容〜/ .aws ,似乎有2个文件存在。我只有一个文件

  $猫〜/ .aws /凭证
[默认]
aws_access_key_id = blablabla
aws_secret_access_key = blablabla
地区= US-西2
 

I get the following error when trying to create an SNSClient object.

InstanceProfileCredentialsException in InstanceMetadataClient.php line 85: 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. (Client error response
[status code] 404
[reason phrase] Not Found
[url] http://169.254.169.254/latest/meta-data/iam/security-credentials/)

I don't understand why I have this error when I have my aws.php in the config folder of my laravel setup. Here the access key and secret key are stored.

I don't really like this since this causes my credentials to be stored in the folder setup where other's may SFTP into.

What I also have is the aws credentials and config files in my server root folder, in a path like this: ~/.aws/ but for some reason the application is not happy.

Here's what my code looks like:

public function about(){

    // Instantiate a client with the credentials from the project1 profile
    $snsClient = SnsClient::factory(array(
            'profile' => 'default',
            'region'  => 'us-west-2',
        ));

    // Get the application's endpoints

    $iOS_AppArn = "arn:aws:sns:us-west-2:235418406768:app/APNS_SANDBOX/ClashTarget";

    $iOS_model = $snsClient->listEndpointsByPlatformApplication(array('PlatformApplicationArn' => $iOS_AppArn));
}

Note that I am using the default profile which should take the credentials from the root aws directory where the config and credential files are stored.

For now, as a temporary solution I did this: http://blog.ianholden.com/aws-s3-with-php-on-apache/ which makes everything work but I'm not happy having my credential keys living in the application code. It doesn't feel right.

Can someone guide me in getting this error resolved please?

Update 1: Comment: What is the content of config at ~/.aws/ This is the content of the config file in the ~/.aws/ folder

[default]
output = json
region = us-west-2

解决方案

From @Pavan's comment on his question in which he shows the contents of the credentials file in ~/.aws, it seems that there are 2 files there. I only have one file

$ cat ~/.aws/credentials
[default]
aws_access_key_id = blablabla
aws_secret_access_key = blablabla
region = us-west-2

这篇关于AWS PHP SDK凭证误差ε的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆