xp-forge / aws

AWS Core for the XP Framework
0 stars 0 forks source link

Support alternate domains when passed a prefix ending with "." #19

Closed thekid closed 1 month ago

thekid commented 1 month ago

Typically, the pattern for AWS service's endpoints is {service}.amazonaws.com (or {service}.{region}.amazonaws.com). In some cases like with Bedrock, there are two separate endpoint: bedrock for management, and bedrock-runtime for accessing the AI models. However, the credentials need to always scoped to the service, for which the using() method was established.

This PR adds a shorthand for having to repeat the region and top-level domain in this case by passing the prefix ending with a ".":

use com\amazon\aws\{ServiceEndpoint, CredentialProvider};

// Before
$runtime= (new ServiceEndpoint('bedrock', CredentialProvider::default()))
  ->using('bedrock-runtime.eu-central-1.amazonaws.com')
  ->in('eu-central-1')
;

// After
$runtime= (new ServiceEndpoint('bedrock', CredentialProvider::default()))
  ->using('bedrock-runtime.')
  ->in('eu-central-1')
;
thekid commented 1 month ago

Released in https://github.com/xp-forge/aws/releases/tag/v2.6.0