2016-09-30 168 views
0

我想從ec3實例下載s3的文件並獲取低於錯誤。我創建了提供密鑰的數據庫項目access.json。請幫助廚師食譜NoMethodError廚師::資源:: S3File未定義的方法`訪問'

================================================================================ 
Recipe Compile Error in /var/chef/cache/cookbooks/s3_file/recipes/default.rb 
================================================================================ 

NoMethodError 
------------- 
undefined method `access' for Chef::Resource::S3File 

Cookbook Trace: 
--------------- 
    /var/chef/cache/cookbooks/s3_file/recipes/default.rb:13:in `block in from_file' 
    /var/chef/cache/cookbooks/s3_file/recipes/default.rb:10:in `from_file' 

Relevant File Content: 
---------------------- 
/var/chef/cache/cookbooks/s3_file/recipes/default.rb: 

    6: # 
    7: # All rights reserved - Do Not Redistribute 
    8: # 
    9: ws = data_bag_item('cred1', 'access.json') 
10: s3_file 'xxxxxxxxxxx' do 
11: bucket 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 
12: remote_path 'xxxxxxxxxxxxxxxxxxxx' 
13>> aws_access_key_id access.json['aws_access_key_id'] 
14: aws_secret_access_key access.json['aws_secret_access_key'] 
15: region 'us-west-1' 
16: owner "root" 
17: group "root" 
18: mode 0777 
19: end 
20: 
21: 

access.json是databag項目

實際配方

ws = data_bag_item('cred1', 'access.json') 
s3_file 'xxxxxxxxx' do 
    bucket 'xxxxxxxxxxxxxxx' 
    remote_path 'xxxxxxxxxxxx' 
    aws_access_key_id access.json['aws_access_key_id'] 
    aws_secret_access_key access.json['aws_secret_access_key'] 
    region 'us-west-1' 
    owner "root" 
    group "root" 
    mode 0777 
end 

回答

0

在下面一行:

aws_access_key_id access.json['aws_access_key_id'] 

有一個名爲access某處變量?

您正在檢索數據包項目,但將其存儲在名爲ws的變量中。鑑於此,您可能需要更改上面的行(以及後面的行),如下所示:

aws_access_key_id ws['aws_access_key_id'] 
aws_secret_access_key ws['aws_secret_access_key'] 
+0

感謝您的回覆。現在,它得到下述錯誤: NoMethodError ------------- 未定義的方法'區域」的廚師::資源:: S3File 如果我刪除它,然後它給以下錯誤: RestClient :: ResourceNotFound ---------------------------- 404 Resource Not Found – Dave

+0

's3_file'食譜不支持' region'屬性,所以這可能是S3上的權限錯誤或憑證不正確。我建議閱讀[s3_file食譜](https://supermarket.chef.io/cookbooks/s3_file)上的文檔。 – vase