rubyonjets / jets

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

Jets fails to create a custom domain #385

Closed wr0ngway closed 5 years ago

wr0ngway commented 5 years ago

Checklist

My Environment

Software Version
Operating System docker ruby:2.5.7 (linux 4.9.184-linuxkit)
Jets 2.3.0
Ruby 2.5.7p206

Expected Behaviour

Jets should create a custom domain without failing

Current Behavior

I'm using jets to deploy a new project which only has a hello world controller in it. It deploys successfully until I try to add a custom domain, at which time the jets deploy process takes about 30-60 minutes before finally failing while trying to update the ApiGateway with Too Many Requests (Service: AmazonApiGateway; Status Code: 429; Error Code: TooManyRequestsException; Request ID: xxxx)

Immediately before or after, I'm able to create a custom domain (only takes a few seconds) with the same settings in the aws console, so its not hitting an account limit specifically for this unless CF is doing something funky...?

Step-by-step reproduction instructions

jets new
add something simple
jets deploy
add custom domain config
jets deploy

Code Sample

application.rb contains:

  config.domain.hosted_zone_name = "dev.mydomain.com"
  config.domain.name = "#{config.project_name}.#{domain}"
  config.domain.cert_arn = "arn:aws:acm:us-east-1:xxx:certificate/xxx"
  config.domain.route53 = false

/tmp/jets/myproj/templates/myproj-dev-api-gateway.yml contains:

  DomainName:
    Type: AWS::ApiGateway::DomainName
    Properties:
      DomainName: myproj.dev.mydomain.com
      EndpointConfiguration:
        Types:
        - REGIONAL
      RegionalCertificateArn: arn:aws:acm:us-east-1:xxx:certificate/xxx
wr0ngway commented 5 years ago

I discovered that I was missing a security group rule - I was passing in VPC security groups and subnets to get the lambda in my VPC, but had forgotten to add the egress rule for the lambda security group (from_port=0, to_port=0, protocol=-1 cidr=0.0.0.0/0) in my vpc setup (terraform external to jets). Once I put this rule in, the custom domain was created quickly without error. Hopefully this helps someone else that runs into a similar issue when trying to provision VPC lambda with a custom domain with jets.