Питон |Лямбда |S3 |EFS |Нет такого файла или каталога: '/efs/iamfile.txt': FileNotFoundError - PullRequest
0 голосов
/ 27 ноября 2018

Невозможно отправить файл «iamfile.txt» из EFS (подключен к экземпляру EC2) в корзину S3 через Python Lambda Function.Я перешел по ссылке AWS, которая подключит EFS к одному из моих экземпляров EC2, и я вручную создал файл в /efs.

[root@ip-10-132-123-123 efs]# df -h
Filesystem                                    Size  Used Avail Use% Mounted on
/dev/xvda2                                     20G  1.9G   19G  10% /
devtmpfs                                      474M     0  474M   0% /dev
tmpfs                                         496M     0  496M   0% /dev/shm
tmpfs                                         496M   13M  483M   3% /run
tmpfs                                         496M     0  496M   0% /sys/fs/cgroup
fs-d33ada2e.efs.eu-central-1.amazonaws.com:/  8.0E     0  8.0E   0% /efs
tmpfs                                         100M     0  100M   0% /run/user/1000


import boto3

# Create an S3 client
s3 = boto3.client('s3')

def lambda_handler(event, context):
    bucketName = "op-efs-uki-vpc"
    Key = "/efs/iamfile.txt"
    outPutname = "iamfile.txt"
    s3 = boto3.client('s3')
    s3.upload_file(Key,bucketName,outPutname)

Журналы ошибок: -

START RequestId: 12d80a60-f24a-11e8-87e1-31e75505d767 Version: $LATEST
[Errno 2] No such file or directory: '/efs/iamfile.txt': FileNotFoundError
Traceback (most recent call last):
  File "/var/task/lambda_function.py", line 11, in lambda_handler
    s3.upload_file(Key,bucketName,outPutname)
  File "/var/runtime/boto3/s3/inject.py", line 131, in upload_file
    extra_args=ExtraArgs, callback=Callback)
  File "/var/runtime/boto3/s3/transfer.py", line 279, in upload_file
    future.result()
  File "/var/runtime/s3transfer/futures.py", line 73, in result
    return self._coordinator.result()
  File "/var/runtime/s3transfer/futures.py", line 233, in result
    raise self._exception
  File "/var/runtime/s3transfer/tasks.py", line 255, in _main
    self._submit(transfer_future=transfer_future, **kwargs)
  File "/var/runtime/s3transfer/upload.py", line 549, in _submit
    upload_input_manager.provide_transfer_size(transfer_future)
  File "/var/runtime/s3transfer/upload.py", line 237, in provide_transfer_size
    transfer_future.meta.call_args.fileobj))
  File "/var/runtime/s3transfer/utils.py", line 228, in get_file_size
    return os.path.getsize(filename)
  File "/var/lang/lib/python3.6/genericpath.py", line 50, in getsize
    return os.stat(filename).st_size
FileNotFoundError: [Errno 2] No such file or directory: '/efs/iamfile.txt'

END RequestId: 12d80a60-f24a-11e8-87e1-31e75505d767
REPORT RequestId: 12d80a60-f24a-11e8-87e1-31e75505d767  Duration: 74.22 ms  Billed Duration: 100 ms     Memory Size: 128 MB Max Memory Used: 32 MB  
...