DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • End-to-End Event Streaming With Kafka, Spring Boot and AWS SQS/SNS (Production-Ready Code Guide)
  • AWS Bedrock: The Future of Enterprise AI
  • Understanding Custom Authorization Mechanisms in Amazon API Gateway and AWS AppSync
  • AWS Transfer Family SFTP Setup (Password + SSH Key Users) Using Lambda Identity Provider + S3

Trending

  • Building a Windows App for a Resilient SSH SOCKS Proxy and Selective Browser Routing
  • A Software Factory on Kubernetes: Gemini Builds, jev Decides (Genkit + senro in Go)
  • Decoupling a Data Pipeline From the Tables It Was Never Supposed to Depend On
  • Event Sourcing in Distributed Systems: Architecture, Consistency, and Fault-Tolerant Projections

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. How to Use EFS With AWS Lambda

How to Use EFS With AWS Lambda

How to utilize the old/new feature with Lambda to empower your Serverless application/architecture.

By 
Mohamed Latfalla
·
Jul. 01, 20 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
9.3K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

EFS with AWS Lambda

AWS recently launched a new feature that lets the customer make an EFS (Elastic File System) that works with Lambda. This is really cool! But, Why EFS?

EFS is a storage unit that lives independently inside a machine. This file can be attached to other services like EC2 and can be accessed from multiple instances at once. Files that are inside this storage unit are accessible from any connected instance or Lambda.

Why do we need something like this to work with Lambda? Extra complicated step?

Actually, this feature is amazing if you looked at it from different angles. Let’s start with some of them:

Consistency

If you need multiple Lambdas to use (read and write) BIG files, you’ll need them to be in a place that doesn’t delay the function to get the resources, which leads to less computing power and time -> less money.

More Space

When you’re working with files from S3, you’re limited to the max storage size of 512 MiB. This is not enough is some cases. Plus, you might need to work with this file in different processes stages, like cleaning, segmenting, processing, and exporting readable reports/formats of this file. Imagine the amount of code involved in this scenario.

More Space 2

Using layers will share the resources between the functions, but Layers sometimes can’t handle the size of the resources and binaries you called to run this function. Using EFS will give you more room to store these resources and call when is needed.

I can list more points. But, you get the idea. Let’s dive into how to use it with lambda.

Creating EFS

1. Open AWS console and search for “EFS”

AWS Management Console


2. Click on “Create file system”

3. At step 1, select your VPC. If your lambda is configured within a VPC, choose it, if not, remember when VPC you’ve selected.

Creating file system


4. Add a descriptive name for your file system. Then, click the next step.

Adding name to file system


5. Go down and click on “Add access point”. Then, fill it with what’s in the image.

Adding access point

6. Review the configuration. Then, click “Create file system”.

Creating file system


7. Done! Wait for a few seconds, and your EFS will be active.

EFS is active


Connect it With Lambda

1. Click on Service and search for “Lambda”.

Searching for Lambda

2. Create a new function and choose your preferred runtime language. In this article, I’ll use Python.

Creating a new Lambda function


3. Go down a little bit, and you’ll see a section called “VPC”. Click on “Edit”.

Editing VPC


4. Select your VPC, and choose the Subnets and the security group. Then save.

Selecting VPC


5. Under the VPC section, click on “Add file system” from “file System” section.

Adding a file system


6. Select the EFS File System we made, remember that we gave it a descriptive name. Then choose the Access point that is associated with the Access Point and finally, give it a path.

Note: "This path needs to start with ‘/mnt/‘. You can keep it as it is, or if you want to have a custom folder, you can."

Adding file system

7. A small piece of code to test if the file system is attached to the function.

Testing if file system is attached


8. Bingo!! We made it!

Successful output

Conclusion

Adding EFS to Lambda is a huge new milestone in The Serverless architecture. You can have new use-cases that will be doable and before were a nightmare to accomplish. Easy steps with the cheap price make Lambda an option that can battle EC2 in some new modern use-cases.

AWS File system AWS Lambda

Opinions expressed by DZone contributors are their own.

Related

  • End-to-End Event Streaming With Kafka, Spring Boot and AWS SQS/SNS (Production-Ready Code Guide)
  • AWS Bedrock: The Future of Enterprise AI
  • Understanding Custom Authorization Mechanisms in Amazon API Gateway and AWS AppSync
  • AWS Transfer Family SFTP Setup (Password + SSH Key Users) Using Lambda Identity Provider + S3

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook