The error occurred when creating STS Client and S3 client is not yet in the picture. So the first thing you need to do is allow "test" user to assume role. So please try to attach the policy to the user itself.