AWS CloudFormation支持通过API Gateway创建REST API服务。在创建REST API时,您需要提供自定义域名,并将其与API Gateway映射,以便客户访问您的API。以下是一个示例:
Resources:
MyAPI:
Type: AWS::ApiGateway::RestApi
Properties:
Name: my-api
Description: My API
EndpointConfiguration:
Types:
- EDGE
Tags:
tag-key-1: tag-value-1
MyCustomDomain:
Type: AWS::ApiGateway::DomainName
Properties:
DomainName: example.com
CertificateArn: arn:aws:acm:us-west-2:123456789012:certificate/12345678-1234-1234-1234-123456789012
RegionalCertificateArn: arn:aws:acm:us-west-2:123456789012:certificate/12345678-5678-5678-5678-123456789012
EndpointConfiguration:
Types:
- EDGE
Tags:
tag-key-2: tag-value-2
MyBasePathMapping:
Type: AWS::ApiGateway::BasePathMapping
Properties:
RestApiId: !Ref MyAPI
DomainName: !Ref MyCustomDomain
BasePath: "foo"
在上面的示例中,首先定义了一个名为“MyAPI”的AWS::ApiGateway::RestApi资源,然后定义了一个名为“MyCustomDomain”的AWS::ApiGateway::DomainName资源。
最后,定义一个AWS::ApiGateway::BasePathMapping资源,该资源将REST API映射到域名和子路径“example.com/foo”。
您可以通过在AWS CloudFormation模板中定义这些资源来映射REST API。
上一篇:AWSCloudFormation引导程序二进制文件最新版被VirusTotal报告为不合法?
下一篇:AWSCloudFormation中Cloudwatch发生的不具体的错误信息:“指标列表中应返回正好两个元素的数据。”