This does not work in RDS. In order to update system catalog tables (pg_index), one needs privileges which is
denied in RDS. In RDS terminology, the user must belong to role rdsadmin and that role is reserved only for AWS
internal users.
Right, but pl/pgsql works fine there, so you can backup&drop all indexes and then restore them using `do $$ ... $$ language plpgsql;`, as Thomas Kellerer already suggested.