-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Description
Is there something different about AmazonS3Client.getObjectMetadata(..) such that V4 signatures are not being sent for HEAD requests?
I'm using the following code to verify that I can interact with buckets in all regions without setting specific region endpoints but it fails on getObjectMetadata for the EU_Frankfurt region. The strange thing is that only getObjectMetadata fails - creating a bucket, deleting a bucket, get and put work fine.
I've tried 'SDKGlobalConfiguration.ENABLE_S3_SIGV4_SYSTEM_PROPERTY' but no difference.
Stacktrace below.
SDK versions: 1.9.19 &1.9.20
AmazonS3Client amazonS3Client = new AmazonS3Client(basicAWSCredentials)
(Region.values() - [Region.US_GovCloud, Region.CN_Beijing]).each { Region region ->
String bucketName = "${BUCKET_NAME}-${region ?: region.name}"
println("Creating bucket: ${bucketName}")
CreateBucketRequest createBucketRequest = new CreateBucketRequest(bucketName, region)
amazonS3Client.createBucket(createBucketRequest)
println "-- uploading"
InputStream inputStream = new FileInputStream(file)
ObjectMetadata metadata = new ObjectMetadata()
metadata.setContentLength(file.length())
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, file.name, inputStream, metadata)
amazonS3Client.putObject(putObjectRequest)
//FAILING HERE FOR EU_Frankfurt
println "------Getting object metadata"
GetObjectMetadataRequest metadataRequest = new GetObjectMetadataRequest(bucketName,file.name)
ObjectMetadata objectMetadata = amazonS3Client.getObjectMetadata(metadataRequest)
println "------Getting object"
GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, file.name)
getObjectRequest.setRange(0, 0);
S3Object object = amazonS3Client.getObject(getObjectRequest)
InputStream objectData = object.getObjectContent();
objectData.close();
println "-- Deleting object"
DeleteObjectRequest deleteObjectRequest = new DeleteObjectRequest(bucketName, putObjectRequest.getKey())
amazonS3Client.deleteObject(deleteObjectRequest)
println("Deleting bucket: ${bucketName}")
DeleteBucketRequest deleteBucketRequest = new DeleteBucketRequest(bucketName)
amazonS3Client.deleteBucket(deleteBucketRequest)
}
Creating bucket: testv4signatures-us-west-1
-- uploading
------Getting object metadata
------Getting object
-- Deleting object
Deleting bucket: testv4signatures-us-west-1
Creating bucket: testv4signatures-us-west-2
-- uploading
------Getting object metadata
------Getting object
-- Deleting object
Deleting bucket: testv4signatures-us-west-2
Creating bucket: testv4signatures-eu-west-1
-- uploading
------Getting object metadata
------Getting object
-- Deleting object
Deleting bucket: testv4signatures-eu-west-1
Creating bucket: testv4signatures-eu-central-1
-- uploading
Feb 19, 2015 12:06:34 AM com.amazonaws.services.s3.AmazonS3Client shouldRetryWithAuthParam
WARNING: Attempting to re-send the request to testv4signatures-eu-central-1.s3-external-1.amazonaws.com with AWS V4 authentication. To avoid this warning in the future, please use region-specific endpoint to access buckets located in regions that require V4 signing.
------Getting object metadata
com.amazonaws.services.s3.model.AmazonS3Exception: Bad Request (Service: Amazon S3; Status Code: 400; Error Code: 400 Bad Request; Request ID: 1AD4BF78493A5206), S3 Extended Request ID: 78CyvR+iqPNnh1/UQ/xM/DkcwTCwVtPniVLlvfMyj96djN6sFHh28KE+jFx0TWITDzezDW6+LzQ=
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1077)
at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:725)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:460)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:295)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3736)
at com.amazonaws.services.s3.AmazonS3Client.getObjectMetadata(AmazonS3Client.java:1027)
Metadata
Metadata
Assignees
Labels
No labels