Parameters:
  MyDomainName:
    Type: String
  MyDomainCert:
    Type: String
  HostedZoneId:
    Type: String

Globals:
  HttpApi:
    Domain:
      DomainName:
        Ref: MyDomainName
      CertificateArn:
        Ref: MyDomainCert
      EndpointConfiguration: REGIONAL
      MutualTlsAuthentication:
        TruststoreUri: ${mtlsuri}
        TruststoreVersion: 0
      SecurityPolicy: TLS_1_2
      BasePath:
      - /get
      - /post
      Route53:
        HostedZoneId:
          Ref: HostedZoneId

Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      InlineCode: |
        exports.handler = async (event) => {
          const response = {
            statusCode: 200,
            body: JSON.stringify('Hello from Lambda!'),
          };
          return response;
        };
      Handler: index.handler
      Runtime: nodejs18.x
      Events:
        ImplicitGet:
          Type: HttpApi
          Properties:
            Method: Get
            Path: /get
            ApiId:
              Ref: MyApi
        ImplicitPost:
          Type: HttpApi
          Properties:
            Method: Post
            Path: /post
            ApiId:
              Ref: MyApi
  MyApi:
    Type: AWS::Serverless::HttpApi
    Properties:
      StageName: Prod
Metadata:
  SamTransformTest: true
