Authentication issue with AWS SDK for PHP and EventBridge client

0

I have created global endpoint for EventBridge buses, one in us-east1, another in eu-north1 I use Wordpress instance hosted on AWS Lightsail to send event from PHP to global endpoint.

I installed composer and AWS SDK under PATH/vendor/

My PHP function:

require_once(__DIR__.'/vendor/autoload.php');

use Aws\EventBridge\EventBridgeClient;

$evClient = new EventBridgeClient([
	'region' => 'us-east-1'
]);

$endpointId = 'my-endpoint.veo';  
$eventBusName = 'my-bus-name';    

$event =  [
    'Source' => 'cybertechtalk',
    'DetailType' => 'test',
    'Detail' => json_encode(['foo' => 'bar']),
    'Time' => new DateTime(),
    'Resources' => ['php-script'],
    'EventBusName' => $eventBusName,
    'TraceHeader' => 'test'
];

$result = $evClient->putEvents([
    'EndpointId' => $endpointId,
    'Entries' => [$event]
]);

Exception:

Uncaught Aws\Auth\Exception\UnresolvedAuthSchemeException: This operation requests `sigv4a` auth schemes, but the client currently supports `sigv4`, `none`, `bearer`, `sigv4-s3express`. in /bitnami/wordpress/wp-content/plugins/insert-headers-and-footers/includes/vendor/aws/aws-sdk-php/src/EndpointV2/EndpointV2Middleware.php:265

Stack trace:
#0 /bitnami/wordpress/wp-content/plugins/insert-headers-and-footers/includes/vendor/aws/aws-sdk-php/src/EndpointV2/EndpointV2Middleware.php(233): Aws\EndpointV2\EndpointV2Middleware->resolveAuthScheme()
#1 /bitnami/wordpress/wp-content/plugins/insert-headers-and-footers/includes/vendor/aws/aws-sdk-php/src/EndpointV2/EndpointV2Middleware.php(96): Aws\EndpointV2\EndpointV2Middleware->applyAuthScheme()
#2 /bitnami/wordpress/wp-content/plugins/insert-headers-and-footers/includes/vendor/aws/aws-sdk-php/src/Middleware.php(90): Aws\EndpointV2\EndpointV2Middleware->__invoke()
#3 /bitnami/wordpress/wp-content/plugins/insert-headers-and-footers/includes/vendor/aws/aws-sdk-php/src/IdempotencyTokenMiddleware.php(77): Aws\Middleware::Aws\{closure}()
#4 /bitnami/wordpress/wp-content/plugins/insert-headers-and-footers/includes/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(64): Aws\IdempotencyTokenMiddleware->__invoke()
#5 /bitnami/wordpress/wp-content/plugins/insert-headers-and-footers/includes/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(58): Aws\AwsClient->executeAsync()
#6 /bitnami/wordpress/wp-content/plugins/insert-headers-and-footers/includes/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(86): Aws\AwsClient->execute()
#7 /bitnami/wordpress/wp-content/plugins/insert-headers-and-footers/includes/class-wpcode-snippet-execute.php(287) : eval()'d code(25): Aws\AwsClient->__call()
#8 /bitnami/wordpress/wp-content/plugins/insert-headers-and-footers/includes/class-wpcode-snippet-execute.php(287): eval()
#9 /bitnami/wordpress/wp-content/plugins/insert-headers-and-footers/includes/execute/class-wpcode-snippet-execute-php.php(32): WPCode_Snippet_Execute->safe_execute_php()
#10 /bitnami/wordpress/wp-content/plugins/insert-headers-and-footers/includes/execute/class-wpcode-snippet-execute-type.php(55): WPCode_Snippet_Execute_PHP->prepare_snippet_output()
#11 /bitnami/wordpress/wp-content/plugins/insert-headers-and-footers/includes/class-wpcode-snippet.php(623): WPCode_Snippet_Execute_Type->get_output()
#12 /bitnami/wordpress/wp-content/plugins/insert-headers-and-footers/includes/class-wpcode-snippet.php(465): WPCode_Snippet->run_activation_checks()
#13 /bitnami/wordpress/wp-content/plugins/insert-headers-and-footers/includes/admin/pages/class-wpcode-admin-page-snippet-manager.php(1087): WPCode_Snippet->save()
#14 /opt/bitnami/wordpress/wp-includes/class-wp-hook.php(324): WPCode_Admin_Page_Snippet_Manager->submit_listener()
#15 /opt/bitnami/wordpress/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#16 /opt/bitnami/wordpress/wp-includes/plugin.php(517): WP_Hook->do_action()
#17 /opt/bitnami/wordpress/wp-admin/admin.php(175): do_action() #18 {main} thrown
질문됨 한 달 전177회 조회
2개 답변
0
수락된 답변

Hello.

You may need to install the "AWS CRT extension" as described in the document below.
https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/eventbridge-examples.html

To use EventBridge global endpoints with the SDK for PHP, your PHP environment must have the AWS Common Runtime (AWS CRT) extension installed.

Please check the installation method on GitHub below.
https://github.com/awslabs/aws-crt-php#aws-common-runtime-php-bindings

profile picture
전문가
답변함 한 달 전
profile picture
전문가
검토됨 한 달 전
  • Thank you guys. Installing AWS CRT did not work

0

I also think you're encountering an authentication issue with your AWS SDK for PHP when trying to put events to the EventBridge bus. The error message indicates that the operation requests sigv4a authentication schemes, but the client only supports sigv4, none, bearer, sigv4-s3express.

To resolve this issue, you may need to configure your AWS SDK for PHP to use Signature Version 4 (sigv4) authentication scheme explicitly. Here's how you can modify your code to specify the authentication scheme:

require_once(DIR.'/vendor/autoload.php');

use Aws\EventBridge\EventBridgeClient; use Aws\Credentials\Credentials; use Aws\Signature\SignatureV4;

// Specify your AWS credentials $credentials = new Credentials('YOUR_ACCESS_KEY_ID', 'YOUR_SECRET_ACCESS_KEY');

// Specify the AWS region and authentication scheme $config = [ 'region' => 'us-east-1', 'version' => 'latest', 'signature' => new SignatureV4('eventbridge', 'us-east-1') ];

// Create an EventBridge client with the specified configuration $evClient = new EventBridgeClient($config + ['credentials' => $credentials]);

// Your code to put events to the EventBridge bus goes here

profile picture
Bravo
답변함 한 달 전
  • Codebase updated: require_once(DIR . '/vendor/autoload.php');

    use Aws\EventBridge\EventBridgeClient; use Aws\Credentials\Credentials; use Aws\Signature\SignatureV4;

    $credentials = new Credentials('YOUR_ACCESS_KEY_ID', 'YOUR_SECRET_ACCESS_KEY');

    $evClient = new EventBridgeClient([ 'region' => 'us-east-1', 'version' => 'latest', 'signature' => new SignatureV4('eventbridge', 'us-east-1'), 'credentials' => $credentials ]);

    Still same exception. Any ideas?

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠