https://pulumi.com logo
#aws
Title
# aws
g

gorgeous-lunch-7514

09/08/2023, 1:16 PM
Copy code
const adminBucketDir = `${__dirname}/../build/`;
const updatedFiles: BucketObject[] = [];
crawlDirectory(adminBucketDir, (filePath: string) => {
  const relativeFilePath = filePath.replace(adminBucketDir + "/", "");
  console.log(relativeFilePath, filePath);
  const contentFile = new aws.s3.BucketObject(
    relativeFilePath,
    {
      key: relativeFilePath,
      acl: "public-read",
      bucket: config.adminBucket,
      contentType: mime.getType(filePath) || undefined,
      source: new pulumi.asset.FileAsset(filePath),
    }
  );
  updatedFiles.push(contentFile);
});
b

billowy-army-68599

09/08/2023, 1:27 PM
what is
config.adminBucket
set to?
g

gorgeous-lunch-7514

09/08/2023, 1:27 PM
the actual bucket (export const adminBucket = new aws.s3.Bucket) from our core infra config
I could add an export for adminBucket.id and forward that?
b

billowy-army-68599

09/08/2023, 1:49 PM
what’s its value? it seems to be the wrong type. I would export const config.adminBucket first to see what the value is set to
g

gorgeous-lunch-7514

09/08/2023, 1:50 PM
Copy code
pulumi:pulumi:Stack (admin-dev):
    OutputImpl {
      __pulumiOutput: true,
      resources: [Function (anonymous)],
      allResources: [Function (anonymous)],
      isKnown: Promise { <pending> },
      isSecret: Promise { <pending> },
      promise: [Function (anonymous)],
      toString: [Function (anonymous)],
      toJSON: [Function (anonymous)]
    }
that’s my console log, it should be a Output<Bucket>
I can try apply and then .id or something too perhaps?
b

billowy-army-68599

09/08/2023, 1:52 PM
yeah that’s likely the issue
g

gorgeous-lunch-7514

09/08/2023, 1:53 PM
Copy code
const updatedFiles: BucketObject[] = [];
config.adminBucket.apply(bucket => {
  const adminBucketDir = `${__dirname}/../build/`;
  crawlDirectory(adminBucketDir, (filePath: string) => {
    const relativeFilePath = filePath.replace(adminBucketDir + "/", "");
    console.log(relativeFilePath, filePath);
    const contentFile = new aws.s3.BucketObject(
      relativeFilePath,
      {
        key: relativeFilePath,
        acl: "public-read",
        bucket: bucket.id,
        contentType: mime.getType(filePath) || undefined,
        source: new pulumi.asset.FileAsset(filePath),
      }
    );
    updatedFiles.push(contentFile);
  });
})
This seems to be successful, I’m going to export the id and see if I need to apply
with just bucket it was still failing
b

billowy-army-68599

09/08/2023, 1:55 PM
you shouldn’t need to
g

gorgeous-lunch-7514

09/08/2023, 2:02 PM
we’re good, I’ll start using
bucket.id
over
bucket
for
new aws.s3.BucketObject
in the future cheers for the help