无法使用api从s3提取文件

I am trying to fetch a file from an s3 bucket. I have written the code using Chalice microservice of aws.

我不明白如何解决这个问题。由于我对aws非常陌生,并且据我了解,我同意s3 full acess的IAM角色。我该怎么办?

这是我得到的错误。

Traceback (most recent call last):
  File "/var/task/chalice/app.py", line 1112, in _get_view_function_response
    response = view_function(**function_args)
  File "/var/task/app.py", line 58, in fetch
    s3.Bucket(os.environ["BUCKET_NAME"]).download_file( 'key', 'key.pem')
  File "/var/task/boto3/s3/inject.py", line 246, in bucket_download_file
    ExtraArgs=ExtraArgs, Callback=Callback, Config=Config)
  File "/var/task/boto3/s3/inject.py", line 172, in download_file
    extra_args=ExtraArgs, callback=Callback)
  File "/var/task/boto3/s3/transfer.py", line 307, in download_file
    future.result()
  File "/var/task/s3transfer/futures.py", line 106, in result
    return self._coordinator.result()
  File "/var/task/s3transfer/futures.py", line 265, in result
    raise self._exception
  File "/var/task/s3transfer/tasks.py", line 126, in __call__
    return self._execute_main(kwargs)
  File "/var/task/s3transfer/tasks.py", line 150, in _execute_main
    return_value = self._main(**kwargs)
  File "/var/task/s3transfer/download.py", line 571, in _main
    fileobj.seek(offset)
  File "/var/task/s3transfer/utils.py", line 367, in seek
    self._open_if_needed()
  File "/var/task/s3transfer/utils.py", line 350, in _open_if_needed
    self._fileobj = self._open_function(self._filename, self._mode)
  File "/var/task/s3transfer/utils.py", line 261, in open
    return open(filename, mode)
OSError: [Errno 30] Read-only file system: 'key.pem.a7A6afCF'

关联代码:

    s3 = boto3.resource('s3')
    # s3.Bucket(os.environ["BUCKET_NAME"]).upload_file(Filename="requirements.txt" , Key="tryagain")
    s3.Bucket(os.environ["BUCKET_NAME"]).download_file( 'key', 'key.pem')

谢谢你的帮助。