0

I would like to deploy Python packages to EFS and use it in an AWS Lambda function. I was successful in adding EFS to one Lambda function and calling the Python package from it without any issues. However, when I added the same EFS to a different Lambda function and attempted to test it, the function got stuck in the code and timed out.

Since the first Lambda function worked properly, I do not believe it to be a configuration issue. Have you experienced this before? Please advise.

I found that code gets stuck when querying data from dynamoDB. However, it works find if I detach EFS.

def read_table(pk_key, sk_key, pk_value, sk_value):
    table = boto3.resource('dynamodb').Table(settings.table_data)

    query_response = table.query(
        KeyConditionExpression=Key(pk_key).eq(pk_value) & Key(sk_key).eq(sk_value)
        )

    item = query_response['Items'][0]
    return item
Than
  • 21
  • 5
  • 1
    Could it be related to file locking? What is the reason for putting python package in EFS? Can't you use Lambda layers? – brushtakopo May 05 '23 at 10:55
  • I don't think it is about file locking. Since it works with another Lambda. I am trying to deploy a large package (>250 MB), so Layer does not work for this case. – Than May 05 '23 at 11:11
  • 1
    not sure I understand, you mentioned the other lambda got stucked, in where? In accessing EFS? Are they exact same lambda or different ones? You might to share your code. – brushtakopo May 05 '23 at 12:09
  • @brushtakopo I just updated my code – Than May 06 '23 at 15:19

1 Answers1

0

Issue resolved. When VPC is added to the Lambda function, it will not have access to AWS resources. I need to create a VPC endpoint to DynamoDB, then it works.

I found the discussion here

Than
  • 21
  • 5
  • In your question description looks like you can connect to DynamoDB if you detach EFS, however without the VPC endpoint DynamoDB access is not possible and don't matter if you attach or not the EFS – Miguel Conde May 08 '23 at 04:04
  • @MiguelConde that's correct. It is VPC configuration issue. However, there are limitations using VPC to access other resources in AWS. Moving forward, I will explore using Docker with Lambda. – Than May 09 '23 at 09:20