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好友助力码,攻略教程(有挂透视);实战中需综合...
查到实测!hhpoker一直输... 1、查到实测!hhpoker一直输有挂吗,约局吧德州真的存在透视吗,2025新版教程(有挂神器)2、...
一秒答解!wepoker辅助器... 一秒答解!wepoker辅助器如何使用,hhpoker有后台操控吗,教你教程(有挂辅助)是一款可以让...
今日头条!wepoker怎么挂... 今日头条!wepoker怎么挂飞机,竞技联盟辅助,普及教程(有挂技巧);亲真的是有正版授权,小编(透...
玩家必备科普!wejoker内... 玩家必备科普!wejoker内置辅助,wepoker透视最简单三个步骤,攻略教程(有挂教程);支持2...
总算了解!德扑圈透视,德普之星... 总算了解!德扑圈透视,德普之星透视辅助软件激活码,揭秘教程(有挂攻略);支持2-10人实时对战,虚拟...
盘点几款!德州圈脚本,hhpo... 盘点几款!德州圈脚本,hhpoker德州机器人,详细教程(有挂透明)关于hhpoker德州机器人机制...
今日焦点!hhpoker有没有... 今日焦点!hhpoker有没有作弊挂,pokerworld破解版下载,玩家教你(有挂方法)是由北京得...
揭秘!wpk透视插件,德普之星... 揭秘!wpk透视插件,德普之星透视辅助,2025新版技巧(有挂透明);玩家必备必赢加哟《136704...
玩家必备攻略!hhpoker辅... 玩家必备攻略!hhpoker辅助器视频,wpk插件辅助,wepoke教程(有挂攻略)科技教程也叫必备...