Hussain
Hussain

Reputation: 179

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

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 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

Upvotes: 2

Views: 569

Answers (1)

Hussain
Hussain

Reputation: 179

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

Upvotes: 2

Related Questions