rumblelabs/asset_sync — Issue #21: Precompile failing to sync (403 Forbidden)
Author: bullfight
Created: 2011-11-14 12:39:19+00:00
State: open

I have not been able to get my assets to sync to my amazon bucket. I know that my app has access to the bucket, as I have given it permission via a group policy shown below, but no matter what I have tried I can't get my assets to sync. I keep getting a HTTP 403 error code.

ruby-1.9.2-p290

````ruby
gem 'rails', '3.1.1'
gem 'asset_sync', '~> 0.1.9'

````

````ruby
AssetSync.configure do |config|
config.aws_access_key = 'hardcoded_key'
config.aws_access_secret = 'hardcoded_secret'
config.aws_bucket = 'goswimtv-staging'
config.existing_remote_files = "keep"
# Increase upload performance by configuring your region
# config.aws_region = "eu-west-1"
# Automatically replace files with their equivalent gzip compressed version
# config.gzip_compression = true
end

````

on push to heroku

````
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
/tmp/build_10dnyp6p3sc0u/vendor/bundle/ruby/1.9.1/gems/airbrake-3.0.4/lib/airbrake.rb:134:in `send_notice': undefined method `send_to_airbrake' for nil:NilClass (NoMethodError)
from /tmp/build_10dnyp6p3sc0u/vendor/bundle/ruby/1.9.1/gems/airbrake-3.0.4/lib/airbrake.rb:103:in `notify'
from /tmp/build_10dnyp6p3sc0u/vendor/bundle/ruby/1.9.1/gems/airbrake-3.0.4/lib/airbrake/rake_handler.rb:15:in `display_error_message_with_airbrake'
from /tmp/build_10dnyp6p3sc0u/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:142:in `rescue in standard_exception_handling'
from /tmp/build_10dnyp6p3sc0u/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:132:in `standard_exception_handling'
from /tmp/build_10dnyp6p3sc0u/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
from /tmp/build_10dnyp6p3sc0u/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `'
from /tmp/build_10dnyp6p3sc0u/vendor/bundle/ruby/1.9.1/bin/rake:19:in `load'
from /tmp/build_10dnyp6p3sc0u/vendor/bundle/ruby/1.9.1/bin/rake:19:in `

'
Precompiling assets failed, enabling runtime asset compilation
Injecting rails31_enable_runtime_asset_compilation
Please see this article for troubleshooting help:
http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting
````

compiling from command line

````
[staging][~/goswim] heroku run rake assets:precompile --app staging-goswim
Running rake assets:precompile attached to terminal... up, run.6
/usr/local/bin/ruby /app/vendor/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
** [NewRelic][11/14/11 12:18:58 +0000 5e3c3c91-52bc-41eb-87a1-9dc3a92768fa (31)] INFO : Dispatcher: thin
** [NewRelic][11/14/11 12:18:58 +0000 5e3c3c91-52bc-41eb-87a1-9dc3a92768fa (31)] INFO : Application: staging-goswim
** [NewRelic][11/14/11 12:18:58 +0000 5e3c3c91-52bc-41eb-87a1-9dc3a92768fa (31)] INFO : New Relic Ruby Agent 3.2.0.1 Initialized: pid = 31
** [NewRelic][11/14/11 12:18:59 +0000 5e3c3c91-52bc-41eb-87a1-9dc3a92768fa (31)] INFO : NewRelic::Agent::Samplers::DelayedJobLockSampler sampler not available: No DJ worker present
** [NewRelic][11/14/11 12:19:09 +0000 5e3c3c91-52bc-41eb-87a1-9dc3a92768fa (31)] INFO : Resolved collector.newrelic.com to 204.93.223.153
** [NewRelic][11/14/11 12:19:10 +0000 5e3c3c91-52bc-41eb-87a1-9dc3a92768fa (31)] INFO : Resolved collector-3.newrelic.com to 204.93.223.137
Connected to NewRelic Service at collector-3.newrelic.com:80
** [NewRelic][11/14/11 12:19:10 +0000 5e3c3c91-52bc-41eb-87a1-9dc3a92768fa (31)] INFO : Reporting performance data every 60 seconds.
/usr/local/bin/ruby /app/vendor/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets
** [NewRelic][11/14/11 12:19:33 +0000 5e3c3c91-52bc-41eb-87a1-9dc3a92768fa (64)] INFO : Dispatcher: thin
** [NewRelic][11/14/11 12:19:33 +0000 5e3c3c91-52bc-41eb-87a1-9dc3a92768fa (64)] INFO : Application: staging-goswim
** [NewRelic][11/14/11 12:19:33 +0000 5e3c3c91-52bc-41eb-87a1-9dc3a92768fa (64)] INFO : New Relic Ruby Agent 3.2.0.1 Initialized: pid = 64
** [NewRelic][11/14/11 12:19:33 +0000 5e3c3c91-52bc-41eb-87a1-9dc3a92768fa (64)] INFO : NewRelic::Agent::Samplers::DelayedJobLockSampler sampler not available: No DJ worker present
** [NewRelic][11/14/11 12:19:42 +0000 5e3c3c91-52bc-41eb-87a1-9dc3a92768fa (31)] WARN : Disabling serialization: Read-only file system - /newrelic_agent_store.db
** [NewRelic][11/14/11 12:19:46 +0000 5e3c3c91-52bc-41eb-87a1-9dc3a92768fa (6)] INFO : Dispatcher: thin
** [NewRelic][11/14/11 12:19:46 +0000 5e3c3c91-52bc-41eb-87a1-9dc3a92768fa (6)] INFO : Application: staging-goswim
** [NewRelic][11/14/11 12:19:46 +0000 5e3c3c91-52bc-41eb-87a1-9dc3a92768fa (6)] INFO : New Relic Ruby Agent 3.2.0.1 Initialized: pid = 6
** [NewRelic][11/14/11 12:19:46 +0000 5e3c3c91-52bc-41eb-87a1-9dc3a92768fa (6)] INFO : NewRelic::Agent::Samplers::DelayedJobLockSampler sampler not available: No DJ worker present
rake aborted!
Expected(200) <=> Actual(403 Forbidden)
request => {:connect_timeout=>60, :headers=>{"Date"=>"Mon, 14 Nov 2011 12:19:49 +0000", "Authorization"=>"AWS AKIAJM3OUCTTRGTWMWWA:nXHp0GGIQSpKSAvjIXLtpYFjTbk=", "Host"=>"goswimtv-staging.s3.amazonaws.com:443", "Content-Length"=>0}, :host=>"goswimtv-staging.s3.amazonaws.com", :mock=>nil, :path=>"/", :port=>"443", :query=>{}, :read_timeout=>60, :scheme=>"https", :write_timeout=>60, :expects=>200, :idempotent=>true, :method=>"GET"}
response => #\nAccessDeniedAccess Denied59E95DA3405C280DFtbIFLAD3oK4LQLnqgX8uygY+8kRXbpLaTPWTUjdtmxrTE2n1J0UDlAzJHe6jf7d", @headers={"x-amz-request-id"=>"59E95DA3405C280D", "x-amz-id-2"=>"FtbIFLAD3oK4LQLnqgX8uygY+8kRXbpLaTPWTUjdtmxrTE2n1J0UDlAzJHe6jf7d", "Content-Type"=>"application/xml", "Transfer-Encoding"=>"chunked", "Date"=>"Mon, 14 Nov 2011 12:19:49 GMT", "Server"=>"AmazonS3"}, @status=403>

Tasks: TOP => assets:precompile
````

And a resultant Log from my S3 Bucket

````
fd69332feeccfaac7caf291d645bda05c982f1c6bb12d29015c3cdf7ef5a882d goswimtv-staging [14/Nov/2011:11:08:28 +0000] 195.241.148.235 arn:aws:iam::967741550144:user/goswimtv_app FCC131D7A7B1BE76 REST.GET.BUCKET - "GET / HTTP/1.1" 403 AccessDenied 231 - 15 - "-" "-" -
fd69332feeccfaac7caf291d645bda05c982f1c6bb12d29015c3cdf7ef5a882d goswimtv-staging [14/Nov/2011:11:17:27 +0000] 10.194.22.16 3272ee65a908a7677109fedda345db8d9554ba26398b2ca10581de88777e2b61 2BE3A542843C517D REST.PUT.OBJECT logs2011-11-14-11-17-27-8464AC8CEC983217 "PUT /goswimtv-staging/logs2011-11-14-11-17-27-8464AC8CEC983217 HTTP/1.1" 403 AccessDenied 231 818 19 - "-" "Jakarta Commons-HttpClient/3.0" -
fd69332feeccfaac7caf291d645bda05c982f1c6bb12d29015c3cdf7ef5a882d goswimtv-staging [14/Nov/2011:11:22:14 +0000] 10.119.93.14 fd69332feeccfaac7caf291d645bda05c982f1c6bb12d29015c3cdf7ef5a882d 6120BB9FAEA5BFAA REST.GET.BUCKET - "GET /goswimtv-staging?prefix=&max-keys=100&marker=&delimiter=/ HTTP/1.1" 200 - 1136 - 41 39 "-" "S3Console/0.4" -
fd69332feeccfaac7caf291d645bda05c982f1c6bb12d29015c3cdf7ef5a882d goswimtv-staging [14/Nov/2011:11:22:21 +0000] 10.194.64.24 fd69332feeccfaac7caf291d645bda05c982f1c6bb12d29015c3cdf7ef5a882d 959249E37A0007D9 REST.GET.BUCKETPOLICY - "GET /goswimtv-staging?policy HTTP/1.1" 404 NoSuchBucketPolicy 297 - 41 - "-" "S3Console/0.4" -
````

my user group policy should give my S3 user account access to all actions on the S3 bucket, and it shouldn't be rejected

````
{
"Statement": [
{
"Sid": "Stmt1314716526050staging",
"Action": "s3:*",
"Effect": "Allow",
"Resource": "arn:aws:s3:::goswimtv-staging/*"
}
]
}
````