Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick attempt at resolving AWS signing problems #1596

Draft
wants to merge 1 commit into
base: series/0.18
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion modules/aws-http4s/src/smithy4s/aws/AwsClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ object AwsClient {

def baseRequest(endpoint: OperationSchema[_, _, _, _, _]): F[HttpRequest[Blob]] = {
awsEnv.region.map { region =>
val endpointPrefix = awsService.endpointPrefix.getOrElse(endpoint.id.name)
val endpointPrefix =
awsService.endpointPrefix
.orElse(awsService.arnNamespace.map(_.value))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: should this be sigv4 rather than arnNamespace?

should we even be looking at endpointPrefix? sigv4 is supposed to match arnNamespace but smithy says it's a SHOULD (see documentation trait of the sigv4 trait members).

For what it's worth, both Sagemaker and Location work if sigv4 is used instead, in both locations of this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should eventually just go through all services on https://docs.aws.amazon.com/general/latest/gr/aws-service-information.html one-by-one and validate that we compute the right urls...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's a bit misleading because of the endpointPrefix value name, but really we should be using the sigv4 value here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I'll change to sigv4 then, and maybe run through the services to see if it's present on all of them (and what the fallback should be).

.getOrElse(endpoint.id.name)

val baseUri = HttpUri(
scheme = HttpUriScheme.Https,
host = s"$endpointPrefix.$region.amazonaws.com",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ private[aws] object AwsSigning {
): Client[F] => Client[F] = {
val endpointPrefix = serviceHints
.get(_root_.aws.api.Service)
.flatMap(_.endpointPrefix)
.flatMap { awsService =>
awsService.endpointPrefix
.orElse(awsService.arnNamespace.map(_.value))
}
.getOrElse(serviceId.name)
.toLowerCase()

Expand Down