I tried if I use access key, it works fine but I am trying to get ride of access key and using role instead, but once I get ride of access key. what I get in return is ww
You can't use getSignedUrl() synchronously when using IAM roles.
Note: You must ensure that you have static or previously resolved credentials if you call this method synchronously (with no callback), otherwise it may not properly sign the request. If you cannot guarantee this (you are using an asynchronous credential provider, i.e., EC2 IAM roles), you should always call this method with an asynchronous callback.
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#getSignedUrl-property
s3.getSignedUrl('getObject', params, function (err, url) {
console.log('The URL is', url);
});