I migrated a Jersey API to Cloudformation (using AWS SAM) and it is working properly with amazonaws domain... accesible like https://xxxxx.execute-api.us-east-1.amazonaws.com/Stage/endpoint
Now I need to be able to access it with my own domain, like https://api.mydomain.com/endpoint
.
I configured a Certificate in Certificate Manager (api.mydomain.com) and added the CNAME record to my route53 hosted zone. Then, I just added this section to my YML file:
Api:
EndpointConfiguration: REGIONAL
Domain:
DomainName: api.mydomain.com
CertificateArn: arn:aws:acm:us-east-1:XXXXXXXX:certificate/bbbbbb-bbbb-bbbb-bbbb-bbbbbbbb
This is my YML with that section:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: AWS Serverless Jersey API - com.mydomain::mydomain
Globals:
Function:
Environment:
Variables:
•••
Api:
EndpointConfiguration: REGIONAL
Domain:
DomainName: api.mydomain.com
CertificateArn: arn:aws:acm:us-east-1:XXXXXXXX:certificate/bbbbbb-bbbb-bbbb-bbbb-bbbbbbbb
Resources:
MyServiceFunction:
Type: AWS::Serverless::Function
Properties:
Handler: com.mydomain.app.StreamLambdaHandler::handleRequest
Runtime: java8
CodeUri: .
MemorySize: 512
Policies: AWSLambdaBasicExecutionRole
Timeout: 30
Events:
ProxyResource:
Type: Api
Properties:
Path: /{proxy+}
Method: any
Policies:
•••
Outputs:
MyServiceApi:
Description: URL for application
Value: !Sub 'https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Stage/endpoint'
Export:
Name: MyServiceApi
It is just not working with my custom domain. The requested URL can't be reached. Please help :(
Ok, finally I solved the problem with these steps