rubyonjets / jets

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

Unable to add a custom domain to production environment #255

Closed nathanpalmer closed 5 years ago

nathanpalmer commented 5 years ago

Checklist

My Environment

Software Version
Operating System macOS 10.14.5
Jets 1.8.14
Ruby 2.5.3

Expected Behaviour

I am expecting the deploy to point to the api endpoint using a custom domain.

Current Behavior

I can deploy just fine without the custom domain, but as soon as I add the domain on the CloudFormation fails. I followed the instructions here.

It fails on BasePathMapping

09:59:24AM CREATE_FAILED AWS::CloudFormation::Stack ApiDeployment20190522095635 Embedded stack arn:aws:cloudformation:us-east-1:129282110611:stack/NathanPalmer-prod-ApiDeployment20190522095635-NVD5RA2BDEMO/b1e7f4c0-7c99-11e9-808f-0ad4d2e93658 was not successfully created: The following resource(s) failed to create: [BasePathMapping]. 

Step-by-step reproduction instructions

This is a brand new project, no customizations beyond adding a single home controller, the bulma css framework (to package.json) and then the domain customizations.

  1. jets new project
  2. yarn add bulma
  3. jets generate controller home
  4. add def index to home
  5. add basic html to index.html.erb
  6. jets deploy production (works fine)
  7. add domain name and certificate to config/environments.production.rb (see code below)
  8. jets deploy production (fails)

Code Sample

  config.domain.hosted_zone_name = "mydomain.com."
  config.domain.name = "www.mydomain.com"
  config.domain.route53 = true
  config.domain.cert_arn = "(arn)"
tongueroo commented 5 years ago

Wondering what the child CloudFormation stack error showed. Here's some info on how to find it. http://rubyonjets.com/docs/debugging/cloudformation/

nathanpalmer commented 5 years ago

If I dig into the nested CloudFormation I see these two errors

The following resource(s) failed to create: [BasePathMapping].
Failed to create resource. See the details in CloudWatch Log Stream: "2019/05/23/[$LATEST]4dc75b7fe8e342d0bf96ec99aeb14039"

Then jumping deeper into the CloudWatch logs I see this

START RequestId: d207668e-3d3e-444b-9e2f-49101471921a Version: $LATEST
event['RequestType'] Create
event:
{
    "RequestType": "Create",
    "ServiceToken": "arn:aws:lambda:us-east-1:129282110611:function:NathanPalmer-prod-jets-base-path-20190523075306",
    "ResponseURL": "https://cloudformation-custom-resource-response-useast1.s3.amazonaws.com/arn%3Aaws%3Acloudformation%3Aus-east-1%3A129282110611%3Astack/NathanPalmer-prod-ApiDeployment20190523075306-YJ0819O8QR2/9cb45e00-7d51-11e9-b109-0a1b7b252ffe%7CBasePathMapping%7Cec96a4b8-7f57-4791-a655-a25ec6a71eb5?AWSAccessKeyId=AKIA6L7Q4OWT7XTLUBXY&Expires=1558619737&Signature=Sz1P45cTMipUeYFBQh%2FbSYv9v5U%3D",
    "StackId": "arn:aws:cloudformation:us-east-1:129282110611:stack/NathanPalmer-prod-ApiDeployment20190523075306-YJ0819O8QR2/9cb45e00-7d51-11e9-b109-0a1b7b252ffe",
    "RequestId": "ec96a4b8-7f57-4791-a655-a25ec6a71eb5",
    "LogicalResourceId": "BasePathMapping",
    "ResourceType": "Custom::BasePathMapping",
    "ResourceProperties": {
        "ServiceToken": "arn:aws:lambda:us-east-1:129282110611:function:NathanPalmer-prod-jets-base-path-20190523075306"
    }
}

context: "#<LambdaContext:0x0000561e09d54620>"
context.log_stream_name "2019/05/23/[$LATEST]4dc75b7fe8e342d0bf96ec99aeb14039"
mimic: 
physical_id: PhysicalId

/var/runtime/gems/aws-sdk-core-3.47.0/lib/seahorse/client/plugins/raise_response_errors.rb:15:in `call'
/var/runtime/gems/aws-sdk-core-3.47.0/lib/aws-sdk-core/plugins/jsonvalue_converter.rb:20:in `call'
/var/runtime/gems/aws-sdk-core-3.47.0/lib/aws-sdk-core/plugins/idempotency_token.rb:17:in `call'
/var/runtime/gems/aws-sdk-core-3.47.0/lib/aws-sdk-core/plugins/param_converter.rb:24:in `call'
/var/runtime/gems/aws-sdk-core-3.47.0/lib/aws-sdk-core/plugins/response_paging.rb:10:in `call'
/var/runtime/gems/aws-sdk-core-3.47.0/lib/seahorse/client/plugins/response_target.rb:23:in `call'
/var/runtime/gems/aws-sdk-core-3.47.0/lib/seahorse/client/request.rb:70:in `send_request'
/var/runtime/gems/aws-sdk-apigateway-1.24.0/lib/aws-sdk-apigateway/client.rb:1413:in `delete_base_path_mapping'
/var/task/handlers/functions/jets/base_path.rb:105:in `delete'
/var/task/handlers/functions/jets/base_path.rb:94:in `update'
/var/task/handlers/functions/jets/base_path.rb:30:in `lambda_handler'
/var/runtime/lib/lambda_handler.rb:24:in `call_handler'
/var/runtime/lib/runtime.rb:42:in `<main>'
RESPONSE BODY:
{
    "Status": "FAILED",
    "Reason": "See the details in CloudWatch Log Stream: \"2019/05/23/[$LATEST]4dc75b7fe8e342d0bf96ec99aeb14039\"",
    "PhysicalResourceId": "PhysicalId",
    "StackId": "arn:aws:cloudformation:us-east-1:129282110611:stack/NathanPalmer-prod-ApiDeployment20190523075306-YJ0819O8QR2/9cb45e00-7d51-11e9-b109-0a1b7b252ffe",
    "RequestId": "ec96a4b8-7f57-4791-a655-a25ec6a71eb5",
    "LogicalResourceId": "BasePathMapping",
    "Data": {}
}
status code: 200
headers: {"x-amz-id-2"=>"HRbBH2QkTw4uv/yP0NNvtVzKByC/FloqnQYoi8kbKCEGPIi9h/nae37am7EEVsHcfoeSTHY1bPw=", "x-amz-request-id"=>"E9958730BCFC70E4", "date"=>"Thu, 23 May 2019 11:55:51 GMT", "etag"=>"\"8844e5c6fff8d08059623c22c9f9a50f\"", "content-length"=>"0", "server"=>"AmazonS3", "connection"=>"close"}
body: 
END RequestId: d207668e-3d3e-444b-9e2f-49101471921a
tongueroo commented 5 years ago

Cool. Thanks for the details. This is fixed in #258 Released in v1.9.1

nathanpalmer commented 5 years ago

Confirmed. 💯

I just pulled down the latest version(v1.9.2 actually) and it deployed just fine.

Thanks!