AWS Resources - APIs
Nitric APIs are deployed to AWS using Amazon API Gateway.
AWS Resources
The following resources are created when deploying APIs to AWS:
- API Gateway v2 HTTP APIs
- API Gateway v2 Stages
- API Gateway Integration
- Lambda Functions
- ECR Images
- IAM Policies
Deployment
During deployment the Nitric CLI builds your API's routes, methods and handlers:
- Files referenced by the
services
key in thenitric.yaml
file are built into container images - Built container images are pushed to the Amazon Elastic Container Registry as private images
- Functions in AWS Lambda are created to run the container images
- All route/handler mappings are built into an Open API v3 definition file (as required by Amazon API Gateway)
- Lambda ARNs are injected into the API definition using the x-amazon-apigateway-integration object, creating an API Gateway Integration for each.
- The API definition is deployed as an API Gateway v2 HTTP API, using the
$default
stage name - IAM policies are created enabling API Gateway to execute the Lambdas
Custom Domain Prerequisites
To support custom domains with APIs deployed to AWS your domain (or subdomain) will need to be setup as a hosted zone in Route 53.
The general steps to setup a hosted zone in Route 53 are as follows:
- Navigate to Route 53 in the AWS Console
- Select 'hosted zones' from the left navigation
- Click 'Create hosted zone'
- Enter your domain name and choose the 'Public hosted zone' type.
- Click 'Create hosted zone'
- You will now be provided with a set of NS DNS records to configure in the DNS provider for your domain
- Create the required DNS records, then wait for the DNS changes to propagate
Once this is done you will be able to use the hosted zone domain or any direct subdomain with your Nitric APIs.
You can read more about how AWS suggests configuring hosted zones in their documentation on Making Route 53 the DNS service for a domain that's in use or Making Route 53 the DNS service for an inactive domain.
If the hosted zone was nitric.io, nitric.io or api.nitric.io would be supported for APIs, but not public.api.nitric.io since that is a subdomain of a subdomain.
DNS propagation of the NS records can take a few seconds to a few hours due to the nature of DNS.