How do I setup Route 53 to point to Api Gateway
Solution 1:
You have to create a SSL certificate using the Certificate Manager. For an edge endpoint, create it in eu-east-1, for regional and private endpoints, create it in the region you are deploying the API gateway in (or the lambda). Read more here. I will refer to the ARN as CertificateArn
You have to configure a AWS::ApiGateway::DomainName
:
"MyDomainName": {
"Type": "AWS::ApiGateway::DomainName",
"Properties": {
"DomainName": {"Ref: "DomainName"},
"CertificateArn": "arn:aws:acm:us-east-1:111122223333:certificate/fb1b9770-a305-495d-aefb-27e5e101ff3"
}
}
This enables the Domain for the API Gateway. Next, you need to expose the API (i.e. your RestAPI), in a specific deployment stage. In your template, your have no deployment stages. Take a look a AWS::ApiGateway::Stage
. A minimal example would look like this:
"Prod": {
"Type": "AWS::ApiGateway::Stage",
"Properties": {
"StageName": "Prod",
"Description": "Prod Stage",
"RestApiId": {
"Ref": "APIGateway"
},
"DeploymentId": {
"Ref": "APITDeploymentTest"
},
}
However, you most likely want some additional configuration in that. I suggest you take a look at the MethodSettings
property.
At last, deploy a basepath mapping resource: AWS::ApiGateway::BasePathMapping
. I suggest you map the basepath to the stage you created like this:
"ProdDomainBasePath": {
"Type" : "AWS::ApiGateway::BasePathMapping",
"Properties" : {
"DomainName" : {"Ref: "DomainName"},
"RestApiId" : {"Ref": "APIGateway"},
"Stage" : "Prod"
}
}
If you change an AWS::ApiGateway::Stage
resource, you have to force an update on the corresponding AWS::ApiGateway::Deployment
resource - this usually means renaming the AWS::ApiGateway::Deployment
resource, to keep that in mind. Otherwise, it wont be deployed.
That should do it.