AWS SDK v3 for nodejs, how to get tags of an s3 bucket?

Viewed 3834

I'm trying to extract tags of an s3 bucket with the AWS SDK v3 for Nodejs. This is my code, based on the example how to list all buckets:

const { S3Client, GetBucketTaggingCommand } = require("@aws-sdk/client-s3");
const { fromIni } = require("@aws-sdk/credential-provider-ini");

const s3 = new S3Client({
  credentials: fromIni({
    profile: 'example-s3'
  })
});


const run = async () => {
  try {
    const data = await s3.send(new GetBucketTaggingCommand({
      Bucket: "example-bucket"
    }));
    console.log("Success", data);
  } catch (err) {
    console.log("Error", err);
  }
};


run();

If I run this, I get

Error Error: No value provided for input HTTP label: Bucket.

I've read through the documentation of GetBucketTaggingCommand. It requires an input of type GetBucketTaggingCommandInput. That is a json object with an required attribute Bucket, which I have provided. So what am I missing here?

1 Answers

It means that your Bucket name was not set. Check it.

Related