I’m having an issue where I’m defining a new EFS instance (for FS and AP) in the resources section of my serverless.yml file. I then reference the FileSystem in one of my functions. However, the problem I’m having is that when the function attempts to deploy the access point is not yet ready and the function fails, which then rolls back the stack.
I can sort of work around this by commenting out all of the functions and just deploying the resources, but this is not a viable solution. Is there any way to force serverless to deploy resources only? Or some other solution to this issue? I’ve searched for a while and haven’t been able to find a solution to this but I’m guessing I can’t be the only one who has faced this.
A solution? Yes. A good one? Eh… So never could figure this out directly in serverless so ended up just using Terraform (which is standard in my env) for EFS deployment, then dumping the TF outputs to a JSON outputs file which can be read in by serverless.
It works perfectly, but does introduce a step outside of serverless.
I’m sure this could be accomplished natively by creating a module similar to the domain creation module but for me, since we use TF anyway, TF was the way to go.
Yeah, the nice thing with Terraform is that it doesn’t complete until the resource is actually created and available, so it will sit there running for a half hour if needed so you can just run TF and then serverless right afterward, no need for delay.
Yeah and I was under the impression serverless does that as well. It seems this case is more of an exception. I like how serverless seems more declarative compared to tf and also saves me from managing state myself.
Serverless Error ----------------------------------------
An error occurred: MyFunctionLambdaFunction - EFS file system arn:aws:elasticfilesystem:eu-west-1:<account-id>:file-system/<fs-code> referenced by access point arn:aws:elasticfilesystem:eu-west-1:<account-id>:access-point/<fsap-code> has mount targets created in all availability zones the function will execute in, but not all are in the available life cycle state yet. Please wait for them to become available and try the request again. (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: 5dd189ac-b6a9-42ef-a8e6-7dba88019d12; Proxy: null).
I got it working by adding an additional DependsOn attribute on the AccessPoint as suggested here. The serverless yaml then looks something like this:
Thanks for sharing your solution. It works for me!
The only issue that I found is when I have to use EFS combined with container image. When I try to mount in a function in an image, deploy is completed, but when invoked it, function always timed out.
Yes, I did! Ive create a function to get an object from s3, and I put a console.log before, inside and after the function, and only the before is displayed.
All console.log are displayed when EFS is not a resource in my function (combined with a container image).