AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31

Parameters:
  Stage:
    Type: String
    Default: dev
    Description: Parameter for getting the deployment stage
  Profile:
    Type: String
    Default: tidbcloud
    Description: Parameter for getting the deployment profile

Resources:
  JiraportApi:
    # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: !Join ['-', ['jiraport-api', !Ref Stage, !Ref Profile]]
      Runtime: provided.al2
      CodeUri: bin/jiraport-api
      Handler: bootstrap
      Architectures: [x86_64]
      Timeout: 30
      Policies:
      - Version: "2012-10-17"
        Statement:
        - Effect: "Allow"
          Action:
            - "lambda:InvokeFunction"
          Resource: "*"
      VpcConfig:
        SecurityGroupIds:
          - sg-0593e736eef53f746
        SubnetIds:
          - subnet-0b598c475df0fcea8
          - subnet-0da467c2d46786011
      Environment:
        Variables:
          CONFIG_PATH: ./
          LOG_LEVEL: INFO
      Events:
        ApiHandler:
          Type: HttpApi
          Properties:
            Path: '/{proxy+}'
            Method: ANY
            PayloadFormatVersion: '2.0'
  JiraportResovler:
    # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: !Join ['-', ['jiraport-resolver', !Ref Stage, !Ref Profile]]
      Runtime: provided.al2
      CodeUri: bin/jiraport-resolver
      Handler: bootstrap
      Architectures: [x86_64]
      Timeout: 60
      Policies:
      - Version: "2012-10-17"
        Statement:
        - Effect: "Allow"
          Action:
            - "lambda:InvokeFunction"
          Resource: "*"
      VpcConfig:
        SecurityGroupIds:
          - sg-0593e736eef53f746
        SubnetIds:
          - subnet-0b598c475df0fcea8
          - subnet-0da467c2d46786011
      Environment:
        Variables:
          CONFIG_PATH: ./
          LOG_LEVEL: INFO