Where is uploaded your images ? Is it on the discourse server or on amazon ?
Normally this ugly function do the job:
function add_base_url_to_link($cooked, $base_url){
$relative_image_path = 'src="/uploads';
$absolute_image_path = 'src="'.$base_url.'/uploads';
$new_content = str_replace($relative_image_path, $absolute_image_path, $cooked, $count);
$relative_user_avatar_path = 'src="/user_avatar';
$absolute_user_avatar_path = 'src="'.$base_url.'/user_avatar';
$new_content = str_replace($relative_user_avatar_path, $absolute_user_avatar_path, $new_content, $count);
$relative_user_path = 'href="/users';
$absolute_user_path = 'href="'.$base_url.'/users';
$new_content = str_replace($relative_user_path, $absolute_user_path, $new_content, $count);
return $new_content;
}