Issue creating Lambda function layer versions in parallel process



We are using Terraform (v0.13.5 with AWS provider "hashicorp/aws v3.38.0") to deploy AWS resources into our accounts. Some of these resources are Lambda functions with Lambda layers.

We make use of certain automated processes (Gitlab pipelines) to run those deployments. We can change several Lambda functions at the same time.

We use the same Lambda layer for ALL the Lambda functions, but create different versions of that layer with different code (ZIP files) and attach each version to a concrete Lambda function.

Lately we realized that when modifying several Lambda functions at the same time, the code in the different versions of the same layer is mixed!!! So the code that should go for a concrete layer version is also appearing in other versions created at the same time.

For example:

  • when we modify several Lambda functions at the same time (let's say L001 and L002), two new versions of layer MYLAY are created for each, and the corresponding version is linked to each of the modified Lambda functions. So we have L001 with MYLAY-001 and L002 with MYLAY-002. This is how we expect it, so fine so far
  • Each version of the layer should have its own code (different ZIP files)
  • We have detected that the code for MYLAY-001 is also appearing in MYLAY-002, even though the ZIP files used to create those versions are different!!!

So from my point of view, it seems that the way in which AWS is creating the layer versions for the same layer is not compatible with parallel creation.

Can anyone confirm of shed some light on how AWS is creating those versions?

I guess the best approach considering the previous is to use different layer for each Lambda function, indeed.

Thanks in advance and best regards Luis

질문됨 2년 전693회 조회
1개 답변

That is odd behaviour. I'd strongly encourage you to raise a support ticket to investigate that particular issue.

Otherwise: I don't think your strategy of using Lambda Layers is quite right. Yes, it might work but storing different data in each Layer is probably a bad pattern to use. My guess is that you're doing it so that the Lambda function doesn't have to load anything externally at startup but it still seems a little wrong.

Please reach out to your local AWS Solutions Architect to talk about your requirements and the best way to achieve that. Or: Ask a question here on re:Post with what you're trying to achieve.

profile pictureAWS
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠