Skip to content

feat: custom domains Api Gateway support#1144

Merged
praneetap merged 12 commits intoaws:developfrom
praneetap:custom-domains-m1
Oct 2, 2019
Merged

feat: custom domains Api Gateway support#1144
praneetap merged 12 commits intoaws:developfrom
praneetap:custom-domains-m1

Conversation

@praneetap
Copy link
Contributor

@praneetap praneetap commented Sep 17, 2019

Issue #, if available:
#1125, #1126, #1127, #783
Description of changes:
Adding basic custom domains handling to SAM. This only creates ApiGateway resources with a single basepath mapping to '/'
I found that I don't need to edit the swagger, APIGateway does this for me automatically when I create the BasePath Mappings.
Description of how you validated changes:
Tested deploying on CFN

Checklist:

  • Write/update tests
  • make pr passes
  • Update documentation
  • Verify transformed template deploys and application functions as expected
  • Add/update example to examples/2016-10-31

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@praneetap praneetap assigned praneetap and jlhood and unassigned praneetap Sep 17, 2019
@codecov-io
Copy link

codecov-io commented Sep 18, 2019

Codecov Report

Merging #1144 into develop will increase coverage by 0.11%.
The diff coverage is 96.66%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1144      +/-   ##
===========================================
+ Coverage    94.36%   94.47%   +0.11%     
===========================================
  Files           71       71              
  Lines         3621     3677      +56     
  Branches       713      726      +13     
===========================================
+ Hits          3417     3474      +57     
+ Misses         104      103       -1     
  Partials       100      100
Impacted Files Coverage Δ
samtranslator/translator/verify_logical_id.py 100% <ø> (ø) ⬆️
samtranslator/plugins/globals/globals_plugin.py 100% <ø> (ø) ⬆️
samtranslator/plugins/globals/globals.py 99.02% <ø> (ø) ⬆️
samtranslator/model/apigateway.py 97.9% <100%> (+0.11%) ⬆️
samtranslator/model/sam_resources.py 95.56% <100%> (+0.07%) ⬆️
samtranslator/model/api/api_generator.py 96.51% <95.34%> (-0.21%) ⬇️
samtranslator/plugins/api/implicit_api_plugin.py 98.59% <0%> (+2.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 91adf57...ae108d7. Read the comment docs.

jlhood
jlhood previously requested changes Sep 19, 2019
Copy link
Contributor

@jlhood jlhood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really excited to see movement on custom domain support! Lots of questions around edge case behavior. I don't think a single happycase test is sufficient here.

Also, are you planning to add an example as part of this PR?

@praneetap praneetap self-assigned this Sep 20, 2019
@praneetap praneetap requested a review from jlhood September 24, 2019 07:57
@Jacco
Copy link
Contributor

Jacco commented Sep 26, 2019

Just a note: I have a template with two AWS::Serverless::Api that share the same AWS::ApiGateway::DomainName each with a different AWS::ApiGateway::BasePathMapping.

I guess this solution does not support that?

Also found that using custom domains the AWS::ApiGateway::BasePathMapping needs a DepensOn on de Stage generated by AWS::Serverless::Api for succesful deploying

DependsOn:
  - BackofficeAPIStage

@praneetap
Copy link
Contributor Author

praneetap commented Sep 26, 2019

@Jacco thanks for the feedback!

Just a note: I have a template with two AWS::Serverless::Api that share the same AWS::ApiGateway::DomainName each with a different AWS::ApiGateway::BasePathMapping.

I guess this solution does not support that?

No unfortunately this doesn't support referencing an existing DomainName. Sounds like this would be good to have.

Also found that using custom domains the AWS::ApiGateway::BasePathMapping needs a DepensOn on de Stage generated by AWS::Serverless::Api for succesful deploying

DependsOn:
  - BackofficeAPIStage

BasePathMapping references Api.Stage (this is a referable property exposed by SAM), which creates the necessary dependency chain. The BasePathMapping resource looks like this -

MyApiBasePathMapping:
    Type: AWS::ApiGateway::BasePathMapping
    Properties:
      DomainName: !Ref APIDomainName
      RestApiId: !Ref MyApi
      BasePath: one
      Stage: !Ref MyApi.Stage ## this creates the dependency

@praneetap praneetap changed the title Custom domains m1 feat: custom domains Api Gateway support Sep 28, 2019
@praneetap praneetap assigned keetonian and unassigned jlhood and praneetap Sep 28, 2019
Copy link
Contributor

@keetonian keetonian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, looks good. This might be a silly question, but can you have multiple AWS::ApiGateway::DomainName resources that all have the same domain name + certificate but different logical Id's?

@praneetap
Copy link
Contributor Author

praneetap commented Oct 1, 2019

Overall, looks good. This might be a silly question, but can you have multiple AWS::ApiGateway::DomainName resources that all have the same domain name + certificate but different logical Id's?

No, you can only create one ApiGateway DomainName per domain "www.example.com". CloudFormation deploy fails if you try to create another ApiGateway DomainName resource for an existing domain.

@praneetap praneetap requested a review from keetonian October 1, 2019 21:16
@praneetap praneetap dismissed jlhood’s stale review October 1, 2019 21:27

Addressed requested changes

@praneetap praneetap merged commit 92d4b01 into aws:develop Oct 2, 2019
@mhausenblas mhausenblas mentioned this pull request Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants