AWSSAM如何将两个域名映射到单个函数?
创始人
2024-09-27 03:00:52
0

可以使用AWS SAM的API Gateway来实现将两个域名映射到同一个函数的目的。在API Gateway上创建一个REST API,并添加两个域名作为API的自定义域名。然后在API Gateway上创建Lambda集成,将其关联到相应的Lambda函数。

以下是一个示例AWS SAM模板,它使用API Gateway将两个域名映射到同一个Lambda函数:

AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Resources:
  ApiGatewayApi:
    Type: 'AWS::Serverless::Api'
    Properties:
      StageName: Prod
      DefinitionBody:
        swagger: '2.0'
        info:
          version: '1.0.0'
          title: My API
        schemes:
          - https
        paths:
          /myresource:
            get:
              x-amazon-apigateway-integration:
                type: aws
                uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${LambdaFunction.Arn}/invocations
                httpMethod: POST
                credentials: !GetAtt ApiGatewayRole.Arn
                responses: {}
              produces:
                - application/json
              500:
                description: 'Server Error'
  ApiGatewayDeployment:
    Type: 'AWS::Serverless::Api'
    DependsOn: ApiGatewayApi
    Properties:
      StageName: Prod
  ApiGatewayDomainName1:
    Type: 'AWS::ApiGateway::DomainName'
    Properties:
      DomainName: 'example.com'
      CertificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
  ApiGatewayDomainName2:
    Type: 'AWS::ApiGateway::DomainName'
    Properties:
      DomainName: 'sub.example.com'
      CertificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'

相关内容

热门资讯

透视机巧!wepoker透视方... 透视机巧!wepoker透视方法(WPK方法)原来真的是有辅助教程(哔哩哔哩)1、金币登录送、破产送...
透视法门!wejoker辅助器... 透视法门!wejoker辅助器怎么卖(HHpoker内部)切实真的有辅助软件(哔哩哔哩)一、wejo...
透视烘培!aa poker辅助... 透视烘培!aa poker辅助,AApoker透视软件总是有工具,八分钟教程(有挂存在)aa pok...
透视总结!wpk辅助哪里买,w... 透视总结!wpk辅助哪里买,wpk控制牌是真的吗(透视)果然有技巧(哔哩哔哩)1、下载好透视辅助下载...
透视策略!德普之星辅助软件,德... 透视策略!德普之星辅助软件,德普之星工具切实存在有插件,第2分钟教程(有挂教学)德普之星辅助软件能透...
一直以来!aapoker透视插... 一直以来!aapoker透视插件,微信小程序微乐破解器2024,揭幕透视(新版有挂)-哔哩哔哩1、首...
透视好友!pokemmo手机脚... 透视好友!pokemmo手机脚本辅助器,微乐贵阳足鸡麻将开挂,科普透视(今日头条)-哔哩哔哩poke...
透视积累!德普之星透视辅助软件... 透视积累!德普之星透视辅助软件下载,德普之星私人局总是是有透视,第3分钟教程(确实有挂)1、玩家可以...
透视手段!wpk辅助哪里买,W... 透视手段!wpk辅助哪里买,WPK有透视一直真的是有工具,7分钟教程(有挂透视)1、玩家可以在wpk...
这一现象值得深思!xpoker... 这一现象值得深思!xpoker辅助器,微乐自建房辅助软件功能,总结脚本(有挂解惑)-哔哩哔哩xpok...