需要按照以下步骤来重新设置API网关的V2 DomainName接口:
打开API网关的控制台,选择你的API。
点击左侧栏目中的'自定义域名”,然后选择'创建域名”。
在'域名名称”中输入您想要使用的域名,然后选择'API Gateway V2”为'Endpoint Type”。
在'为您的域名创建的路由”中选择您想要使用的路由,然后单击'创建”。
在API Gateway网关控制台的左侧导航栏中,选择'域名”,并单击您刚刚创建的域名。
单击'绑定”并选择要绑定到该域名的API。
在'API 阶段”中选择您要操作的阶段(默认为'prod”)。
点击'保存”。
代码示例如下:
Resources:
ApiGatewayV2DomainName:
Type: 'AWS::ApiGatewayV2::DomainName'
Properties:
DomainName: example.com
DomainNameConfigurations:
- EndpointType: REGIONAL
CertificateArn:
SecurityPolicy: TLS_1_2
Resources:
ApiGatewayV2Api:
Type: 'AWS::ApiGatewayV2::Api'
Properties:
Name: my-awesome-api
ProtocolType: HTTP
Description: My awesome API
Resources:
ApiGatewayV2Integration:
Type: 'AWS::ApiGatewayV2::Integration'
Properties:
ApiId: !Ref ApiGatewayV2Api
IntegrationType: AWS_PROXY
IntegrationUri: arn:aws:lambda:us-east-1:123456789012:function:my-function-name
上一篇:API网关:无法启用CORS
下一篇:API网络数据捕获