You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(lambda-python): support setting environment vars for bundling (#18635)
While using the Python Lambda with Code Artifact, discovered that Code Artifact was still inaccessible because bundling occurs at _run_ time, which can only access env vars, not build args.
This is not a security issue because bundled output doesn't contain any of the secret values.
**Note:** Without this, using Code Artifact (or any other private packaging for Python Lambdas) is currently broken.
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy file name to clipboardExpand all lines: packages/@aws-cdk/aws-lambda-python/README.md
+27-2
Original file line number
Diff line number
Diff line change
@@ -167,9 +167,34 @@ new lambda.PythonFunction(this, 'function', {
167
167
entry,
168
168
runtime: Runtime.PYTHON_3_8,
169
169
bundling: {
170
-
buildArgs: { PIP_INDEX_URL: indexUrl },
170
+
environment: { PIP_INDEX_URL: indexUrl },
171
171
},
172
172
});
173
173
```
174
174
175
-
This type of an example should work for `pip` and `poetry` based dependencies, but will not work for `pipenv`.
175
+
The index URL or the token are only used during bundling and thus not included in the final asset. Setting only environment variable for `PIP_INDEX_URL` or `PIP_EXTRA_INDEX_URL` should work for accesing private Python repositories with `pip`, `pipenv` and `poetry` based dependencies.
176
+
177
+
If you also want to use the Code Artifact repo for building the base Docker image for bundling, use `buildArgs`. However, note that setting custom build args for bundling will force the base bundling image to be rebuilt every time (i.e. skip the Docker cache). Build args can be customized as:
0 commit comments