{"id":1587,"date":"2020-11-27T15:49:15","date_gmt":"2020-11-27T07:49:15","guid":{"rendered":"https:\/\/9incloud.com\/?p=1587"},"modified":"2020-11-28T16:36:08","modified_gmt":"2020-11-28T08:36:08","slug":"api-gateway-custom-domain-cloudformation-debug","status":"publish","type":"post","link":"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug","title":{"rendered":"API Gateway Custom Domain CloudFormation \u9664\u932f"},"content":{"rendered":"\n

\u5728\u73fe\u6709 API Gateway \u4e2d\u52a0\u5165\u81ea\u8a02\u7db2\u57df\u6642\uff0c\u9700\u8981\u6ce8\u610f Endpoint type\uff0c\u6709\u5206 Regional<\/em> \u3001edge-optimized<\/em>\u3001private<\/em> \u4e09\u7a2e\uff0c\u4ee5 public endpoint \u4f86\u8aaa\uff0c\u6709 Regional<\/em> \u3001edge-optimized<\/em> \u5169\u7a2e\uff0c\u5728\u52a0\u5165\u81ea\u8a02\u7db2\u57df\u6642\uff0c\u5fc5\u5b9a\u9700\u8981 SSL \u6191\u8b49 (AWS \u7a31\u70ba ACM)\uff0c\u5728\u65b0\u589e ACM \u9700\u8981\u6ce8\u610f Region \u7684\u554f\u984c<\/p>\n\n\n\n

\u5047\u8a2d\u5982\u679c API Gateway \u7684 Endpoint type \u662f Regional\uff0c CloudFormation \u7684\u8a2d\u5b9a\u5982\u4e0b<\/p>\n<\/div>\n\n\n\n

AWSTemplateFormatVersion: \"2010-09-09\"\nDescription: \"Setup API Gateway custom domain name\"\nParameters:\n  AcmArn:\n    Type: String\n  CustomDomainName:\n    Type: String\n  ApiID:\n    Type: String\n  DomainHostZoneId:\n    Type: String\nResources:\n  ApiGatewayCustomDomainName:\n    Type: \"AWS::ApiGateway::DomainName\"\n    Properties:\n      CertificateArn: !Ref AcmArn\n      DomainName: !Ref CustomDomainName\n  BasePathMapping:\n    Type: \"AWS::ApiGateway::BasePathMapping\"\n    DependsOn: ApiGatewayCustomDomainName\n    Properties:\n      DomainName: !Ref CustomDomainName\n      RestApiId: !Ref ApiID\n      Stage: dev\n  CustomDomainRecord:\n    Type: \"AWS::Route53::RecordSet\"\n    DependsOn: ApiGatewayCustomDomainName\n    Properties:\n      Name: !Ref CustomDomainName\n      Type: A\n      HostedZoneId: !Ref DomainHostZoneId\n      AliasTarget:\n        DNSName: !GetAtt ApiGatewayCustomDomainName.DistributionDomainName\n        HostedZoneId: !GetAtt ApiGatewayCustomDomainName.DistributionHostedZoneId\n<\/code><\/pre>\n\n\n\n

\u00a0<\/p>\n

CloudFormation \u932f\u8aa4\u8a0a\u606f<\/h4>\n
\n

Invalid request provided: Invalid certificate ARN: arn:aws:acm:ap-northeast-1:093611479171:certificate\/edd8180c-8575-45ca-8947-e2d432c521e4. Certificate must be in ‘us-east-1’. (Service: ApiGateway, Status Code: 400, Request ID: 15bee123-53f5-4f6a-b44e-940505c825d0, Extended Request ID: null)<\/p>\n


\n

\u00a0<\/p>\n

\u9019\u500b\u932f\u8aa4\u6700\u4e3b\u8981\u662f\u4ee5\u4e0b\u7684\u8a2d\u5b9a<\/p>\n

ApiGatewayCustomDomainName.Properties.CertificateArn\n<\/code><\/pre>\n

\u6b64\u8a2d\u5b9a\u662f\u91dd\u5c0d edge-optimized endpoint type\uff0c\u800c\u6b64 type \u53ea\u80fd\u4f7f\u7528us-east-1<\/strong><\/em> \u7684 ACM\uff0c\u56e0\u70ba\u662f\u91dd\u5c0d worldwide\uff0c\u6240\u4ee5\u6191\u8b49\u4e0a\u7684 regional \u8981\u7279\u5225\u6ce8\u610f<\/p>\n

\u53e6\u5916 CustomDomainRecord.Properties.AliasTarget.DNSName \u548c HostedZoneId \u7684\u8a2d\u5b9a\u4e5f\u8981\u6ce8\u610f\uff0cDistributionDomainName \u548c DistributionHostedZoneId \u4e5f\u662f\u91dd\u5c0d edge-optimized endpoint type<\/p>\n

\u6700\u5f8c\uff0c\u5982\u679c\u662f\u91dd\u5c0d Regional endpoint type\uff0c\u6b63\u78ba\u7684 CloudFormation \u7684\u6b63\u78ba\u8a2d\u5b9a\u5982\u4e0b<\/p>\n<\/div>\n\n\n\n

AWSTemplateFormatVersion: \"2010-09-09\"\nDescription: \"Setup API Gateway custom domain name\"\nParameters:\n  AcmArn:\n    Type: String\n  CustomDomainName:\n    Type: String\n  ApiID:\n    Type: String\n  DomainHostZoneId:\n    Type: String\nResources:\n  ApiGatewayCustomDomainName:\n    Type: \"AWS::ApiGateway::DomainName\"\n    Properties:\n      EndpointConfiguration:\n        Types:\n          - REGIONAL\n      RegionalCertificateArn: !Ref AcmArn\n      DomainName: !Ref CustomDomainName\n  BasePathMapping:\n    Type: \"AWS::ApiGateway::BasePathMapping\"\n    DependsOn: ApiGatewayCustomDomainName\n    Properties:\n      DomainName: !Ref CustomDomainName\n      RestApiId: !Ref ApiID\n      Stage: dev\n  CustomDomainRecord:\n    Type: \"AWS::Route53::RecordSet\"\n    DependsOn: ApiGatewayCustomDomainName\n    Properties:\n      Name: !Ref CustomDomainName\n      Type: A\n      HostedZoneId: !Ref DomainHostZoneId\n      AliasTarget:\n        DNSName: !GetAtt ApiGatewayCustomDomainName.RegionalDomainName\n        HostedZoneId: !GetAtt ApiGatewayCustomDomainName.RegionalHostedZoneId\n<\/code><\/pre>\n\n\n\n

\u00a0<\/p>\n

Custom Domain \u53e6\u5916\u8981\u6ce8\u610f\u7684\u5730\u65b9<\/h4>\n

API Gateway \u4e2d\u7684 Stage \u8a2d\u5b9a\u82e5\u70ba dev<\/code>\uff0c\u5247\u6574\u500b Invoke URL \u5927\u6982\u9577\u7684\u50cf\u9019\u6a23\uff0curl \u6703\u81ea\u52d5\u52a0\u5165 \/dev \u7576\u6210\u5f8c\u7db4<\/p>\n

https:\/\/xxxxxx.execute-api.ap-northeast-1.amazonaws.com\/dev\n<\/code><\/pre>\n

\u5047\u8a2d\u50b3\u5165\u7684\u5b8c\u6574\u7684 url \u662f\u9019\u6a23<\/p>\n

https:\/\/xxxxxx.execute-api.ap-northeast-1.amazonaws.com\/dev\/oauth\/token\n<\/code><\/pre>\n

Lambda \u90a3\u908a\u63a5\u5230\u7684 path \u53ea\u6709 \/oauth\/token<\/strong><\/em> \uff0c\u76f8\u5c0d\u7684\uff0c\u5982\u679c custom domain \u662f\u9019\u6a23<\/p>\n

https:\/\/example.com\/dev\/oauth\/token\n<\/code><\/pre>\n

\u90a3\u9ebc\u5728\u6e2c\u8a66\u6642\uff0c\u6703\u6c38\u9060\u5f97\u5230 404<\/strong><\/em> \uff0c\u56e0\u70ba\u50b3\u5165 Lambda \u6642\uff0cpath \u6703\u8b8a\u6210 \/dev\/oauth\/token<\/strong><\/em> \uff0c\u60f3\u7576\u7136\u723e\uff0croute \u7684\u5224\u65b7\u5c31\u6703\u932f\u8aa4<\/p>\n

\u6240\u4ee5\u5728 CloudFormation \u4e2d\u7684 BasePathMapping.Properties.BasePath \u4e0d\u8981\u8a2d\u5b9a\uff0c\u5c31\u4e0d\u6703\u6709\u9019\u500b\u554f\u984c<\/p>\n<\/div>\n\n\n\n

<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5728\u73fe\u6709 API Gateway \u4e2d\u52a0\u5165\u81ea<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[65,70],"tags":[],"yoast_head":"\nAPI Gateway Custom Domain CloudFormation \u9664\u932f - \u597d\u7aef\u7aef\u641e\u4ec0\u9ebc\u96f2\u7aef<\/title>\n<meta name=\"description\" content=\"API Gateway Custom Domain CloudFormation \u9664\u932f\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug\" \/>\n<meta property=\"og:locale\" content=\"zh_TW\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"API Gateway Custom Domain CloudFormation \u9664\u932f - \u597d\u7aef\u7aef\u641e\u4ec0\u9ebc\u96f2\u7aef\" \/>\n<meta property=\"og:description\" content=\"API Gateway Custom Domain CloudFormation \u9664\u932f\" \/>\n<meta property=\"og:url\" content=\"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug\" \/>\n<meta property=\"og:site_name\" content=\"\u597d\u7aef\u7aef\u641e\u4ec0\u9ebc\u96f2\u7aef\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-27T07:49:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-11-28T08:36:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/9incloud.com\/wp-content\/uploads\/2021\/06\/titlle2.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1728\" \/>\n\t<meta property=\"og:image:height\" content=\"1152\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Chris\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Chris\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9810\u4f30\u95b1\u8b80\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\u9418\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug#article\",\"isPartOf\":{\"@id\":\"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug\"},\"author\":{\"name\":\"Chris\",\"@id\":\"https:\/\/9incloud.com\/#\/schema\/person\/fba1134ab7c10c7e91f689b6f1d5f550\"},\"headline\":\"API Gateway Custom Domain CloudFormation \u9664\u932f\",\"datePublished\":\"2020-11-27T07:49:15+00:00\",\"dateModified\":\"2020-11-28T08:36:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug\"},\"wordCount\":120,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/9incloud.com\/#\/schema\/person\/fba1134ab7c10c7e91f689b6f1d5f550\"},\"articleSection\":[\"AWS\",\"Cloudformation\"],\"inLanguage\":\"zh-TW\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug\",\"url\":\"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug\",\"name\":\"API Gateway Custom Domain CloudFormation \u9664\u932f - \u597d\u7aef\u7aef\u641e\u4ec0\u9ebc\u96f2\u7aef\",\"isPartOf\":{\"@id\":\"https:\/\/9incloud.com\/#website\"},\"datePublished\":\"2020-11-27T07:49:15+00:00\",\"dateModified\":\"2020-11-28T08:36:08+00:00\",\"description\":\"API Gateway Custom Domain CloudFormation \u9664\u932f\",\"breadcrumb\":{\"@id\":\"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug#breadcrumb\"},\"inLanguage\":\"zh-TW\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9801\",\"item\":\"https:\/\/9incloud.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"API Gateway Custom Domain CloudFormation \u9664\u932f\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/9incloud.com\/#website\",\"url\":\"https:\/\/9incloud.com\/\",\"name\":\"\u597d\u7aef\u7aef\u641e\u4ec0\u9ebc\u96f2\u7aef\",\"description\":\"\u6709\u95dc\u96f2\u7aef\u548c\u7a0b\u5f0f\u8a2d\u8a08\u7684\u76f8\u95dc\u6587\u7ae0\",\"publisher\":{\"@id\":\"https:\/\/9incloud.com\/#\/schema\/person\/fba1134ab7c10c7e91f689b6f1d5f550\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/9incloud.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-TW\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/9incloud.com\/#\/schema\/person\/fba1134ab7c10c7e91f689b6f1d5f550\",\"name\":\"Chris\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\/\/9incloud.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ef7e8e2f5339fd481f555681a22163f5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ef7e8e2f5339fd481f555681a22163f5?s=96&d=mm&r=g\",\"caption\":\"Chris\"},\"logo\":{\"@id\":\"https:\/\/9incloud.com\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:\/\/9incloud.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"API Gateway Custom Domain CloudFormation \u9664\u932f - \u597d\u7aef\u7aef\u641e\u4ec0\u9ebc\u96f2\u7aef","description":"API Gateway Custom Domain CloudFormation \u9664\u932f","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug","og_locale":"zh_TW","og_type":"article","og_title":"API Gateway Custom Domain CloudFormation \u9664\u932f - \u597d\u7aef\u7aef\u641e\u4ec0\u9ebc\u96f2\u7aef","og_description":"API Gateway Custom Domain CloudFormation \u9664\u932f","og_url":"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug","og_site_name":"\u597d\u7aef\u7aef\u641e\u4ec0\u9ebc\u96f2\u7aef","article_published_time":"2020-11-27T07:49:15+00:00","article_modified_time":"2020-11-28T08:36:08+00:00","og_image":[{"width":1728,"height":1152,"url":"https:\/\/9incloud.com\/wp-content\/uploads\/2021\/06\/titlle2.png","type":"image\/png"}],"author":"Chris","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Chris","\u9810\u4f30\u95b1\u8b80\u6642\u9593":"1 \u5206\u9418"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug#article","isPartOf":{"@id":"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug"},"author":{"name":"Chris","@id":"https:\/\/9incloud.com\/#\/schema\/person\/fba1134ab7c10c7e91f689b6f1d5f550"},"headline":"API Gateway Custom Domain CloudFormation \u9664\u932f","datePublished":"2020-11-27T07:49:15+00:00","dateModified":"2020-11-28T08:36:08+00:00","mainEntityOfPage":{"@id":"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug"},"wordCount":120,"commentCount":0,"publisher":{"@id":"https:\/\/9incloud.com\/#\/schema\/person\/fba1134ab7c10c7e91f689b6f1d5f550"},"articleSection":["AWS","Cloudformation"],"inLanguage":"zh-TW","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug#respond"]}]},{"@type":"WebPage","@id":"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug","url":"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug","name":"API Gateway Custom Domain CloudFormation \u9664\u932f - \u597d\u7aef\u7aef\u641e\u4ec0\u9ebc\u96f2\u7aef","isPartOf":{"@id":"https:\/\/9incloud.com\/#website"},"datePublished":"2020-11-27T07:49:15+00:00","dateModified":"2020-11-28T08:36:08+00:00","description":"API Gateway Custom Domain CloudFormation \u9664\u932f","breadcrumb":{"@id":"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug#breadcrumb"},"inLanguage":"zh-TW","potentialAction":[{"@type":"ReadAction","target":["https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/9incloud.com\/aws\/cloudformation\/api-gateway-custom-domain-cloudformation-debug#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9801","item":"https:\/\/9incloud.com\/"},{"@type":"ListItem","position":2,"name":"API Gateway Custom Domain CloudFormation \u9664\u932f"}]},{"@type":"WebSite","@id":"https:\/\/9incloud.com\/#website","url":"https:\/\/9incloud.com\/","name":"\u597d\u7aef\u7aef\u641e\u4ec0\u9ebc\u96f2\u7aef","description":"\u6709\u95dc\u96f2\u7aef\u548c\u7a0b\u5f0f\u8a2d\u8a08\u7684\u76f8\u95dc\u6587\u7ae0","publisher":{"@id":"https:\/\/9incloud.com\/#\/schema\/person\/fba1134ab7c10c7e91f689b6f1d5f550"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/9incloud.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-TW"},{"@type":["Person","Organization"],"@id":"https:\/\/9incloud.com\/#\/schema\/person\/fba1134ab7c10c7e91f689b6f1d5f550","name":"Chris","image":{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/9incloud.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ef7e8e2f5339fd481f555681a22163f5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ef7e8e2f5339fd481f555681a22163f5?s=96&d=mm&r=g","caption":"Chris"},"logo":{"@id":"https:\/\/9incloud.com\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/9incloud.com"]}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/9incloud.com\/wp-json\/wp\/v2\/posts\/1587"}],"collection":[{"href":"https:\/\/9incloud.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/9incloud.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/9incloud.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/9incloud.com\/wp-json\/wp\/v2\/comments?post=1587"}],"version-history":[{"count":0,"href":"https:\/\/9incloud.com\/wp-json\/wp\/v2\/posts\/1587\/revisions"}],"wp:attachment":[{"href":"https:\/\/9incloud.com\/wp-json\/wp\/v2\/media?parent=1587"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/9incloud.com\/wp-json\/wp\/v2\/categories?post=1587"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/9incloud.com\/wp-json\/wp\/v2\/tags?post=1587"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}