AWS SDK and Ruby

Discussion in 'Programming & Software Development' started by ni9ht_5ta1k3r, Mar 26, 2018.

  1. ni9ht_5ta1k3r

    ni9ht_5ta1k3r Member

    Joined:
    Feb 11, 2006
    Messages:
    32,449
    Location:
    地球・オーストラリア・シドニー
    I'm looking into how configuring the AWS SDK for ruby but I have no idea on how to do it.

    I am looking to do a recursive list of a bucket and I am looking to use Ruby as a method of doing that.
     
  2. waltermitty

    waltermitty Member

    Joined:
    Feb 19, 2016
    Messages:
    639
    Location:
    BRISBANE
  3. OP
    OP
    ni9ht_5ta1k3r

    ni9ht_5ta1k3r Member

    Joined:
    Feb 11, 2006
    Messages:
    32,449
    Location:
    地球・オーストラリア・シドニー
    where do i put the access id and secret keys in that? i am not a programmer.
     
  4. waltermitty

    waltermitty Member

    Joined:
    Feb 19, 2016
    Messages:
    639
    Location:
    BRISBANE
  5. OP
    OP
    ni9ht_5ta1k3r

    ni9ht_5ta1k3r Member

    Joined:
    Feb 11, 2006
    Messages:
    32,449
    Location:
    地球・オーストラリア・シドニー
    well, i am trying to is:

    1. get the number of objects in the bucket.
    2. list the objects in a bucket.

    using the below code...

    Code:
    require 'aws-sdk-s3'  # v2: require 'aws-sdk'
    
    s3 = Aws::S3::Client.new(
      access_key_id: 'XXXXX',
      secret_access_key: 'XXXX'
    )
    
    s3 = Aws::S3::Resource.new(region: 'ap-southeast-2')
    
    bucket = s3.bucket('bucket-name')
    
    # Show only the first 50 items
    bucket.objects.limit(50).each do |item|
      puts "Name:  #{item.key}"
    end
    I haven't figured out #1 yet but the major annoyance is having the credentials in the file not being detected by the AWS-SDK...and I am not interested in manually setting it every time I need to do an export.
     

Share This Page