Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing require for aws-sdk? #181

Closed
shortdudey123 opened this issue Oct 29, 2015 · 17 comments
Closed

missing require for aws-sdk? #181

shortdudey123 opened this issue Oct 29, 2015 · 17 comments

Comments

@shortdudey123
Copy link
Contributor

When using the aws_s3_file LWRP, I get an error saying uninitialized constant Aws. Looks like this is because stuff from the Aws namespace is used before the gem is required.

Anyone else seeing this? If so, I can put in a PR

Recipe: XXXXX::XXXXX
  * aws_s3_file[/var/chef/cache/XXXXX] action create

    ================================================================================
    Error executing action `create` on resource 'aws_s3_file[/var/chef/cache/XXXXX]'
    ================================================================================

    NameError
    ---------
    uninitialized constant Aws

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/aws/providers/s3_file.rb:33:in `do_s3_file'
    /var/chef/cache/cookbooks/aws/providers/s3_file.rb:9:in `block in class_from_file'

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/XXXXX/recipes/XXXXX.rb

     25: aws_s3_file "#{Chef::Config[:file_cache_path]}/#{filename}" do
     26:   bucket 'XXXXX'
     27:   remote_path "XXXXX/#{filename}"
     28:   aws_secret_access_key bag['aws_secret_key']
     29:   aws_access_key_id bag['aws_access_key']
     30:   not_if { ::File.exist?("#{Chef::Config[:file_cache_path]}/#{filename}") }
     31: end
     32: 

Gem versions

$ gem list | grep aws
aws-sdk (2.1.33)
aws-sdk-core (2.1.33)
aws-sdk-resources (2.1.33)
aws-sdk-v1 (1.66.0)
$
$ /opt/chef/embedded/bin/gem list | grep aws
aws-sdk (2.0.48)
aws-sdk-core (2.0.48)
aws-sdk-resources (2.0.48)
$
@zanzan42
Copy link

zanzan42 commented Nov 2, 2015

Yes. This has been a problem for anybody using OpsWorks ever since Amazon went to the new version of aws-sdk. I haven't been using this cookbook (or any dependent on it) ever since that happened, due to the uninitialized constant error. Been using the awscli cookbook from awslabs for S3 gets instead.

However, there is another cookbook for tagging OpsWorks instances that I'd like to use, and it's dependent on the ec2 tagging LWRP in this cookbook as well (which has the same problem). So if the issue can be fixed, I'm all for it.

@shortdudey123
Copy link
Contributor Author

@zanzan42 glad i am not the only one haha
I will put a PR in for this

shortdudey123 added a commit to shortdudey123/chef-aws that referenced this issue Nov 17, 2015

Verified

This commit was signed with the committer’s verified signature.
The aws-sdk gem namespace was being called before it was required.
Solves sous-chefs#181
@doitagain
Copy link

I'm experiencing the same issue using aws-sdk 2.2.0.

aws-sdk (2.2.0)
aws-sdk-core (2.2.0)
aws-sdk-resources (2.2.0)

Is there a workaround that can be used for the short term?

@shortdudey123
Copy link
Contributor Author

@doitagain see the PR above

@doitagain
Copy link

@shortdudey123 thanks for responding so quickly. I see the PR, but I'm new to chef and don't understand how to reference that branch in my Berksfile or metadata.rb. If you have time, would you mind providing an example?

This is what I've tried:

Berksfile

cookbook 'aws', branch: 'add_needed_gem_require'

metadata.rb

depends 'aws'

@shortdudey123
Copy link
Contributor Author

look at the Git Location section of http://berkshelf.com/v2.0/

@doitagain
Copy link

Clear now... thank you!

@notwaf
Copy link

notwaf commented Nov 20, 2015

+1

@doitagain
Copy link

I've tested the above but keep get the same error. What is the last known stable version for s3 file? 2.7.2 seems unusable.

@shortdudey123
Copy link
Contributor Author

@doitagain error output?

@tas50
Copy link
Contributor

tas50 commented Nov 25, 2015

I think this is part of a larger problem where we shouldn't require the aws::default recipe in order to install / load the SDK gem. Instead we should dynamically install the gem when needed and require the sdk as needed. The fix in #183 partially fixes it, but as @miketheman pointed out the real fix is more complex and should probably be done. I'm still a bit partial to getting the mini-fix in place now, but I'm going to look into what it will take to refactor things the right way.

@shortdudey123
Copy link
Contributor Author

@tas50 Thanks!

@doitagain
Copy link

@shortdudey123 my error output is the same that you reported.

================================================================================
Error executing action `create` on resource 'aws_s3_file[/usr/local/jdk1.8.0_65.tar.gz]'
================================================================================


NameError
---------
uninitialized constant Aws


Cookbook Trace:
---------------
/var/lib/aws/opsworks/cache.stage2/cookbooks/aws/providers/s3_file.rb:34:in `do_s3_file'
/var/lib/aws/opsworks/cache.stage2/cookbooks/aws/providers/s3_file.rb:10:in `block in class_from_file'

@doitagain
Copy link

I apologize for being so confused over usage of s3_file. I've read through the docs, the above PR, this issue, and the OpsWorks docs repeatedly and can't figure out how to add the aws recipe to the run_list on OpsWorks. I've tried executing aws::default directly and still result in the "uninitialized constant Aws" error.

I realize this may be out of scope, but clarification on use of the aws cookbook on OpsWorks would be greatly appreciated.

@mmamane
Copy link

mmamane commented Dec 19, 2015

@doitagain downgrade to 2.5.0. There seems to be too much confusion over the use of anything more recent.

@tas50
Copy link
Contributor

tas50 commented Jan 19, 2016

We have a fix on master for this. It'll go out with the next release.

@tas50 tas50 closed this as completed Jan 19, 2016
@zanzan42
Copy link

zanzan42 commented May 3, 2016

This is still a problem for OpsWorks recipes which use aws as a dependency. While I punted and use a different s3_file cookbook (which has been included in the OpsWorks base set since about November), tagging recipes which depend on aws still continue to fail with the uninitialized constant Aws error.

For instance, this one:

https://github.com/stuart-warren/chef-aws-tag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants