loki icon indicating copy to clipboard operation
loki copied to clipboard

feat: Prevent lambda-promtail from recompiling on every plan

Open mchaffee-anaconda opened this issue 6 months ago • 1 comments

What this PR does / why we need it:

Currently, if you deploy lambda-promtail using the provided Terraform code, every time you run terraform plan, the golang binary will be recompiled and you will never have a clean plan. Ideally, the binary should only be recompiled if the code actually changes compared to the last apply.

If the code was just a single file, we could use a hash of the script as the trigger, but we have too many files to make hashing feasible. Terraform won't let you hash every file in a folder natively, you'd have to add a third-party module or write a script yourself.

So instead, I've added a new variable, lambda_code_version, which if set, will be used as the trigger for determining when the code should be recompiled. I've added an example to the README.

Special notes for your reviewer:

n/a

Checklist

  • [x] Reviewed the CONTRIBUTING.md guide (required)
  • [x] Documentation added
  • [x] Tests updated
  • [x] Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • [x] Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • [x] If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

mchaffee-anaconda avatar Jun 05 '25 15:06 mchaffee-anaconda

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jun 05 '25 15:06 CLAassistant

@mchaffee-anaconda as of https://github.com/grafana/loki/pull/18531, the lambda-promtail code has moved to its own repo as another team is taking ownership of it. Could you re-open your PR against the new lambda promtail repo please?

JStickler avatar Jul 22 '25 19:07 JStickler