Skip to content

Detect AWS domain suffix automatically #7136

@ab295382

Description

@ab295382

User Story

As a system administrator, I want the AWS domain suffix used throughout Sleeper to be detected automatically, so that the deployment tooling is not tied to a single fixed domain.

Description / Background

Currently, the string amazonaws.com is hardcoded in multiple locations across the codebase. One example is in UploadDockerImagesToEcr, where it is used to construct the ECR repository host:

String.format("%s.dkr.ecr.%s.amazonaws.com", account, region)

This hardcoded value means that any deployment environment requiring a different domain suffix cannot be supported without modifying source code.

Acceptance Criteria

Given the AWS domain suffix has been set to a non-default value
When Sleeper constructs any AWS service endpoint (e.g. ECR)
Then the configured domain suffix is used in place of amazonaws.com

Given no domain suffix property has been configured
When Sleeper constructs any AWS service endpoint
Then amazonaws.com is used as the default, and existing deployments are unaffected

Technical Notes / Implementation Details

We should be able to extract the suffix from AWS code. If that's not possible we could add an instance property and default it to amazonaws.com.

Partition metadata from AWS SDK

Each AWS client has a getter serviceClientConfiguration() that lets you retrieve its configuration. This includes a way to get region and partition metadata, including a DNS suffix.

That ends up using MetadataLoader to load the region and partition metadata. We could use that directly like this:

Region region = new DefaultAwsRegionProviderChain().getRegion();
PartitionMetadata partition = PartitionMetadata.of(region);
String dnsSuffix = partiton.dnsSuffix();

The Javadoc of that dnsSuffix getter says "Returns the DNS suffix, such as amazonaws.com for this partition."

It looks like the only implementation we have on the classpath to get the partition metadata is GeneratedPartitionMetadataProvider. That hard codes certain partitions, so this would only work for one of those partitions.

Applying the change

All hardcoded occurrences of amazonaws.com in non-test production code should be replaced with a reference to this configuration.

Test code that asserts on constructed URLs may also need updating.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions