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

0

Hi I am trying to create a schedule with aws eventbridge scheduler

am getting an error as

Parameter 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',
            ],
        ]);
Hussain
질문됨 일 년 전588회 조회
2개 답변
0

'Arn' => 'Arn name copied from aws console for api destination',

Would it be possible to share the relevant API ARN?
For example, an ARN that stops RDS would be the following.

arn:aws:scheduler:::aws-sdk:rds:stopDBInstance
profile picture
전문가
답변함 일 년 전
  • Hi, Thank you very much for the input. When I try with the input you have given it shows error message as "scheduler is not a supported service for a target." Arn looks like arn:aws:scheduler:::aws:events:ap-south-1:<id>:api-destination/<api-destination-id>

  • I checked this document and it says that the ARN will be in the form of "arn:aws:scheduler:::aws-sdk:service:apiAction".
    https://docs.aws.amazon.com/ja_jp/scheduler/latest/UserGuide/managing-targets-universal.html

  • Thank you for the input, I checked this documentation, but i don't see api destination, but from console i can do

0

The solution is as below

`

$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', 
                    ]),
                ],
            ]);

`

Hussain
답변함 일 년 전

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

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

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

관련 콘텐츠