我不太清楚如何使用this aws cookbook。我的目標是從我的s3存儲桶下載一些文件。據documentation,我已經設置此內容在我的食譜:廚師aws客戶端
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
被正確執行和文件被下載。
EDIT
更詳細的錯誤消息:
==> 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"
錯誤提示,您無權訪問存儲桶。仔細檢查您的aws密鑰和帳戶的權限。 –
我用'aws-cli'測試過它。我用行爲編輯了帖子。看來一切正常... – Jordi
remote_path'artifacts/authz/authz.war'是不同的 –