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

(aws-lambda-python-alpha): Bundling Options do not include PIP_TRUSTED_HOST, and do not get passed to bundling #29732

Open
m3newc opened this issue Apr 4, 2024 · 0 comments
Labels
@aws-cdk/aws-lambda-python bug This issue is a bug. effort/small Small work item – less than a day of effort p3

Comments

@m3newc
Copy link

m3newc commented Apr 4, 2024

Describe the bug

Bundling arguments for a PythonLayerVersion do not work as expected. When specifying a PIP_INDEX_URL, I am unable to specify PIP_TRUSTED_HOST.
Additionally, any configured indexes are not passed to the bundling stage.

Expected Behavior

Passing PIP_TRUSTED_HOST as a build argument allows full use of a mirrored pip repository.

When passing PIP_TRUSTED_HOST and PIP_INDEX_URL as a build argument, it get's passed to the pip install of the requirements.txt file

Current Behavior

Passing PIP_TRUSTED_HOST does nothing.
When configuring PIP_INDEX_URL, it passes the pipenv install, but does not get passed to the requirements.txt install

Reproduction Steps

from aws_cdk import aws_lambda, aws_lambda_python_alpha;

import pathlib;
from cdk.shared_resources import CommandHook;

from constructs import Construct;
class IAC(Construct):
    def __init__(self, scope, construct_id):
        super().__init__(scope, construct_id);
        
        self.layer = aws_lambda_python_alpha.PythonLayerVersion(self, "Utilities",
            compatible_runtimes       = [ aws_lambda.Runtime.PYTHON_3_8 ],
            compatible_architectures  = [ aws_lambda.Architecture.X86_64 ],

            # Code
            entry = str(pathlib.Path(__file__).parent),
            bundling = aws_lambda_python_alpha.BundlingOptions(
                build_args = {"PIP_INDEX_URL": "https://our-mirror.com/simple/", "PIP_TRUSTED_HOST": "our-mirror.com",
                command_hooks = CommandHook()
            )
        );

Possible Solution

Update https:/aws/aws-cdk/blob/v2.135.0/packages/%40aws-cdk/aws-lambda-python-alpha/lib/Dockerfile#L8 to include ARG PIP_TRUSTED_HOST

Possibly add in a flag in Bundling Options for passing through the build_args into the pip3 install phase. This would be intended to prevent the need to duplicate the mirror information for both the pipenv install and the requirementst.txt install; in theory both would always use the same mirror, but having a flag that defaults to true just in case.

If true, it can simply turn the build_args into export statements in the before_bundling list.

Additional Information/Context

No response

CDK CLI Version

2.118.0

Framework Version

No response

Node.js Version

16.16.0

OS

Amazon Linux 2

Language

Python

Language Version

3.7

Other information

No response

@m3newc m3newc added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 4, 2024
@khushail khushail added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Apr 5, 2024
@khushail khushail self-assigned this Apr 5, 2024
@khushail khushail removed the needs-triage This issue or PR still needs to be triaged. label Apr 5, 2024
@khushail khushail added p2 effort/small Small work item – less than a day of effort labels Apr 29, 2024
@khushail khushail removed their assignment May 23, 2024
@khushail khushail removed the investigating This issue is being investigated and/or work is in progress to resolve the issue. label May 23, 2024
@pahud pahud added p3 and removed p2 labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda-python bug This issue is a bug. effort/small Small work item – less than a day of effort p3
Projects
None yet
Development

No branches or pull requests

3 participants