https://pulumi.com logo
#general
Title
# general
h

hundreds-musician-51496

06/02/2020, 10:37 PM
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

gentle-diamond-70147

06/02/2020, 10:51 PM
Can you share your code?
c

calm-quill-21760

06/02/2020, 11:05 PM
Is your code not waiting for completion of an asynchronous write?
h

hundreds-musician-51496

06/03/2020, 12:53 AM
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

clever-plumber-29709

06/09/2020, 7:29 PM
@hundreds-musician-51496 where you able to find the problem?
h

hundreds-musician-51496

06/09/2020, 7:37 PM
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.