Skip to content

GetObjectCommand not working with IAM roles #6773

@randhirsingh0578

Description

@randhirsingh0578

Checkboxes for prior research

Describe the bug

const REGION = "us-east-2";
const config = {
  region: REGION,
}
const s3config = {
  region: PUBLIC_AWS_REGION,
  credentials:{
    accessKeyId: "exampleacessid",
    secretAccessKey: "examplesecretid"
  }
}
const s3Client = new S3Client(config);
export const retrieveBucketObjList = async (bucket) => {
  const command = new ListObjectsV2Command({Bucket: bucket});
  try{
    const bucketObjs = await s3Client.send(command);
    return bucketObjs?.Contents;
  }catch(error){
    return {error:error.message};
  }
}

export const retrieveBucketObj = async (bucket, key) => {
  const command = new GetObjectCommand({Bucket: bucket, Key: key});
  try{
    const object = await s3Client.send(command);
    return object;
  }catch(error){
    return {error:error.message}
  }
}

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/client-s3 3.721.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v20.12.0

Reproduction Steps

  1. Install aws/client-s3 sdk
  2. Run this code `given```

Observed Behavior

GetObjectCommand not working with IAM role policy throwing error Credential is missing while ListObjectsv2Command does not throw that GetObjectCommand properly work when i give s3config with hardcoded access and secret access keys it works perfectly

Expected Behavior

GetObjectCommand should work with IAM role provided secret and access keys as ListObjectsV2Command is working properly with IAM roles and permission for s3 bucket in IAM role and even bucket policy is properly configured checked that as well

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closed-for-stalenessp2This is a standard priority issueresponse-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions