miasma-rb / miasma-aws

Miasma AWS API
Other
8 stars 8 forks source link

Broken SparkleFormation Validation #50

Closed hybby closed 6 years ago

hybby commented 6 years ago

It appears as though the recent release of miasma-aws 0.3.18 has broken the sfn validate command:

$ bundle list | grep miasma-aws
  * miasma-aws (0.3.18)
$ bundle exec sfn validate -f ./lib/sparkleformation/templates/template.rb -d --debug
[DEBUG]: Initial compile parameters - {}
[DEBUG]: Merged compile parameters - {}
[Sfn]: Template Validation (aws):  lib/sparkleformation/templates/template.rb
[Sfn]: Validating: template
[Sfn]:   -> INVALID
[FATAL]: no implicit conversion of nil into String
ERROR: TypeError: no implicit conversion of nil into String
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/miasma-aws-0.3.18/lib/miasma/contrib/aws.rb:97:in `digest'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/miasma-aws-0.3.18/lib/miasma/contrib/aws.rb:97:in `sign'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/miasma-aws-0.3.18/lib/miasma/contrib/aws.rb:230:in `sign_request'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/miasma-aws-0.3.18/lib/miasma/contrib/aws.rb:218:in `generate_signature'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/miasma-aws-0.3.18/lib/miasma/contrib/aws.rb:176:in `generate'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/miasma-aws-0.3.18/lib/miasma/contrib/aws.rb:780:in `make_request'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/miasma-0.3.4/lib/miasma/types/api.rb:124:in `block in request'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/bogo-0.2.12/lib/bogo/retry.rb:65:in `run!'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/miasma-0.3.4/lib/miasma/types/api.rb:148:in `retryable_request'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/miasma-0.3.4/lib/miasma/types/api.rb:123:in `request'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/miasma-aws-0.3.18/lib/miasma/contrib/aws/storage.rb:141:in `bucket_reload'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/miasma-0.3.4/lib/miasma/models/storage/bucket.rb:31:in `perform_reload'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/miasma-0.3.4/lib/miasma/types/model.rb:81:in `reload'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/miasma-aws-0.3.18/lib/miasma/contrib/aws/storage.rb:105:in `bucket_get'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/miasma-0.3.4/lib/miasma/types/collection.rb:105:in `perform_get'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/miasma-0.3.4/lib/miasma/types/collection.rb:39:in `block in get'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/bogo-0.2.12/lib/bogo/memoization.rb:64:in `memoize'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/miasma-0.3.4/lib/miasma/types/collection.rb:38:in `get'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/sfn-3.0.30/lib/sfn/command_module/template.rb:385:in `store_template'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/sfn-3.0.30/lib/sfn/command/validate.rb:49:in `validate_stack'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/sfn-3.0.30/lib/sfn/command/validate.rb:24:in `execute!'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/sfn-3.0.30/bin/sfn:52:in `block (4 levels) in <top (required)>'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/bogo-cli-0.2.14/lib/bogo-cli/setup.rb:26:in `block in bogo_cli_run'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/slop-3.6.0/lib/slop.rb:260:in `parse!'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/slop-3.6.0/lib/slop.rb:235:in `parse!'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/slop-3.6.0/lib/slop.rb:65:in `parse!'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/slop-3.6.0/lib/slop.rb:54:in `parse'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/bogo-cli-0.2.14/lib/bogo-cli/setup.rb:48:in `define'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/gems/sfn-3.0.30/bin/sfn:14:in `<top (required)>'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/bin/sfn:23:in `load'
/var/lib/jenkins/workspace/sparkleformation-pull-requests-testing/.gem/ruby/2.4.0/bin/sfn:23:in `<top (required)>'
/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.2/lib/bundler/cli/exec.rb:74:in `load'
/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.2/lib/bundler/cli/exec.rb:74:in `kernel_load'
/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.2/lib/bundler/cli/exec.rb:28:in `run'
/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.2/lib/bundler/cli.rb:424:in `exec'
/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.2/lib/bundler/cli.rb:27:in `dispatch'
/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.2/lib/bundler/cli.rb:18:in `start'
/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.2/exe/bundle:30:in `block in <top (required)>'
/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.2/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.2/exe/bundle:22:in `<top (required)>'
/opt/rbenv/versions/2.4.2/bin/bundle:23:in `load'
/opt/rbenv/versions/2.4.2/bin/bundle:23:in `<main>'

When I downgrade my version of miasma-aws to 0.3.16, functionality is restored:

$ bundle list | grep miasma-aws
  * miasma-aws (0.3.16)
$ bundle exec sfn validate -f ./lib/sparkleformation/templates/template.rb -d --debug
[DEBUG]: Initial compile parameters - {}
[DEBUG]: Merged compile parameters - {}
[Sfn]: Template Validation (aws):  ./lib/sparkleformation/templates/template.rb
[Sfn]: Validating: template
[Sfn]:   -> VALID

Looking at the changelog and referenced PR (#49), I believe this may be caused by the change to this line:

https://github.com/miasma-rb/miasma-aws/pull/49/files#diff-e10f20b08f97e415929ebc03b633cb19L349

From what I can tell, we're currently setting the environment variable AWS_SESSION_TOKEN and I presume the value of that is making its way to attribute :aws_sts_session_token in earlier versions of miasma-aws. The update's presumably broken that behavior.

Is there some better way for us to pull in the session token rather than relying on this environment variable? Happy to take your advice.

chrisroberts commented 6 years ago

I'll get this fixed to properly typecast the variable and generate a useful error. In the meantime, you can set the attribute in your .sfn configuration file:

Configuration.new do
  credentials do
    provider :aws
    aws_sts_session_token ENV["AWS_SESSION_TOKEN"]
  end
end