https://pulumi.com logo
h

happy-egg-47291

10/04/2018, 11:33 PM
How do I create a lambda function with an existing zip archive? I tried something like this
Copy code
let lambda = new aws.lambda.Function("test-lambda", {
    runtime: aws.lambda.Go1dxRuntime,
    code: new pulumi.asset.FileAsset("/tmp/artifacts/aws_lambda.zip"),
    timeout: 300,
    handler: "server",
    role: role.arn,
    environment: {
        variables: {
            "FOO": "bar"
        }
    },
});
but I'm getting an error
error: expected an asset, but filename is not an asset
w

white-balloon-205

10/04/2018, 11:43 PM
I think
pulumi.asset.FileArchive
should work here - but not at my laptop to verify.
h

happy-egg-47291

10/04/2018, 11:43 PM
I thought file archive took files and turned them into a zip file.
But in my case I already have a zip file.
er wait, no that does take a path
oh AssetArchive is what bundles them I guess
w

white-balloon-205

10/04/2018, 11:46 PM
Yes - that’s right. You can use
AssetArchive
to create a zip on the fly from other assets. But ‘FileArchive` should work for cases where you already have the archive.
h

happy-egg-47291

10/04/2018, 11:46 PM
cool, thanks
2 Views