Amazon SES从实例配置文件元数据服务器检索凭证时出错. (客户端错误:404) [英] Amazon SES Error retrieving credentials from the instance profile metadata server. (Client error: 404)

查看:648
本文介绍了Amazon SES从实例配置文件元数据服务器检索凭证时出错. (客户端错误:404)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使AWS SES按以下方式工作时存在一些问题;我想从我的网站向用户发送电子邮件.看来凭据未得到验证,但是我使用了从IAM生成的正确凭据(我还尝试了服务器根密钥,但它给了我同样的错误).我已经用完了如何进一步解决/调试的想法,因此将不胜感激.

Am having some issues getting AWS SES working per below; I want to send an email to users from my website. Looks like the credentials are not being validated, however I have used the correct credentials generated from an IAM (I also tried the server root keys and it gave me the same error). I have run out of ideas of how to resolved/ debug any further so any steer would be greatly appreciated.

执行时收到错误:

从实例配置文件元数据服务器检索凭据时出错. (客户端错误:404)

Error retrieving credentials from the instance profile metadata server. (Client error: 404)

已采取的步骤

  1. 我已经设置了SES并验证了电子邮件地址等

  1. I have setup SES and validated the email addresses etc

我创建了一个具有对SES的完全访问权限"的IAM配置文件

I have created a IAM profile with 'Full access to SES'

我已经使用phar文件安装了适用于php的AWS开发工具包

I have installed the AWS SDK for php using the phar file

我已经在下面编写了php代码,直接提供了SES的正确安全访问代码

I have written the php code below providing the correct security access code directly of the SES

require 'aws/aws.phar';
use Aws\Ses\SesClient;

//More code here

$client = SesClient::factory(array(
    'key' => 'xxxxxxxxxxxxx',
    'secret' => 'xxxxxxxxxxx',
    'region' => 'us-west-2',
    'version' => '2010-12-01'
));

//code to build the $msg here as array

try{
     $result = $client->sendEmail($msg);

     //save the MessageId which can be used to track the request
     $msg_id = $result->get('MessageId');
     echo("MessageId: $msg_id");

     //view sample output
     print_r($result);
} catch (Exception $e) {
     echo($e->getMessage());
}
//view the original message passed to the SDK
print_r($msg);

感谢您的事先帮助-这始终是一个很棒的社区!!请让我知道我是否还能提供其他任何东西

Thank you for your help in advance - this is always a great community!! Please let me know if i can provide anything else

约翰

推荐答案

您可以使用多种方法向SDK提供凭据.请参阅文档:为SDK提供凭据

You can provide credentials to your SDK using multiple methods. See the documentation: Providing Credentials to SDK

1)使用您创建的IAM配置文件中的值设置环境变量:AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_DEFAULT_REGION.

1) Set the environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION with the values from the IAM profile you created.

2)代替1),您也可以创建〜/.aws/credentials文件.您可以在此处添加以下行:
[默认]
aws_access_key_id = YOUR_AWS_ACCESS_KEY_ID
aws_secret_access_key = YOUR_AWS_SECRET_ACCESS_KEY
aws_default_region =区域

2) Instead of 1), you can also create ~/.aws/credentials file. Here you can add the lines:
[default]
aws_access_key_id = YOUR_AWS_ACCESS_KEY_ID
aws_secret_access_key = YOUR_AWS_SECRET_ACCESS_KEY
aws_default_region = the region

1)或2)肯定会起作用,这很简单.

1) or 2) will definitely work and it is straight forward.

3)您也可以创建实例配置文件.您需要创建IAM角色和实例配置文件.创建实例时,需要为其分配实例配置文件.请参见第183页(如页面底部所示.主题名称为使用IAM角色向应用程序授予权限". 在本指南上运行"): AWS IAM用户指南了解步骤和过程.在这里,秘密密钥和访问密钥会自动被提取,您无需执行任何操作,您只需要使用步骤1设置默认区域即可(例如,导出AWS_DEFAULT_REGION = someregion).

3) You can also create instance profile. You need to create IAM role and instance profile. Your instance needs to have instance profile assigned when it is being created. See page 183 (as indicated on bottom of page. The topic name is "Using an IAM Role to Grant Permissions to Applications Running on Amazon EC2 Instances") of this guide: AWS IAM User Guide to understand the steps and procedure. Here, the secret key and access key are automatically picked up and you don't have to do anything. You just need to set default region using step 1) (i.e, export AWS_DEFAULT_REGION=someregion).

4)您已经尝试过第四种方法,可能是您的设置中存在一些我不知道的问题.

4) You have already tried the 4th method and may be there is some issue in your settings which I am not aware of.

这篇关于Amazon SES从实例配置文件元数据服务器检索凭证时出错. (客户端错误:404)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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