I'm attempting to translate a YAML CloudFormation template into AWS's CDK using Python. I am currently stuck on instantiating a lambda CfnFunction. It appears that I am not satisfying the required "code" parameter.
My current code looks like:
firehose_trans_lambda = _lambda.CfnFunction(self, "FirehoseTransformLambda",
description="foo",
code=,
handler="lambda_function.handler",
role="LambdaTransformRole.Arn",
runtime="python3.8",
)
According to the CDK documentation, the "code" field should be of type (Union[Forwardref, IResolvable]). I have no idea what this means, and the documentation isn't very helpful. Does anybody have any insight as to what I could put in there to satisfy the requirements? I was thinking of trying either a reference to some lambda or a piece of inline code, but am not sure how to go about doing that (I have tried various things, but my Python skills aren't the strongest).
The code paramter expects an instance of CfnFunction.CodeProperty. Its __init__ accepts the following parameters (all optional and of type str)
s3_buckets3_keys3_object_versionzip_fileYou can pass the same values to CfnFunction.CodeProperty() that you've used in your CloudFormation template.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html
Afaik CfnFunction.CodeProperty isn't mentioned in the AWS CDK Python Reference. The general CDK documentation mentions it, but only as an interface.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With