Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using NewFileArchive to create Lambda in Go #1962

Closed
justone opened this issue Sep 20, 2018 · 4 comments
Closed

Error when using NewFileArchive to create Lambda in Go #1962

justone opened this issue Sep 20, 2018 · 4 comments
Assignees
Projects
Milestone

Comments

@justone
Copy link
Contributor

justone commented Sep 20, 2018

I'm trying to create a lambda with code that is in a local directory. Here's a snippet:

        lambdaFunction, err := lambda.NewFunction(ctx, "slacker", &lambda.FunctionArgs{
            Runtime: "python3.6",
            Code: asset.NewAssetArchive(map[string]interface{}{
                ".": asset.NewFileArchive("./function.zip"),
            }),
            Timeout: 300,
            Handler: "function.lambda_handler",
            Role:    lambdaRole.Name(),
        })

When I run pulumi up, I get this error message:

Diagnostics:
  global: global
    error: expected an asset, but filename is not an asset

At @swgillespie's request, I changed line 103 of rpc.go from:

rpcTokenSpecialSigKey: rpcTokenSpecialAssetSig,

to:

rpcTokenSpecialSigKey: rpcTokenSpecialArchiveSig,

and that got past the error message.

However, now I get this message:

error: Plan apply failed: creating urn:pulumi:billing-dev::billing::aws:lambda/function:Function::slacker: Error creating Lambda function: InvalidParameterValueException: Uploaded file must be a non-empty zip

I've tried both asset.NewFileArchive("./function") and asset.NewFileArchive("./function.zip"), and the error is the same.

Here's the files on the filesystem:

$ tree function
function
└── function.py

0 directories, 1 file
$ unzip -l function.zip
Archive:  function.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
     2844  2018-09-20 08:56   function.py
---------                     -------
     2844                     1 file

I was able to work around this issue by uploading my code to S3 and using the S3Bucket and S3Key properties.

Any help would be greatly appreciated. Thanks.

@swgillespie swgillespie self-assigned this Sep 20, 2018
@lukehoban lukehoban added this to the 0.19 milestone Sep 20, 2018
@swgillespie
Copy link
Contributor

We should definitely fix rpc.go, that's 100% a bug. There's probably another bug lurking but using rpcTokenSpecialAssetSig to serialize an Archive is definitely a bug.

@lukehoban lukehoban modified the milestones: 0.19, 0.21 Oct 25, 2018
@swgillespie
Copy link
Contributor

Go support is out of scope for M21.

@swgillespie swgillespie modified the milestones: 0.21, 0.22 Feb 1, 2019
@swgillespie swgillespie removed this from the 0.22 milestone Mar 18, 2019
@joeduffy joeduffy assigned ellismg and unassigned swgillespie May 28, 2019
@lukehoban lukehoban assigned EvanBoyle and unassigned ellismg Jan 15, 2020
@EvanBoyle EvanBoyle added this to Untracked in Go Jan 27, 2020
@EvanBoyle EvanBoyle moved this from Untracked to M31 in Go Jan 28, 2020
@EvanBoyle
Copy link
Contributor

We think this may have been fixed. I'll try to create a repro in M31 to verify.

@lukehoban lukehoban added this to the 0.31 milestone Jan 28, 2020
@EvanBoyle EvanBoyle moved this from M31 to M32 in Go Feb 6, 2020
@EvanBoyle EvanBoyle modified the milestones: 0.31, 0.32 Feb 6, 2020
@lukehoban
Copy link
Member

Confirmed that this works. There's an example now in the examples repo that does this:

https://github.com/pulumi/examples/blob/1e1720ff87f0cb85dbf12e0840c577953aa35e4a/aws-go-lambda/main.go#L46-L63

@EvanBoyle EvanBoyle moved this from M32 to Released in Go Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Go
Released
Development

No branches or pull requests

5 participants