Skip to content

Commit 5190d36

Browse files
Liz BaldoLiz Baldo
authored andcommitted
porting over changes from PR#7837
1 parent 530307d commit 5190d36

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The PK of the JOB_KEY_VALUE_ENTRY table will be migrated from INT to BIGINT.
1111
The Docker registry implementation now correctly handles ECR's support for repository-less image paths.
1212

1313
### AWS Batch
14+
* Added support for submitting jobs to AWS Batch queues in different regions. The region is now automatically derived from the `queueArn` runtime attribute, allowing multi-region workflows without additional configuration.
1415
* Fixed an issue where job failures before all outputs were written would cause delocalization to fail, preventing the upload of return code, stdout, and stderr files needed for debugging.
1516
* Split the option to tag resources between AWS Batch jobs vs. EC2 and EBS volumes hardware
1617
* Moved the option to tag job resources from runtime attributes to backend config.

supportedBackends/aws/src/main/scala/cromwell/backend/impl/aws/AwsBatchJob.scala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,20 @@ final case class AwsBatchJob(
110110
case prefix => if (prefix.endsWith("/")) prefix else s"$prefix/"
111111
}
112112

113+
// Region derived from queueArn, with configRegion as fallback
114+
// This allows jobs to be submitted to queues in different regions
115+
lazy val batchRegion: Option[Region] = regionFromArn(runtimeAttributes.queueArn).orElse(configRegion)
116+
113117
lazy val batchClient: BatchClient = {
114118
val builder = BatchClient.builder()
115-
configureClient(builder, optAwsAuthMode, configRegion)
119+
configureClient(builder, optAwsAuthMode, batchRegion)
116120
}
121+
// CloudWatch logs are in the same region as the Batch job
117122
lazy val cloudWatchLogsClient: CloudWatchLogsClient = {
118123
val builder = CloudWatchLogsClient.builder()
119-
configureClient(builder, optAwsAuthMode, configRegion)
124+
configureClient(builder, optAwsAuthMode, batchRegion)
120125
}
121-
126+
// S3 client uses the config region (S3 is region-agnostic for access)
122127
lazy val s3Client: S3Client = {
123128
val builder = S3Client.builder()
124129
configureClient(builder, optAwsAuthMode, configRegion)

supportedBackends/aws/src/main/scala/cromwell/backend/impl/aws/package.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@ package object aws {
1414

1515
type Aws[F[_], A] = ReaderT[F, AwsBatchAttributes, A]
1616

17+
/**
18+
* Extracts the AWS region from an ARN string.
19+
* ARN format: arn:partition:service:region:account-id:resource
20+
* For example: arn:aws:batch:eu-west-2:123456789012:job-queue/my-queue
21+
*
22+
* @param arn The ARN string to extract the region from
23+
* @return Some(Region) if a valid region is found, None otherwise
24+
*/
25+
def regionFromArn(arn: String): Option[Region] =
26+
Option(arn).flatMap { a =>
27+
val parts = a.split(":")
28+
if (parts.length >= 4 && parts(3).nonEmpty) {
29+
Some(Region.of(parts(3)))
30+
} else {
31+
None
32+
}
33+
}
34+
1735
def sanitize(name: String): String =
1836
// Up to 128 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed.
1937
// We'll replace all invalid characters with an underscore

0 commit comments

Comments
 (0)