aws / aws/aws-sam-cli

Way to specify build arguments for go, such as -ldflags

Open
#3,419 1 comment 13 reactions 0 assignees View on GitHub
type/feature
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

### Describe your idea/feature/enhancement

Often when debugging I want to know what version and commit I'm looking at in the logs, or presented by the API. One way of doing this is to embed the details from the envirnoment into the application, ie passing these as ldflags

// -X main.version=${Version} -X main.commit=${Commit} -X main.date=${CommitDate}

Will allow you to access the values from inside the application.

### Proposal

I propose extending the "Metadata" componet to include "BuilderArgs" or something along those lines, which would be added to the builder. Then the values can be routed into sam in the usual ways. ie:

```

Resources:
function1:
Type: AWS::Serverless::Function
Properties:
Handler: handler
CodeUri: lambda
Runtime: go1.x
Metadata:
BuilderArgs: !Sub "-ldflags \"-X main.version=${Version} -X main.commit=${Commit} -X main.date=${CommitDate}\""
```

### Additional Details

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.