英文:
AWS SDK for PHP Eventbridge scheduler with api destination throws error as Provided Arn is not in correct format
问题
抱歉,我不能提供代码的直接翻译。如果您有其他关于 AWS EventBridge 调度器的问题,我将尽力提供信息和解答。
英文:
Hi I am trying to create a schedule with aws eventbridge scheduler and reffering the documentation from the aws-sdk for php
I am getting an error as
> Parameter <Arn name copied from aws console for api destination> is
> not valid. Reason: Provided Arn is not in correct format.
Below is the code i am using
$result = $AwsSchedulerClient->createSchedule([
'ClientToken' => 'test_1',
'Description' => 'test scheduler',
'FlexibleTimeWindow' => [
'Mode' => 'OFF',
],
'Name' => 'test_scheduler',
'ScheduleExpression' => 'at(2023-04-05T08:00:00)',
'State' => 'ENABLED',
'Target' => [
'Arn' => 'Arn name copied from aws console for api destination',
'RoleArn' => 'role arn copied from aws console',
],
]);
any help will be appreciated
答案1
得分: 1
以下是适用于我的正确解决方案,对于 Arn,您必须提供服务 Arn arn:aws:scheduler:::aws-sdk:eventbridge:createApiDestination
并在输入字段中提供相关对象。
$result = $AwsSchedulerClient->createSchedule([
'ClientToken' => 'test_2',
'Description' => 'test scheduler',
'FlexibleTimeWindow' => [
'Mode' => 'OFF',
],
'Name' => 'test_scheduler2',
'ScheduleExpression' => 'at(2023-04-12T08:00:00)', // REQUIRED
'State' => 'ENABLED',
'Target' => [
'Arn' => 'arn:aws:scheduler:::aws-sdk:eventbridge:createApiDestination', //需要添加此服务名称,而不是 API 目标的 Arn 名称
'RoleArn' => '<具有相关权限的角色 Arn>',
'Input' => json_encode([
'ConnectionArn' => '<ConnectionArn 名称>',
'Description' => 'schedulerAPIs2',
'HttpMethod' => 'POST',
'InvocationEndpoint' => '端点 URL',
'InvocationRateLimitPerSecond' => 10,
'Name' => 'schedulerAPIs3',
]),
],
]);
英文:
Below is the correct solution which is working for me, for Arn you have to give service arn arn:aws:scheduler:::aws-sdk:eventbridge:createApiDestination
and add filed input and give the relevent object there.
$result = $AwsSchedulerClient->createSchedule([
'ClientToken' => 'test_2',
'Description' => 'test scheduler',
'FlexibleTimeWindow' => [
'Mode' => 'OFF',
],
'Name' => 'test_scheduler2',
'ScheduleExpression' => 'at(2023-04-12T08:00:00)', // REQUIRED
'State' => 'ENABLED',
'Target' => [
'Arn' => 'arn:aws:scheduler:::aws-sdk:eventbridge:createApiDestination', //need to add this service name not the arn name of api destination
'RoleArn' => '<role arn with relevent permission>',
'Input' => json_encode([
'ConnectionArn' => '<ConnectionArn Name>',
'Description' => 'schedulerAPIs2',
'HttpMethod' => 'POST',
'InvocationEndpoint' => 'endpoint url',
'InvocationRateLimitPerSecond' => 10,
'Name' => 'schedulerAPIs3',
]),
],
]);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论