I stored test data file in S3 bucket and tried to access uding s3client.
I used AWS JSLib for K6 to configure and connect to S3 client. It could not find bucket in a SSO enabled AWS account which requires AWS_SESSION_TOKEN.
The AWS Config doesn’t have a provision to pass Session Token alongwith Access_Key_ID and Secret_Access_Key which is mandatory for SSO enabled accounts.
Here is my script to access a bucket.
export default function verifyBucket(){
let testBucketName ="mybucket";
try{
const s3 = new S3Client(awsConfig);
} catch (err){
console.error(err)
} finally {
console.log("s3 client creation check finished.")
}
const buckets = s3.listBuckets();
console.log("first bucket:"+buckets[0])
console.log("bucket count:"+buckets.length)
if (buckets.filter((bucket) => bucket.name === testBucketName).length == 0) {
exec.test.abort();
} else {
console.log("bucket found")
}
}
Output I get:
INFO[0001] s3 client creation check finished. source=console
INFO[0002] first bucket:undefined source=console
INFO[0002] bucket count:0 source=console
Need to send all three parameters for connection.
Is there any way I can pass the session Token?