Closed atcherry closed 10 months ago
I was able to work around this by setting the build method to makefile with a makefile that does some simple go building.
Thanks for reporting the issue.
I was able to re-produce it on my side. AFAIR this should be fixed earlier (see: https://github.com/aws/aws-sam-cli/issues/3894)
Will provide more updates after checking the root cause.
Update: Found the root cause of the issue, we will be working on a fix soon. As a workaround for now, you can add metadata for both functions so that they will have separate build flow. If you update your original template to this, it should work.
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-1016-10-31
Resources:
FunctionA:
Type: AWS::Serverless::Function
Properties:
FunctionName: FunctionA
CodeUri: src
Handler: lambda/function-a
Runtime: go1.x
Metadata:
FunctionName: FunctionA
FunctionB:
Type: AWS::Serverless::Function
Properties:
FunctionName: FunctionB
CodeUri: src
Handler: lambda/function-b
Runtime: go1.x
Metadata:
FunctionName: FunctionB
Fixed in #6202 and will be rolled out soon
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
Patch is released in v1.101.0. Closing
@sidhujus I am not using provided.al2
, but I am curious if these changes cope with that runtime. I should probably test this myself, but I figured I'd at least throw this thought out there as I am not using the provided.al2
runtime and do not know much about it. I just know that the go1.x
runtime will be phased out according to this article
Description:
Running
sam build
with a template that defines multiple functions with the sameCodeUri
but different handlers results in only the first defined handler being generated for both functions.Steps to reproduce:
My file structure is the following. The contents of the go files are otherwise empty aside from the
main.go
files having themain
function:This is the
template.yaml
I used:Run
sam build --use-container
(same output occurs regardless of--use-container
)Observed result:
The generated
.aws-sam
directory results in two binaries of the first defined function in the template.Here is the output from
sam build --use-container --debug
Output
Expected result:
I would have expected
.aws-sam/build/FunctionB/lambda/
to containfunction-b
and notfunction-a
since that is what the handler is defined as in the template. The debug output even shows that the binary forFunctionB
is being coppied fromFunctionA
.Additional environment details (Ex: Windows, Mac, Amazon Linux etc)