rubyonjets / jets

Ruby on Jets
http://rubyonjets.com
MIT License
2.6k stars 181 forks source link

undefined method `red' when deploying #229

Closed dbackeus closed 5 years ago

dbackeus commented 5 years ago

Checklist

My Environment

Software Version
Operating System MacOS Mojave 10.14.4
Jets 1.8.9
Ruby 2.5.3

Expected Behaviour

When running jets deploy it should give me a helpful error message if the deploy fails for whatever reason.

I believe it actually worked the first time I ran it on this system but all subsequent times have had the same issues. Even when generating new apps from scratch.

Current Behavior

When running jets deploy after S3 bucket has been created and populated I get the following stack trace:

Traceback (most recent call last):
    16: from /Users/davidbackeus/.rbenv/versions/2.5.3/bin/jets:23:in `<main>'
    15: from /Users/davidbackeus/.rbenv/versions/2.5.3/bin/jets:23:in `load'
    14: from /Users/davidbackeus/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.9/exe/jets:14:in `<top (required)>'
    13: from /Users/davidbackeus/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.9/lib/jets/cli.rb:5:in `start'
    12: from /Users/davidbackeus/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.9/lib/jets/cli.rb:21:in `start'
    11: from /Users/davidbackeus/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.9/lib/jets/commands/base.rb:27:in `perform'
    10: from /Users/davidbackeus/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.9/lib/jets/commands/base.rb:38:in `dispatch'
     9: from /Users/davidbackeus/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
     8: from /Users/davidbackeus/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
     7: from /Users/davidbackeus/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
     6: from /Users/davidbackeus/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.9/lib/jets/commands/main.rb:21:in `deploy'
     5: from /Users/davidbackeus/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.9/lib/jets/commands/deploy.rb:34:in `run'
     4: from /Users/davidbackeus/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.9/lib/jets/commands/deploy.rb:81:in `ship'
     3: from /Users/davidbackeus/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.9/lib/jets/cfn/ship.rb:20:in `run'
     2: from /Users/davidbackeus/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.9/lib/jets/cfn/ship.rb:54:in `save_stack'
     1: from /Users/davidbackeus/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.9/lib/jets/cfn/ship.rb:65:in `update_stack'
/Users/davidbackeus/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.9/lib/jets/cfn/ship.rb:69:in `rescue in update_stack': undefined method `red' for #<String:0x00000001130eed18> (NoMethodError)

Looking at the stack on Cloudfront it has only created the S3 bucket on the Cloudformation stack. No gateway API or lambda functions etc.

Step-by-step reproduction instructions

jets new <app-name> --database=postgresql
cd <app-name>
echo "2.5.3" > .ruby-version
jets deploy

Solution Suggestion

This should be changed to .color(:red): https://github.com/tongueroo/jets/blob/master/lib/jets/cfn/ship.rb#L69

dbackeus commented 5 years ago

Fixed the error in PR #230. After running jets deploy using my fixed branch I can verify that the actual deploy error reported by AWS was:

ERROR: Template format error: Unrecognized resource types: [AWS::Lambda::LayerVersion]

Possibly LayerVersion isn't supported in the eu-north-1 region. Haven't found any official documentation on the topic but there is a forum post echoing the same issue: https://forums.aws.amazon.com/thread.jspa?messageID=892152

It would be nice if jets would validate that the current region is supported and fail early with a nice error message instead of ending up with a half broken deploy and a cryptic error.

tongueroo commented 5 years ago

RE: undefined method .red

Thanks for the fix!

RE: Possibly LayerVersion isn't supported in the eu-north-1 region.

Yup, some regions don't fully support Lambda yet. Another user also ran into this on the community forums: Unrecognized resource types: [AWS::Lambda::LayerVersion]

This AWS Region Table Matrix helps.

RE: It would be nice if jets would validate that the current region is supported and fail early with a nice error message instead of ending up with a half broken deploy and a cryptic error.

Think so too. Though hesitant to add a check and then when AWS adds support to a region, we'll have to maintain that table. Thinking docs would be a better approach. Point the user to the docs as a helpful tip. Will take PRs for this.

Anyway, thanks for the fix!

dbackeus commented 5 years ago

Had a look at the matrix. Not sure what to look for to determine LayerVersion support though? According to the matrix "Lambda" is supported in all regions. We're having a lab week at my company and I might be spending the whole week labbing with Jets so I might get time to improve your docs if I know what to look for :)

tongueroo commented 5 years ago

Yup. The AWS matrix doesn’t details on whether AWS Lambda Layers are supported for that specifically region. Sort got to brute force it to find out.

Think an FAQ item with the specific error message suffice. Can more quickly help users and point them there.