厨师aws客户端

时间:2017-03-03 10:23:51

标签: amazon-web-services amazon-s3 chef

我不太清楚如何使用this aws cookbook。我的目标是从我的s3存储桶下载一些文件。根据{{​​3}},我已将此内容设置在我的食谱中:

aws = data_bag_item('aws', 'dev')

aws_s3_file '/tmp/authz.war' do
  bucket 'living-artifacts-dev'
  remote_path '/authz/authz.war'
  aws_access_key aws['aws_access_key_id']
  aws_secret_access_key aws['aws_secret_access_key']
  region 'eu-central-1'
end

所有值都正确填充,我也尝试使用aws-cli测试它们。然而,厨师客户正在收到这样的信息:

=========================================================================
Error executing action `create` on resource 'aws_s3_file[/tmp/authz.war]'
=========================================================================

Net::HTTPServerException
------------------------
remote_file[/tmp/authz.war] (/var/chef/cache/cookbooks/aws/providers/s3_file.rb line 40) had an error: Net::HTTPServerException: 403 "Forbidden"

我该怎么调试呢?

修改

我已经使用aws命令客户端对其进行了测试。我首先使用aws configure设置凭据,并且我提供了请求的值。所以,这个命令:

aws s3 cp s3://living-artifacts-dev/authz/authz.war authz.war

正确执行并下载文件。

修改

更详细的错误消息:

==> default:   * aws_s3_file[/tmp/authz.war] action create
==> default:
==> default:     * chef_gem[aws-sdk] action install
==> default: [2017-03-03T11:25:16+00:00] INFO: chef_gem[aws-sdk] installed aws-sdk at ~> 2.2
==> default:
==> default:       - install version ~> 2.2 of package aws-sdk
==> default: [2017-03-03T11:25:16+00:00] INFO: Remote and local files do not match, running create operation.
==> default:     * chef_gem[aws-sdk] action install (up to date)
==> default:     * remote_file[/tmp/authz.war] action create
==> default: [2017-03-03T11:25:16+00:00] INFO: HTTP Request Returned 403 Forbidden:
==> default: [2017-03-03T11:25:16+00:00] WARN: remote_file[/tmp/authz.war] cannot be downloaded from https://living-artifacts-dev.s3.e
u-central-1.amazonaws.com/authz/authz.war?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=sFo6JjohgYi%2BYi4Ut7pTy9EGVDCG89IROX%2Bw7E
RR%2F20170303%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20170303T112516Z&X-Amz-Expires=300&X-Amz-SignedHeaders=host&X-Amz-Signatur
e=f3c2b371ad4e1fe24745459adf0463c708e0363a139b598b04e40789c43ded7d: 403 "Forbidden"

2 个答案:

答案 0 :(得分:0)

remote_path '/authz/authz.war'

中删除第一个斜杠

以下是AWS cookbook documentation

中的示例
aws_s3_file '/tmp/foo' do
  bucket 'i_haz_an_s3_buckit'
  remote_path 'path/in/s3/bukket/to/foo'
  aws_access_key aws['aws_access_key_id']
  aws_secret_access_key aws['aws_secret_access_key']
  region 'us-west-1'
end

答案 1 :(得分:0)

你有一个禁止的错误

 403 "Forbidden"

如果在AWS上附加了适当的IAM策略,您需要确保您的系统,该策略至少具有存储桶读取功能,特别是您需要的文件。