Globals:
  Api:
    Cors: {Fn::Join: [',', [www.amazon.com, www.google.com]]}

Resources:
  ImplicitApiFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: s3://sam-demo-bucket/member_portal.zip
      Handler: index.gethtml
      Runtime: nodejs12.x
      Events:
        GetHtml:
          Type: Api
          Properties:
            Path: /
            Method: get
        AnyApi:
          Type: Api
          Properties:
            Path: /foo
            Method: any
  RestApiFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: s3://sam-demo-bucket/member_portal.zip
      Handler: index.handler
      Runtime: nodejs12.x
  GetHtmlFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: s3://sam-demo-bucket/member_portal.zip
      Handler: index.handler
      Runtime: nodejs12.x
  ExplicitApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: Prod
      DefinitionBody: {info: {version: '1.0', title: {Ref: AWS::StackName}}, paths: {
          /add: {post: {x-amazon-apigateway-integration: {httpMethod: POST, type: aws_proxy,
                uri: {Fn::Sub: 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${RestApiFunction.Arn}/invocations'}},
              responses: {}}}, '/{proxy+}': {x-amazon-apigateway-any-method: {x-amazon-apigateway-integration: {
                httpMethod: POST, type: aws_proxy, uri: {Fn::Sub: 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetHtmlFunction.Arn}/invocations'}},
              responses: {}}}}, swagger: '2.0'}
      Cors:
        AllowMethods: methods
        AllowHeaders: headers
        AllowOrigin: origins
        AllowCredentials: true