首先需要准备一个Lambda function(Lambda->Functions)
还要准备一个证书,要覆盖子域名(AWS Certificate Manager->Certificates)。
1、API Gateway->Create API->REST API->Build->API endpoint type( Edge-optimized )->Create API
2、Resources->Create method->Method type(GET)->Integration type(Lambda function)->
Create method
3、Resources->/->GET(/ - GET - Method execution)->Test->结果正确否
4、Resources->Deploy API->Stage(*New Stage*)->Stage name(prod)
5、Stages->prod->/->GET->Invoke URL(https://xxxxxxxx.execute-api.us-east-1.amazonaws.com/prod/),复制地址能访问否
至此,API Gateway已创建完毕
6、CloudFront->Distributions->Create distribution->Origin domain(你的API Gateway)->Origin path - optional(/prod)-> Viewer protocol policy(HTTPS only)->Web Application Firewall (WAF)(Do not enable security protections)->Price class(Use only North America and Europe)->Alternate domain name (CNAME) - optional-> Add item(abc.yourdomain.com)->Custom SSL certificate *- optional->*Create distribution
7、CloudFront->Distributions->Domain name(xxxxxx.cloudfront.net)->复制备用
8、Route 53->Hosted zones->yourdomain.com->Create record->Record name(abc)->Record type(CNAME)->Value(复制备用的xxxxxx.cloudfront.net)->Create records
10、nslookup abc.yourdomain.com