我的目标是使用AWS Beanstalk,创建应用程序环境类型'Worker',它将处理繁重的加载任务,这个worker基于我们的Rails应用程序。 我创建AWS Beanstalk工作者环境: 环境层:Ruby,在64位Amazon Linux上为1.9.3 环境类型:单实例 (我确实尝试过运行Ruby 2.0(Puma)的64位Amazon Linux 2014.03 v1.0.3,同样失败的结果)
解决了GEMS和数据库连接的所有问题后,我坚持启动“aws-sqs”队列客户端。它应该侦听Queue并对Worker应用程序执行HTTP请求。 我为此Worker实例的ENV变量提供了AWS_ACCESS_KEY_ID和AWS_SECRET_KEY:
$ export | grep AWS
declare -x AWS_ACCESS_KEY_ID="AK...........Q"
declare -x AWS_AUTO_SCALING_HOME="/opt/aws/apitools/as"
declare -x AWS_CLOUDWATCH_HOME="/opt/aws/apitools/mon"
declare -x AWS_ELB_HOME="/opt/aws/apitools/elb"
declare -x AWS_IAM_HOME="/opt/aws/apitools/iam"
declare -x AWS_PATH="/opt/aws"
declare -x AWS_RDS_HOME="/opt/aws/apitools/rds"
declare -x AWS_SECRET_KEY="Hp.....fI"
declare -x EB_CONFIG_SYSTEM_AWSEBAGENTID=""
declare -x EB_CONFIG_SYSTEM_AWSEBREFERRERID=""
这是日志输出:
2014-05-19T13:58:59Z init: initializing aws-sqsd 1.0 (2013-12-23)
2014-05-19T13:58:59Z start: polling https://sqs.us-east-1.amazonaws.com/201266939336/awseb-e-dq8cqaud2z-stack-AWSEBWorkerQueue-18836XBBHNDUD
2014-05-19T13:58:59Z fatal: AWS::Errors::MissingCredentialsError:
Missing Credentials.
Unable to find AWS credentials. You can configure your AWS credentials
a few different ways:
* Call AWS.config with :access_key_id and :secret_access_key
<<<
* On EC2 you can run instances with an IAM instance profile and credentials
will be auto loaded from the instance metadata service on those
instances.
* Call AWS.config with :credential_provider. A credential provider should
either include AWS::Core::CredentialProviders::Provider or respond to
the same public methods.
= Ruby on Rails
In a Ruby on Rails application you may also specify your credentials in
the following ways:
* Via a config initializer script using any of the methods mentioned above
(e.g. RAILS_ROOT/config/initializers/aws-sdk.rb).
* Via a yaml configuration file located at RAILS_ROOT/config/aws.yml.
This file should be formated like the default RAILS_ROOT/config/database.yml
file.
此外,我的Rails应用程序中的config / initializers / aws-sdk.rb包含以下内容:
AWS.config(
access_key_id: ENV["AWS_ACCESS_KEY_ID"],
secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"])
守护进程aws-sqs根本没有启动。 我有机会以其他方式配置aws-sqs吗?
答案 0 :(得分:3)
您用于Elastic Beanstalk的实例配置文件可能没有工作环境所需的权限。
您能否确保您的IAM实例个人资料中包含上述链接中列出的所有权限? (以下复制以供参考)
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "QueueAccess",
"Action": [
"sqs:ChangeMessageVisibility",
"sqs:DeleteMessage",
"sqs:ReceiveMessage"
],
"Effect": "Allow",
"Resource": "*"
},
{
"Sid": "MetricsAccess",
"Action": [
"cloudwatch:PutMetricData"
],
"Effect": "Allow",
"Resource": "*"
}
]
}