Got a deployment that appears to upload a file to ...
# general
h
Got a deployment that appears to upload a file to my S3 bucket, and the file is created, but it's empty. The file has data on disk but in S3. Pulumi doesn't report any errors. Any ideas besides comb through my cloudtrail logs?
g
Can you share your code?
c
Is your code not waiting for completion of an asynchronous write?
h
This code hasn't changed in months, but here it is. It walks a directory tree recursively and creates an S3 asset BucketObject for each file found. Other files uploaded just fine, however they haven't changed in quite awhile either. Its just this one file that didn't upload (which happens to be our minified JS app!):
Copy code
// For each file in the directory, create an S3 object stored in `siteBucket`
    walkSync(siteDir, (filePath) => {
      const item = path.relative(siteDir, filePath).replace(/\\/g, "/");
      // upload to new bucket
      new aws.s3.BucketObject(`${item}-upd`, {
        bucket: s3AppBucket,
        key: item,
        source: new pulumi.asset.FileAsset(filePath), // use FileAsset to point to a file
        contentType: mime.getType(filePath) || undefined // set the MIME type of the file
      });

      // upload to legacy bucket while we aren't redirecting.
      new aws.s3.BucketObject(item, {
        bucket: legacyS3AppBucket,
        key: item,
        source: new pulumi.asset.FileAsset(filePath), // use FileAsset to point to a file
        contentType: mime.getType(filePath) || undefined // set the MIME type of the file
      });
    })
The only change in this area is I updated the build so it doesn't produce source maps anymore.
c
@hundreds-musician-51496 where you able to find the problem?
h
Some discussion in this thread - https://pulumi-community.slack.com/archives/CRH5ENVDX/p1591466203276600. Might be related to a known issue (https://github.com/pulumi/pulumi/issues/3900). What I ended up doing was synchronizing my s3 bucket with the
aws
tool after deployment 😞. Hopefully a temporary workaround.