use local variables in s3 image function