Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Generates error in plan phase if runtime is not available #358

Merged

Conversation

lorengordon
Copy link
Contributor

Fixes #357

Description

Raises plan-time error if the python or nodejs runtime is not present in the PATH. This matches the apply-time behavior, but generates the error during the plan instead of waiting until the apply.

Motivation and Context

See #357

Breaking Changes

I don't think so, unless people were somehow exploiting the prior behavior. But I can't really think of a situation where anyone would want a plan-time success and an apply-time failure...

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

@lorengordon
Copy link
Contributor Author

lorengordon commented Oct 18, 2022

I have validated in my own project that this does cause the necessary failure during the plan phase...

    pip_requirements_step(File(".terraform/modules/lambda/package.py", line 660, in pip_requirements_step
    raise RuntimeError(
RuntimeError: Python interpreter version equal to defined lambda runtime
(python3.8) should be available in system PATH

And also, that it still does not fail if the runtime is available. 😁

@antonbabenko antonbabenko merged commit f9bf21d into terraform-aws-modules:master Oct 20, 2022
antonbabenko pushed a commit that referenced this pull request Oct 20, 2022
### [4.1.2](v4.1.1...v4.1.2) (2022-10-20)

### Bug Fixes

* Generates error in plan phase if runtime is not available ([#358](#358)) ([f9bf21d](f9bf21d))
@lorengordon lorengordon deleted the check-runtime branch October 20, 2022 14:29
@guyzyl
Copy link

guyzyl commented Oct 20, 2022

Now that this PR is merged, I'm getting the following error:

Program: /opt/hostedtoolcache/Python/3.9.15/x64/bin/python3
Error Message: Traceback (most recent call last):
  File "/home/runner/work/bernese/bernese/infrastructure/environments/staging/.terraform/modules/redefine_serverless.list_queries_lambda/package.py", line 1401, in <module>
    main()
  File "/home/runner/work/bernese/bernese/infrastructure/environments/staging/.terraform/modules/redefine_serverless.list_queries_lambda/package.py", line 1397, in main
    exit(args.command(args))
  File "/home/runner/work/bernese/bernese/infrastructure/environments/staging/.terraform/modules/redefine_serverless.list_queries_lambda/package.py", line 1204, in prepare_command
    content_hash = bpm.hash(hash_extra_paths)
  File "/home/runner/work/bernese/bernese/infrastructure/environments/staging/.terraform/modules/redefine_serverless.list_queries_lambda/package.py", line 636, in hash
    content_hash = generate_content_hash(content_hash_paths,
  File "/home/runner/work/bernese/bernese/infrastructure/environments/staging/.terraform/modules/redefine_serverless.list_queries_lambda/package.py", line 248, in generate_content_hash
    update_hash(hash_obj, source_dir, source_file)
  File "/home/runner/work/bernese/bernese/infrastructure/environments/staging/.terraform/modules/redefine_serverless.list_queries_lambda/package.py", line 263, in update_hash
    with open(relative_path, 'rb') as open_file:
NotADirectoryError: [Errno 20] Not a directory:
'lambda_folder/main.py/requirements.txt'

Even though I didn't set the pip_requirements = true option, and my path looks as follows:

source_path = "lambda_folder/list_queries/main.py"

An hour ago this exact same module worked as expected, but now fails.

@antonbabenko
Copy link
Member

@lorengordon Could you please take a look at this issue?

@lorengordon
Copy link
Contributor Author

Oh, I see the logic error. My apologies. One sec.

lorengordon added a commit to lorengordon/terraform-aws-lambda that referenced this pull request Oct 20, 2022
@lorengordon
Copy link
Contributor Author

Please see #359

AllanBenson001 added a commit to AllanBenson001/terraform-aws-lambda that referenced this pull request Oct 20, 2022
lorengordon pushed a commit to lorengordon/terraform-aws-lambda that referenced this pull request Oct 21, 2022
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plan-time validation that runtime is available
3 participants