title: Download Files From AWS S3 Without Access and Secret Keys in Python
body: <p>I have a working code to download files from one of my buckets in S3 and does some conversion work through in Python. I <strong>do not</strong> embed the Access and Secret Keys in the code but <strong>the keys are in</strong> my AWS CLI configuration.</p>
  
  <pre><code>import boto3
  import botocore
  
  
  BUCKET_NAME = 'converted-parquet-bucket' # replace with your own bucket name
  KEY = 'json-to-parquet/names.snappy.parquet' # replace with path and follow with key object
  
  s3 = boto3.resource('s3')
  
  try:
      s3.Bucket(BUCKET_NAME).download_file(KEY, 'names.snappy.parquet') #  replace the key object name
  except botocore.exceptions.ClientError as e: # exception handling
      if e.response['Error']['Code'] == "404":
          print("The object does not exist.") # if object that you are looking for does not exist it will print this
      else:
          raise
  
  # Un comment lines 21 and 22 to convert csv to parquet
  # dataframe = pandas.read_csv('names.csv')
  # dataframe.to_parquet('names.snappy.parquet' ,engine='auto', compression='snappy')
  
  data = pq.read_pandas('names.snappy.parquet', columns=['Year of Birth', 'Gender', 'Ethnicity', "Child's First Name", 'Count', 'Rank']).to_pandas()
  
  
  #print(data) # this code will print the ALL the data in the parquet file
  
  print(data.loc[data['Gender'] == 'MALE']) # this code will print the data in the parquet file ONLY what is in the query (SQL query)
  </code></pre>
  
  <p>Could someone help me how to get this code working <strong>without</strong> having access and secret keys embedded in the code <strong>or</strong> in AWS configure</p>