AWS SDK for PHP Eventbridge scheduler with api destination throws error as Provided Arn is not in correct format

huangapple go评论48阅读模式
英文:

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-&gt;createSchedule([
            &#39;ClientToken&#39; =&gt; &#39;test_1&#39;,
            &#39;Description&#39; =&gt; &#39;test scheduler&#39;,
            &#39;FlexibleTimeWindow&#39; =&gt; [ 
                &#39;Mode&#39; =&gt; &#39;OFF&#39;,
            ],
            &#39;Name&#39; =&gt; &#39;test_scheduler&#39;, 
            &#39;ScheduleExpression&#39; =&gt; &#39;at(2023-04-05T08:00:00)&#39;, 
            &#39;State&#39; =&gt; &#39;ENABLED&#39;,
            &#39;Target&#39; =&gt; [ 
				&#39;Arn&#39; =&gt; &#39;Arn name copied from aws console for api destination&#39;,
                &#39;RoleArn&#39; =&gt; &#39;role arn copied from aws console&#39;,
            ],
        ]);

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-&gt;createSchedule([
                    &#39;ClientToken&#39; =&gt; &#39;test_2&#39;,
                    &#39;Description&#39; =&gt; &#39;test scheduler&#39;,
                    &#39;FlexibleTimeWindow&#39; =&gt; [ 
                        &#39;Mode&#39; =&gt; &#39;OFF&#39;,
                    ],
                    &#39;Name&#39; =&gt; &#39;test_scheduler2&#39;, 
                    &#39;ScheduleExpression&#39; =&gt; &#39;at(2023-04-12T08:00:00)&#39;, // REQUIRED
                    &#39;State&#39; =&gt; &#39;ENABLED&#39;,
                    &#39;Target&#39; =&gt; [ 
                        &#39;Arn&#39; =&gt; &#39;arn:aws:scheduler:::aws-sdk:eventbridge:createApiDestination&#39;, //need to add this service name not the arn name of api destination
                        &#39;RoleArn&#39; =&gt; &#39;&lt;role arn with relevent permission&gt;&#39;,
                        &#39;Input&#39; =&gt; json_encode([
                            &#39;ConnectionArn&#39; =&gt; &#39;&lt;ConnectionArn Name&gt;&#39;, 
                            &#39;Description&#39; =&gt; &#39;schedulerAPIs2&#39;,
                            &#39;HttpMethod&#39; =&gt; &#39;POST&#39;, 
                            &#39;InvocationEndpoint&#39; =&gt; &#39;endpoint url&#39;, 
                            &#39;InvocationRateLimitPerSecond&#39; =&gt; 10,
                            &#39;Name&#39; =&gt; &#39;schedulerAPIs3&#39;, 
                        ]),
                    ],
                ]);

huangapple
  • 本文由 发表于 2023年4月4日 17:25:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/75927700.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定