0

I got completely jammed at trying to get AWS S3 to work together with Travis using Figaro.

This all works fine in dev mode:

picture.rb

class Picture < ApplicationRecord
  acts_as_list
  belongs_to :imageable, polymorphic: true

  has_attached_file :image,
    :storage    => :s3,
    :bucket     => Figaro.env.s3_bucket,
    :s3_region  => 'eu-west-1',
    :s3_credentials => {
      :access_key_id      => Figaro.env.aws_access_key_id,
      :secret_access_key  => Figaro.env.aws_secret_access_key
    }

  do_not_validate_attachment_file_type :image
end

application.yml

aws_access_key_id: 'xxx'
aws_secret_access_key: 'xxx'
aws_region: 'eu-west-1'

development:
  s3_bucket: 'company-name-dev'

production:
  s3_bucket: 'company-name-prod'

Obviously Travis needs access to these keys:

.travis.yml

language: ruby
before_install:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
rvm:
- 2.4.0
bundler_args: "--jobs=2"
script:
- bundle exec rake db:setup
- bundle exec rake spec
cache: bundler
services:
- postgresql
addons:
  postgresql: '9.4'
deploy:
  provider: heroku
  api_key:
    secure: verlongherokukey
  app: imkerij
  on:
    repo: MyGitHub/MyRepoName
  skip_cleanup: true
env:
  matrix:
  - s3_bucket='company-name-dev'
  global:
  - secure: verylongkey
  - secure: anotherverylongkey

I keep on getting AWS missing credentials errors or Figaro MissingKeys errors in Travis.

Figaro::MissingKeys: Missing required configuration keys: ["aws_access_key_id", "aws_secret_access_key"]

Which only happened btw after adding:

Figaro.require_keys("aws_access_key_id", "aws_secret_access_key")

Before that I got AWS credentials missing or something, all the time.

Seems like the keys are not getting through. Also not when using the ENV form of writing them down. Then even in development stuff doesn't work anymore.

Any help is certainly appreciated. Got me stuck for days. Also another solution, just using secrets I would appreciate.

Code-MonKy
  • 2,026
  • 2
  • 14
  • 27

1 Answers1

0

I solved this by going inside my Travis CI project settings, where I could add the keys. Worked immediately.

Using the travis encrypt function for my .yml in each and every way did not.

Code-MonKy
  • 2,026
  • 2
  • 14
  • 27