Bash Resource Not Reading User/CWD Attribute in Chef 11.10

I’m running a local Ubuntu 14.04 VM with Chef 11.10 via Test Kitchen. I want to sync files between an AWS S3 bucket and my local directory via ‘aws s3 sync’ but “kitchen converge” keeps erroring out stating “Unable to locate credentials”. However, I’m able to su and run the command successfully via the CLI (within the VM).

Here is the code in question (in my recipe):

bash ‘Sync WordPress content from S3 bucket’ do
user 'anyperk’
cwd '/home/anyperk/'
code <<-EOH
aws s3 sync --region us-west-1 s3://path/to/bucket/ .
EOH
end

And here is the error output:

Good money says you need to set $HOME in the environment as well. Newer versions of chef do this for you, but you’ll just have to do it manually in the resource:

bash 'Sync WordPress content from S3 bucket' do
  user 'anyperk'
  cwd '/home/anyperk/'
  environment 'HOME' => '/home/anyperk'
  code 'aws s3 sync --region us-west-1 s3://path/to/bucket/ .'
end

Thanks, @coderanger! Setting the $HOME environment variable resolved my problem.