pulumi-aws: InvalidParameterValueException: Uploaded file must be a non-empty zip
What happened?
From @komalali
Hi! I have noticed a recurring error as I’ve worked on drift detection.
Context:
- I have a stack that uses the aws-serverless template: stack
- It is deployed in the dev-sandbox account, so every night a number of these resources are cleaned up
- The following day, when I run drift detection and remediation, the first remediation fails. link
aws:lambda:Function (fn):
error: 1 error occurred:
* creating Lambda Function (fn-a91d018): operation error Lambda: CreateFunction, https response error StatusCode: 400, RequestID: b2589290-ab14-4526-a65c-3b90fabeb5e2, InvalidParameterValueException: Uploaded file must be a non-empty zip
The following drift run/remediation succeeds.
Example
The source is very simple:
https://github.com/pulumi/deploy-demos/blob/main/pulumi-programs/drift-test/index.ts
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as apigateway from "@pulumi/aws-apigateway";
// A Lambda function to invoke
const fn = new aws.lambda.CallbackFunction("fn", {
callback: async (ev, ctx) => {
return {
statusCode: 200,
body: new Date().toISOString(),
};
}
})
// A REST API to route requests to HTML content and the Lambda function
const api = new apigateway.RestAPI("api", {
routes: [
{ path: "/", localPath: "www"},
{ path: "/date", method: "GET", eventHandler: fn },
]
});
// The URL at which the REST API will be served.
export const url = api.url;
Output of pulumi about
$ pulumi about
Logging in using access token from PULUMI_ACCESS_TOKEN
CLI
Version 3.109.0
Go Version go1.22.0
Go Compiler gc
Plugins
NAME VERSION
aws 6.25.1
aws-apigateway 2.4.0
awsx 2.5.0
docker 4.5.1
docker 3.6.1
nodejs unknown
Host
OS debian
Version 11.9
Arch x86_64
This project is written in nodejs: executable='/usr/bin/node' version='v18.17.1'
Backend
Name pulumi.com
URL https://app.pulumi.com/komal-pulumi-corp
User komal-pulumi-corp
Organizations komal-pulumi-corp, service-provider-test-org, komal-testing-123, pulumi-test, pulumi
Token type personal
Dependencies:
NAME VERSION
@pulumi/aws-apigateway 2.4.0
@pulumi/aws 6.25.1
@pulumi/awsx 2.5.0
@pulumi/pulumi 3.109.0
@types/node 18.19.24
typescript 4.9.5
Pulumi locates its logs in /tmp by default
warning: Failed to get information about the current stack: No current stack
Additional context
We tried a few times to reproduce locally but failed to do so, while it reproduces pretty consistently with deployments. This seems quite surprising. There’s a bit going about drift detection but when all is said and done deployments is simply performing this operation over a state that tracks a lambda and a cloud that has the lambda removed:
pulumi update --refresh --skip-preview --yes
Pulumi refreshes and drops the lambda from state, then decides to Create the lambda, which should succeed but does not.
Contributing
Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you’ve opened one already).
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 5
- Comments: 18 (10 by maintainers)
Commits related to this issue
- Ensure that asset translation does not clobber the files (#1813) Adds a test to regress against the situation that caused the AWS P1 in https://github.com/pulumi/pulumi-aws/issues/3622 — committed to pulumi/pulumi-terraform-bridge by t0yv0 3 years ago
- Upgrade pulumi-terraform-bridge to v3.79.0 (#3758) Fixes https://github.com/pulumi/pulumi-aws/issues/3622 This PR was generated via `$ upgrade-provider pulumi/pulumi-aws --kind=bridge --pr-reviewers... — committed to pulumi/pulumi-aws by pulumi-bot 3 years ago
The AssetArchive to upload gets stored as zip file in
${TEMP}/pulumi-asset-${HASH}, with ${HASH} based on the contents of the archive. When we runpulumi update --refreshand the zip files are not present yet, they get created in${TEMP}but are empty. Presumably the name is derived from the existing state. If we then run apulumi updatethat needs to do changes, it will fail with the empty zip error. Since deployments run with an empty temp folder, it reproduces all the time there, whereas locally you might have the correctly formed zip from the previous update.Those 22B files are empty zip files.
If we run without
--refresh, the zip gets created correctlyNote the fileize of 201B this time around.
@t0yv0 https://github.com/pulumi/pulumi/issues/18461 has been created!
We’re seeing a resurgence of this issue – we upgraded from Pulumi 3.38.0 to 3.142.0 a few weeks ago to mitigate this same issue, and after a few weeks, we’ve now noticed that we’re consistently running into the
InvalidParameterValueException: Uploaded file must be a non-empty zipin seemingly random packages packages.We’re running:
pulumi up --yes --refresh --diff --stack stack.name.env --refresh=true, with the AWS v6.18.2 plugin.Please let me know if you’d like for me to create a new issue instead.
Local reproduction:
${TEMP}/pulumi-asset-${HASH}file is larger than 22B)${TEMP}/pulumi-asset-${HASH}The last step will attempt to upload the empty zip file.