Guy Shechter
07/01/2021, 9:41 PM#13 [9/9] RUN if [ -f 'requirements.txt' ]; then pip install -r requirements.txt -t .; else echo "requirements.txt not found"; fi
#13 0.723 ERROR: Could not find a version that satisfies the requirement myprivatemodule (from versions: none)
#13 0.723 ERROR: No matching distribution found for myprivatemodule
#13 ERROR: executor failed running [/bin/sh -c if [ -f 'requirements.txt' ]; then pip install -r requirements.txt -t .; else echo "requirements.txt not found"; fi]: exit code: 1
------
> [9/9] RUN if [ -f 'requirements.txt' ]; then pip install -r requirements.txt -t .; else echo "requirements.txt not found"; fi:
------
executor failed running [/bin/sh -c if [ -f 'requirements.txt' ]; then pip install -r requirements.txt -t .; else echo "requirements.txt not found"; fi]: exit code: 1
Error: docker exited with status 1
at dockerExec (/src/myapp/node_modules/@aws-cdk/core/lib/bundling.ts:450:11)
at Function.fromBuild (/src/myapp/node_modules/@aws-cdk/core/lib/bundling.ts:266:5)
at Function.fromAsset (/src/myapp/node_modules/@aws-cdk/core/lib/bundling.ts:156:24)
at Object.bundle (/src/myapp/node_modules/@serverless-stack/resources/src/util/python/bundling.ts:107:41)
at Object.builder (/src/myapp/node_modules/@serverless-stack/resources/src/util/pythonBuilder.ts:42:15)
at new Function (/src/myapp/node_modules/@serverless-stack/resources/src/Function.ts:245:21)
at Function.fromDefinition (/src/myapp/node_modules/@serverless-stack/resources/src/Function.ts:326:14)
at Api.addRoute (/src/myapp/node_modules/@serverless-stack/resources/src/Api.ts:339:23)
at /src/myapp/node_modules/@serverless-stack/resources/src/Api.ts:198:14
at Array.forEach (<anonymous>)
There was an error synthesizing your app.
FWIW, when building my own docker containers I use the following script with environment AWS_* credentials to pull dependencies defined in requirements.txt
from both AWS CodeArtifact and PyPi.org
#!/bin/sh
CODEARTIFACT_AUTH_TOKEN=`/usr/local/bin/aws codeartifact get-authorization-token --domain mydomain --domain-owner 1111111111 --query authorizationToken --output text`
pip3 install -v d \
--index-url "<https://aws>:$CODEARTIFACT_AUTH_TOKEN@mydomain-1111111111.d.codeartifact.us-east-1.amazonaws.com/pypi/myprivatemodule/simple/" \
--extra-index-url "<https://pypi.org/simple>" "myprivatemodule>=0.0.16"
One workaround would be to publish a lambda Layer of my private module, but I’m not sure that solution would work for local debugging.Frank
Frank
Frank
RUN if [ -f 'requirements.txt' ]; then pip install -r requirements.txt -t .; else echo "requirements.txt not found"; fi
Frank
RUN if [ -f 'requirements.txt' ]; then pip install -r requirements.txt -t .; else echo "requirements.txt not found"; fi
RUN pip3 install -v d \
--index-url "..." \
--extra-index-url "<https://pypi.org/simple>" "myprivatemodule>=0.0.16"
Frank
requirements.txt
?Guy Shechter
07/02/2021, 12:33 AMFrank
-v d
do?
2. why is “myprivatemodule>=0.0.16” explicitly specified in the cli?Guy Shechter
07/02/2021, 12:38 AMGuy Shechter
07/02/2021, 12:38 AMGuy Shechter
07/02/2021, 12:39 AMFrank
Guy Shechter
07/02/2021, 12:39 AMGuy Shechter
07/02/2021, 12:41 AMGuy Shechter
07/02/2021, 12:41 AMCODEARTIFACT_AUTH_TOKEN=`/usr/local/bin/aws codeartifact get-authorization-token --domain mydomain --domain-owner 1111111111 --query authorizationToken --output text
'Guy Shechter
07/02/2021, 12:43 AMRemoving stacks
Building Lambda function src/lambda.handler
Bundling dependencies for src in Docker...
#1 [internal] load build definition from ****Dockerfile.dependencies***
Frank
sst.Function
lets you pass in a build command and a docker environment, ie:
new Function(this, "MyLambda", {
runtime: "python3.7",
handler: "src/index.main",
bundle: {
command: "pip3 install -v --index-url ...",
environment: {
CODEARTIFACT_AUTH_TOKEN: process.env.CODEARTIFACT_AUTH_TOKEN,
}
},
});
You can run the AWS CLI to get the TOKEN and pass that in to the sst deploy
command. ie:
CODEARTIFACT_AUTH_TOKEN=`/usr/local/bin/aws codeartifact get-authorization-token ...` sst deploy
Frank
Guy Shechter
07/02/2021, 1:09 AMFrank
Frank
Frank
Frank
Frank
installCommands
to generate the auth tokenFrank
Guy Shechter
07/07/2021, 7:16 PM