Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to map httpapi to exisiting customdomain #2208

Open
rockey5520 opened this issue Feb 5, 2021 · 6 comments
Open

Unable to map httpapi to exisiting customdomain #2208

rockey5520 opened this issue Feb 5, 2021 · 6 comments

Comments

@rockey5520
Copy link

Description:

I am trying to create a httpapi and map to an exisitng custom domain

Steps to reproduce:

Sample template.yml file

Resources:
  HttpApi:
    Type: AWS::Serverless::HttpApi
    Properties:
      StageName: !Ref StageName
      Tags:
        Tag: Value
      AccessLogSettings:
        DestinationArn: !GetAtt AccessLogs.Arn
        Format: $context.requestId
      StageVariables:
        StageVar: Value
      FailOnWarnings: True
      CorsConfiguration:
        AllowOrigins:
          - "*"
        AllowHeaders:
          - origin
          - content-type
          - x-amz-date
          - authorization
          - x-api-key
          - x-amz-security-token
        AllowMethods:
          - GET
          - POST
          - OPTIONS
          - PATCH
          - DELETE
        MaxAge: 0
      Domain:
        DomainName: x.x.x
        CertificateArn: arn
        EndpointConfiguration: REGIONAL
        Route53:
          HostedZoneId: XXXXXXXXXXX
        BasePath:
          - /banks

Observed result:

The domain name you provided already exists.    
                                                                                                                                                      (Service: AmazonApiGatewayV2; Status Code: 400; 
                                                                                                                                                      Error Code: BadRequestException; Request ID:    
                                                                                                                                                      ; Proxy:    
                                                                                                                                                      null) 

Expected result:

Map created httpapi to the custom domain and under paths given as per the template section BasePath

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Ubuntu
  2. sam --version: 1.16.0
  3. AWS region: eu-west-1

Add --debug flag to command you are running

@CoshUS
Copy link
Contributor

CoshUS commented Nov 5, 2021

Hey @rockey5520,
SAM always creates a AWS::ApiGatewayV2::DomainName resource if DomainName is specified.
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-generated-resources-httpapi.html
To use existing custom domain, you can remove DomainName and use AWS::ApiGatewayV2::ApiMapping resource instead.
Closing. Let me know if there are other issues.

@CoshUS CoshUS closed this as completed Nov 5, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@rockey5520
Copy link
Author

Hey, @CoshUS I suppose your suggestion works and fits nicely for hello-world type applications. but this is not the ideal way of building mapping API to an existing domain which is already having several mappings from other API's

This approach only makes things complex by removing touching the components(API mapping, in turn downtime) during deployment. can we get this issue to be converted as a feature for sam cli?

@CoshUS
Copy link
Contributor

CoshUS commented Nov 5, 2021

@rockey5520 Sounds good. I'll transfer this to SAM repo and the feature request would be:
Add support for using existing custom domains for AWS::Serverless::HttpApi and AWS::Serverless::Api

@CoshUS CoshUS transferred this issue from aws/aws-sam-cli Nov 5, 2021
@CoshUS CoshUS reopened this Nov 5, 2021
@rockey5520
Copy link
Author

@CoshUS Thank you

@hoffa
Copy link
Contributor

hoffa commented Jan 14, 2023

Tangentially related request in #2778 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants