'Access Denied on MSSQL restore database script

I have a SQL Serve instance running on AWS RDS configured to restore a .bak file from AWS S3. I'm connected through Microsoft SQL Server Management Studio and run the next script and works well.

exec msdb.dbo.rds_restore_database @restore_db_name='db_name', @s3_arn_to_restore_from=‘arn:aws:s3:::bucket_name/file_name.bak';

But when run the next script EXEC msdb.dbo.rds_task_status; I got the error:

[2022-03-08 12:23:22.060] Aborted the task because of a task failure or a concurrent RESTORE_DB request. [2022-03-08 12:23:22.137] Task has been aborted [2022-03-08 12:23:22.137] Access Denied

The Options Group has SQLSERVER_BACKUP_RESTORE option with a role configured and this role is added to bucket policy.

...
"Effect": "Allow",
"Principal": {
  "AWS": "arn:aws:iam::code:role/service-role/role_name"
},
"Action": "s3:*",
"Resource": [
  "arn:aws:s3:::bucket_name",
  "arn:aws:s3:::bucket_name/*"
]
...

Any idea how to solve it ? Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source