Reputation: 363
I'm trying to create a CDK app that will deploy a pipeline-stack and a lambda-stack. Similar to the tutorial here. I'm trying to implement a basic CI/CD application that is triggered with every push to a Github Enterprise Repo.
I chose to use PythonFunction from (@aws-cdk/aws-lambda-python) instead of function from @aws-cdk/aws-lambda because PythonFunction builds the dependencies from requirements.txt. I have various lambdas that use different packages (like awswrangler, pandas, requests, etc.).
But, PythonFunction does not support CfnParametersCode (Where the code is passed through CDK instead of being read from an asset).
What other option do I have to pass my code from GithubEnterprise to the PythonFunction?
If function from @aws-cdk/aws-lambda is the only option I have, how can I include the packages from requirements.txt
This does seem like an option for @aws-cdl/aws-lambda, but how would I pass my code from Github? This example relates to building from asset code.
I apologize if I'm missing something obvious, I just started working with AWS CDK last week.
Upvotes: 1
Views: 670
Reputation: 11
First of all I would recommend to take a look at pipelines.CdkPipeline which is able to deal with Assets. That means you can directly use lambda.Code.from_asset
instead of overriding CfnParametersCode
in the Pipeline.
Regarding your other question, you can deal with the requirements by installing them into your lambda folder during the build step with: pip install -r requirements.txt -t .
Upvotes: 1
Reputation: 402
CfnParametersCode
gives you the ability to upload your code from an S3 file.
You can do the same via lambda.Code.fromBucket
.
Taking your link from the third point (https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/aws-lambda#bundling-asset-code) You just need to use lambda.Code.fromBucket
instead of code: lambda.Code.fromAsset
. Docs can be found here: https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/aws-lambda
Upvotes: 0