aws / aws-msk-iam-auth

Enables developers to use AWS Identity and Access Management (IAM) to connect to their Amazon Managed Streaming for Apache Kafka (Amazon MSK) clusters.
Apache License 2.0
138 stars 65 forks source link

#127 Change region metadata provider to use partitions loader #134

Closed nihalpot closed 10 months ago

nihalpot commented 10 months ago

Issue #, if available: Described in #127 Auth failure when connecting from cross-region to MSK and cross-cloud

Description of changes: The LegacyRegionXmlMetadataBuilder is built on the InMemoryRegionsProvider which does not implement the tryGetRegionByEndpointDnsSuffix method. This changes the call to RegionMetadataFactory.create() to PartitionsLoader instead which does define that method.

nihalpot commented 10 months ago

LGTM. Did you verify it fixes inside your environment?

Yup I did, I tried this specific section of code. Just sharing some code here to validate this fix:

import com.amazonaws.regions.LegacyRegionXmlMetadataBuilder
import com.amazonaws.regions.RegionMetadata
import com.amazonaws.partitions.PartitionsLoader

val newMetadata = new RegionMetadata(new PartitionsLoader().build())
val legacyMetadata = new LegacyRegionXmlMetadataBuilder().build()

println(newMetadata.tryGetRegionByEndpointDnsSuffix("msk.us-east-2.amazonaws.com")) // works
println(legacyMetadata.tryGetRegionByEndpointDnsSuffix("msk.us-east-2.amazonaws.com")) // doesn't work
plazma-prizma commented 10 months ago

LGTM much simpler and neat thanks for the PR!