by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Daniel Collis-Puro
@djcp
What I hope is a basic question: is there a way to create a vpc with tags in a single call? Or must one use ec2_client.create_vpc and then Aws::EC2::Vpc#create_tags in a subsequent call?
If the answer is "no", that's fine. When I attempted to use Aws::EC2::Vpc#create_tags right after creating the VPC, though, I got an Aws::EC2::Errors::InvalidVpcIDNotFound error, I assume because it hadn't propagated across aws. Is this what I'd want a waiter for?
Trevor Rowe
@trevorrowe
Currently it is two API calls to create and then tag. Waiters can poll and wait for a resource to enter a given state. You should be able to call ec2_client.wait_until(:vpc_available, vpc_ids:[id]) and then call your tagging operation.
Tim Tischler
@tischler
What does Aws::S3::Errors::PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint. mean?

'''
client = Aws::S3::Client.new(
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['SECRET_ACCESS_KEY'],
region: 'us-west-2'
)

resp = client.list_objects( bucket: 'my-backup')

'''

Tim Tischler
@tischler
and the result is
'''
Aws::S3::Errors::PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
/Users/tischler/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.26/lib/seahorse/client/plugins/raise_response_errors.rb:15:in call' /Users/tischler/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.26/lib/aws-sdk-core/plugins/s3_sse_cpk.rb:18:incall'
/Users/tischler/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.26/lib/seahorse/client/plugins/param_conversion.rb:22:in call' /Users/tischler/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.26/lib/aws-sdk-core/plugins/response_paging.rb:10:incall'
/Users/tischler/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.26/lib/seahorse/client/plugins/response_target.rb:18:in call' /Users/tischler/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.26/lib/seahorse/client/request.rb:70:insend_request'
/Users/tischler/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.26/lib/seahorse/client/base.rb:216:in `block (2 levels) in define_operation_methods'
'''

baah...

client = Aws::S3::Client.new(
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['SECRET_ACCESS_KEY'],
region: 'us-west-2'
)

resp = client.list_objects( bucket: 'my-backup')

and

Aws::S3::Errors::PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
/Users/tischler/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.26/lib/seahorse/client/plugins/raise_response_errors.rb:15:in call' /Users/tischler/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.26/lib/aws-sdk-core/plugins/s3_sse_cpk.rb:18:incall'
/Users/tischler/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.26/lib/seahorse/client/plugins/param_conversion.rb:22:in call' /Users/tischler/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.26/lib/aws-sdk-core/plugins/response_paging.rb:10:incall'
/Users/tischler/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.26/lib/seahorse/client/plugins/response_target.rb:18:in call' /Users/tischler/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.26/lib/seahorse/client/request.rb:70:insend_request'
/Users/tischler/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.26/lib/seahorse/client/base.rb:216:in `block (2 levels) in define_operation_methods'
Trevor Rowe
@trevorrowe

If you rescue that error, you can inspect the HTTP response body:

begin
  resp = client.list_objects( bucket: 'my-backup’)
rescue Aws::S3::Errors:: PermanentRedirect => error
  puts error.context.http_response.body.read
end

My guess is the bucket you are addressing is not in the ‘us-west-2’ region. You can call #get_bucket_location to determine the actual region.

Nikola Velkovski
@parabolic
Hi Folks
can somebody help me with the instance role credentials
I am having hard time getting it to work
my code works perfect with credntials from a json file but I need to utilize the instance role
permisiions
can somebody give me an working example of AssumeRoleCredentials
Nikola Velkovski
@parabolic
Ok found it
if anybody needs an example ping me
:)
Daniel Collis-Puro
@djcp
Thanks for your answer yesterday, @trevorrowe
Robin van Wijngaarden
@robinvw1
i'm doing a head_object with Ruby AWS SDK (v2). according to the documentation I should catch on Aws::S3::Errors::NoSuchKey -> http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html#head_object-instance_method
but i'm receiving Aws::S3::Errors::NotFound
is the documentation up-to-date?
Trevor Rowe
@trevorrowe
@robinvw1 That is a documentation bug / limitation. Normally, if you perform an operation against an object that does not exist, e.g. a GET object, Amazon S3 will return a response with an XML body indicating that there is no such key. However, per the HTTP spec, the response to a HEAD request may not have a body. For this reason, the SDK has no error message or code to parse, so it falls back on NotFound.
I've considered guessing, but this proved problematic, as it is not possible to know if the 404 is a result of a no such bucket or no such key.

I've considered guessing, but this proved problematic, as it is not possible to know if the 404 is a result of a no such bucket or no such key.

We need to change this in the docs to reflect the SDK will raise a NotFound.

chrishawk
@chrishawk
Does anyone know if there is a way of writing data to an s3 object? It looks like object.write was gotten rid of in place of object.upload_file in the new v2 sdk
Trevor Rowe
@trevorrowe
You can call Aws::S3::Client#put_object, or Aws::S3::Object#put
chrishawk
@chrishawk
wow awesome thanks
I don't know how I missed that
What about object.move_to
what's the equivalent in v2
I've been trying copy_object but it produces a Aws::S3::Errors::AllAccessDisabled error I can't figure out
Trevor Rowe
@trevorrowe
The #move_to method was a wrapper around #copy_object. If you share a gist, then I can see if I can help debug your call.
Robin van Wijngaarden
@robinvw1
@trevorrowe thanks for your answer :)
Trevor Rowe
@trevorrowe
@robinvw1 No problem!
chrishawk
@chrishawk
I actually have a stackoverflow question with it
Trevor Rowe
@trevorrowe
I responded there, but in short, your copy_source option is formatted incorrectly. It must be “#{source bucket}/#{sourcekey}”.
chrishawk
@chrishawk
cool thanks, I'll give that a try in a little bit
Andrew Frank
@sirmxanot
Where is the documentation specifying which waiters are available for which services and what params those waiters expect? For instance the only examples I see are relating to EC2, and the RDS waiter documentation doesn't specify which waiters are available for rds clients http://docs.aws.amazon.com/sdkforruby/api/Aws/RDS/Client.html#wait_until-instance_method
Trevor Rowe
@trevorrowe

@sirmxanot In the “Parameters” section of the #wait_until method you linked documentaiton for, it indicates that the accepted waiter names and the operations they call are specified in the #waiter_names method. It is linked from there. In the #waiter_names method, it shows the API call being pulled and links to that:

For RDS:
http://docs.aws.amazon.com/sdkforruby/api/Aws/RDS/Client.html#waiter_names-instance_method

Daniel Collis-Puro
@djcp
So I've scripted stack creation via the ruby API. One odd thing - when I create an instance_profile I don't see it in the web console but I do when I call iam_client.list_instance_profiles
and it's associated with the stack properly - but this makes me think I'm missing something.
associated with the stack in the web console, that is.
Andrew Frank
@sirmxanot
@trevorrowe Thank you! Also, sorry for the obvious question :-)
Trevor Rowe
@trevorrowe
@sirmxanot No problem. Your question is valuable feedback. I’ve considered making this table more prominent, and I should probably move it from #waiter_names to #wait_until where people are looking.
@djcp I think the console has some magic around the creation of instance profiles. If I recall correctly, you have to create a role policy, and a role, associate them, then create an instance profile and associate the policy to that. The console profiles a single wizard for creating them all together. I suspect, though I don’t know, that only displays the policies that it manages.
Daniel Collis-Puro
@djcp
@trevorrowe Huh, interesting. I'll keep that in mind, IIRC I've arrived pretty much at what you layed out above. If I'm doing something wrong, I bet it'll be apparent when I get to adding instances.
Trevor Rowe
@trevorrowe
@djcp If I recall correctly, the only tricky for me was setting the correct assume role policy document. Its a json document that grants EC2 the right to assume a role on behalf of your account. There is a boilerplate document that I used. I haven’t set one up in a while.
Daniel Collis-Puro
@djcp
It seems like a bunch of clients lack waiters - Aws::IAM::Client for example. Is implementing a new waiter as easy as creating a new json definition and registering it with a service via Aws.service() or is there more to it? I am driving some operations that definitely need waiters and I would rather get them into the SDK than implement the semantics myself by hand.
@trevorrowe