This code works perfectly in an SSMS query window.
The backup ends up in the AWS S3 bucket that I want it to be.
But it fails when in a SQL Server Agent Job.
I have tested this on two different RDS instances. Same behavior on both.
Both are running as the correct DBO account. The error from the job history says it is running as the same account.
This error doesn't make sense. The account is a member of the db_owner role.
Is this perhaps a limitation of RDS?
Are we not allowed to use the native SQL backups in the SQL Server agent?
@S3_arn_to_backup_to='arn:aws:s3:::<target buck in S3>'
The job failed. The Job was invoked by User <my user>. The last step to run was step 7 (Backup db '<my database>' to AWS S3).
Executed as user: <my user>. Database backups can only be performed by members of db_owner or db_backupoperator roles in source database [SQLSTATE 42000] (Error 50000) USAGE: EXECUTE msdb.dbo.rds_backup_database @source_db_name, @S3_arn_to_backup_to