xp-forge / aws

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

Add ServiceEndpoint::using() to change the domain or domain prefix #2

Closed thekid closed 1 year ago

thekid commented 1 year ago

Example:

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

$credentials= ...;
return function($event, $context) use($credentials) {

  // Send message to WebSocket connection
  (new ServiceEndpoint('execute-api', $credentials))
    ->in($context->region)
    ->using($event['requestContext']['domainName']) // or: ->using($event['requestContext']['apiId'])
    ->resource('/{stage}/@connections/{connectionId}', $event['requestContext'])
    ->transmit(['message' => 'Reply'])
  ;
  return ['statusCode' => 200];
};
thekid commented 1 year ago

Verified this works in a production setup.

thekid commented 1 year ago

Released in https://github.com/xp-forge/aws/releases/tag/v1.0.0