厨师食谱NoMethodError undefined方法`访问'为Chef :: Resource :: S3File

时间:2016-09-30 16:54:42

标签: amazon-web-services chef

我正在尝试从ec2实例上的s3下载文件并获得以下错误。我创建了数据库项access.json给出了密钥。请帮忙

================================================================================
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是数据库项目

实际食谱是

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

1 个答案:

答案 0 :(得分: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']