cloudandthings/terraform-aws-costnotifier

Applying the plan fails with: Python interpreter version equal to defined lambda runtime

Closed this issue · 4 comments

Tried to add this module to our infrastructure a minute ago (version 3.0.0). Applying the plan fails as we have Python 3.10. available only. It's not that easy to provide a different Python version for us. Anything I can do here to get it running?

Why is a Python installation needed at all? Usually I do not have it available when applying my infrastructure.

│ Error: External Program Execution Failed
│ 
│   with module.billing_notifier_root_account_teams.module.billing_notifier_lambda.data.external.archive_prepare[0],
│   on .terraform/modules/billing_notifier_root_account_teams.billing_notifier_lambda/package.tf line 10, in data "external" "archive_prepare":
│   10:   program = [local.python, "${path.module}/package.py", "prepare"]
│ 
│ The data source received an unexpected error while attempting to execute
│ the program.
│ 
│ Program: /usr/bin/python3
│ Error Message: Traceback (most recent call last):
│   File "/builds/fis3-csbm/sales/platform/infrastructure/.terraform/modules/billing_notifier_root_account_teams.billing_notifier_lambda/package.py", line 1632, in <module>
│     main()
│   File "/builds/fis3-csbm/sales/platform/infrastructure/.terraform/modules/billing_notifier_root_account_teams.billing_notifier_lambda/package.py", line 1628, in main
│     exit(args.command(args))
│   File "/builds/fis3-csbm/sales/platform/infrastructure/.terraform/modules/billing_notifier_root_account_teams.billing_notifier_lambda/package.py", line 1427, in prepare_command
│     build_plan = bpm.plan(source_path, query)
│   File "/builds/fis3-csbm/sales/platform/infrastructure/.terraform/modules/billing_notifier_root_account_teams.billing_notifier_lambda/package.py", line 801, in plan
│     pip_requirements_step(pip_requirements, prefix,
│   File "/builds/fis3-csbm/sales/platform/infrastructure/.terraform/modules/billing_notifier_root_account_teams.billing_notifier_lambda/package.py", line 675, in pip_requirements_step
│     raise RuntimeError(
│ RuntimeError: Python interpreter version equal to defined lambda runtime
│ (python3.8) should be available in system PATH
│ 
│ State: exit status 1

@kayman-mk thanks for the feedback.

Building lambdas is pretty tricky, because you depend on some kind of consistent build environment and hope it is the same as the lambda execution env.

We've mostly been building using Terraform cloud, which supports building Python3.8 and 3.9. It's been working but isn't ideal for several reasons. Building locally is an option but also not great.

We're working on a potentially better way to distribute different lambda modules.
Then we don't require a consumer of our module/s to build anything, and they could just consume it.

I'll ping you here when we think it is ready to go.

Should be fixed by #40

@kayman-mk please test with version = "~> 3.1", it should work for you.

See https://github.com/cloudandthings/terraform-aws-costnotifier#lambda-deployment-package for some info.

Nice. It's working now.