I've created a Javascript Lambda function that relies on dependencies from two substantial modules, namely u/aws-sdk and u/asymmetrik/node-fhir-server-core. To make these dependencies accessible, I mounted an Amazon Elastic File System (EFS) from the EC2 command line and copied the modules using these commands:
sudo cp -r extracted-packages/@aws-sdk /mnt/efs/
sudo cp -r extracted-packages/node-fhir-server-core /mnt/efs/
While I can confirm that I can see the contents of these directories by running cd /mnt/efs/
, ls -l u/aws-sdk, and ls -l node-fhir-server-core within the EC2 instance, I'm encountering an issue. These directories are not visible in the EFS console. I suspect this discrepancy is causing the "Cannot find module '@asymmetrik/node-fhir-server-core'" error I encountered when I deployed my functions and executed a test event to post a patient within the Lambda console. .
I've associated an inline policy with the Lambda function, granting it permissions to mount and write to the Elastic File System (EFS). The Lambda function is configured to run within a VPC, ensuring access to the EFS. Additionally, there is an attached EC2 policy that includes actions related to network interfaces, such as creating, describing, and deleting them.
However, when I attempt to execute a test post using an event JSON like this:
{
"body": "{\"base_version\":\"R4\",\"resource\":{\"given\":\"John\",\"family\":\"Doe\",\"gender\":\"male\",\"birthDate\":\"1990-01-15\"}}"
}
I encounter an issue. Instead of the expected data, I receive the error message: 'Cannot find module '@asymmetrik/node-fhir-server-core'.