ruby/example_code/s3/auth_federation_token_request_test.rb
# Full example call:
# Replace us-west-2 with the AWS Region you're using for Amazon S3.
Full example call:
Replace us-west-2 with the AWS Region you're using for Amazon S3.
Full example call : Replace us - west - 2 with the AWS Region you ' re using for Amazon S3 .
def run_me
  region = 'us-west-2'
  user_name = 'my-user'
  bucket_name = 'doc-example-bucket'
  iam = Aws::IAM::Client.new(region: region)
  user = get_user(iam, user_name)
  exit 1 unless user.user_name
  puts "User's name: #{user.user_name}"
  sts = Aws::STS::Client.new(region: region)
  credentials = get_temporary_credentials(sts, 3600, user_name,
    {
      'Version' => '2012-10-17',
      'Statement' => [
        'Sid' => 'Stmt1',
        'Effect' => 'Allow',
        'Action' => 's3:ListBucket',
        'Resource' => "arn:aws:s3:::#{bucket_name}"
      ]
    }
  )
  exit 1 unless credentials.access_key_id
  puts "Access key ID: #{credentials.access_key_id}"
  s3_client = Aws::S3::Client.new(region: region, credentials: credentials)
  exit 1 unless list_objects_in_bucket?(s3_client, bucket_name)
end
def run_me region = 'us-west-2' user_name = 'my-user' bucket_name = 'doc-example-bucket' iam = Aws :: IAM :: Client . new ( region : region ) user = get_user ( iam , user_name ) exit 1 unless user . user_name puts "User's name: #{user.user_name}" sts = Aws :: STS :: Client . new ( region : region ) credentials = get_temporary_credentials ( sts , 3600 , user_name , { 'Version' => '2012-10-17' , 'Statement' => [ 'Sid' => 'Stmt1' , 'Effect' => 'Allow' , 'Action' => 's3:ListBucket' , 'Resource' => "arn:aws:s3:::#{bucket_name}" ] } ) exit 1 unless credentials . access_key_id puts "Access key ID: #{credentials.access_key_id}" s3_client = Aws :: S3 :: Client . new ( region : region , credentials : credentials ) exit 1 unless list_objects_in_bucket? ( s3_client , bucket_name ) end
Full example call:
Replace us-west-2 with the AWS Region you're using for Amazon S3.
Full example call : Replace us - west - 2 with the AWS Region you ' re using for Amazon S3 .