S3 Object task fails due to AmazonS3Exception: invalid Date or x-amz-date header

Problem

Your builds fail due to Tasks for AWS encountering an AmazonS3Exception: AWS authentication requires a valid Date or x-amz-date header:

Selecting region ap-southeast-2 S3 request rejected by AWS! com.amazonaws.services.s3.model.AmazonS3Exception: AWS authentication requires a valid Date or x-amz-date header (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: 7D8CC94AATLASC2B), S3 Extended Request ID: 42v1eN6ItFvxZQ0aXs/NjhIie8e+e3pqukATLASvfDfXgXR5bn2I= at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1073) at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:721) at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:456) at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:295) at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3658) at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3608) at com.amazonaws.services.s3.AmazonS3Client.listObjects(AmazonS3Client.java:624) at com.amazonaws.services.s3.AmazonS3Client.listObjects(AmazonS3Client.java:607) at net.utoolity.atlassian.bamboo.taws.S3ObjectTask.getObjectSummaries(S3ObjectTask.java:349) at net.utoolity.atlassian.bamboo.taws.S3ObjectTask.executeDelete(S3ObjectTask.java:244) at net.utoolity.atlassian.bamboo.taws.S3ObjectTask.execute(S3ObjectTask.java:112) at net.utoolity.atlassian.bamboo.taws.AWSTask.execute(AWSTask.java:109) at com.atlassian.bamboo.task.TaskExecutorImpl.lambda$executeTasks$124(TaskExecutorImpl.java:273) at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:202) at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:273) at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:108) at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:74) at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:215) at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl$1.call(BuildAgentControllerImpl.java:139) at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl$1.call(BuildAgentControllerImpl.java:130) at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:215) at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:129) at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:137) at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:49) at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:31) at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:20) at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:52) at java.lang.Thread.run(Thread.java:745) Finished task 'Delete' with result: Error

Solution

This is a known issue with AWS SDK for Java up to and including version 1.10.0, which had in turn been caused by the upstream dependency Joda-Time being incompatible with Java >= 1.8u60.

It has been fixed in the AWS SDK for Java 1.10.1 by upgrading the Joda-Time dependency to version 2.8.1, and Tasks for AWS 2.8.0 is the earliest release that ships with this or a later AWS SDK for Java release. Accordingly, updating Tasks for AWS to the most current release (or any other release >= 2.8.0) will address the problem.

Workaround

If you are currently unable to update Tasks for AWS to a release that includes the fixed AWS SDK for Java, you might consider downgrading Java to release 1.8u45 (see note below for caveats).

 Please note that using a non current Java Virtual Machine usually implies running a Java version with known security vulnerabilities - please consider this carefully and apply the workaround at your own risk and in sufficiently controlled environments only!



Atlassian®, Atlassian Bamboo®, Bitbucket®, Atlassian Crowd®, Confluence®, Jira®, Jira Service Management™, Opsgenie®, and Statuspage™ are registered trademarks of Atlassian.
Amazon Web Services™, AWS™ and the “Powered by Amazon Web Services” logo are trademarks of Amazon.com, Inc. or its affiliates in the United States and/or other countries.

Utoolity® is a registered trademark of Utoolity GmbH.
© 2024 Utoolity GmbH. All rights reserved.