ruby/example_code/s3/s3-ruby-example-create-bucket.rb
# Creates an Amazon S3 bucket.
#
# @param s3_client [Aws::S3::Client] An initialized S3 client.
# @param bucket_name [String] The bucket's name.
# @return [Boolean] true if the bucket was created; otherwise, false.
# @example
#   exit 1 unless bucket_created?(
#     Aws::S3::Client.new(region: 'us-west-2'),
#     'doc-example-bucket'
#   )

Creates an Amazon S3 bucket.
Creates an Amazon S3 bucket .
def bucket_created?(s3_client, bucket_name)
  s3_client.create_bucket(bucket: bucket_name)
  return true
rescue StandardError => e
  puts "Error creating bucket: #{e.message}"
  return false
end
def bucket_created? ( s3_client , bucket_name ) s3_client . create_bucket ( bucket : bucket_name ) return true rescue StandardError => e puts "Error creating bucket: #{e.message}" return false end
Creates an Amazon S3 bucket.
Creates an Amazon S3 bucket .
true if the bucket was created; otherwise, false.
true if the bucket was created ; otherwise false .
Boolean
s3_client
An initialized S3 client.
An initialized S3 client .
bucket_name
The bucket's name.
The bucket ' s name .
example
exit 1 unless bucket_created?( Aws::S3::Client.new(region: 'us-west-2'), 'doc-example-bucket' )
exit 1 unless bucket_created? ( Aws :: S3 :: Client . new ( region : ' us - west - 2 ' ) ' doc - example - bucket ' )