<commit_before>AWSTemplateFormatVersion: '2010-09-09'
Description: kong service
Parameters:
  EnvironmentName:
    Type: String
    Default: production
    Description: A name for the environment that this cloudformation will be part of.
                 Used to locate other resources in the same environment.
  ServiceName:
    Type: String
    Default: kong
    Description: A name for the service
  ImageUrl:
    Type: String
    Default: nginx
    Description: The url of a docker image that contains the application process that
                 will handle the traffic for this service
  ContainerCpu:
    Type: Number
    Default: 512
    Description: How much CPU to give the container. 1024 is 1 CPU
  ContainerMemory:
    Type: Number
    Default: 1024
    Description: How much memory in megabytes to give the container
  #DBAddress:
  #  Type: String
  #  Default: rds.amazonaws.com
  #  Description: address for the Postgres DB
  DBPassword:
    Type: String
    Default: <PASSWORD>
    Description: password for the Postgres DB
    NoEcho: 'true'
    MinLength: '8'

Resources:
  # A log group for storing the container logs for this service
  LogGroup:
    Type: AWS::Logs::LogGroup
    Properties:
      LogGroupName: !Join ['-', [!Ref 'EnvironmentName', 'service', !Ref 'ServiceName']]

  # The task definition. This is a simple metadata description of what
  # container to run, and what resource requirements it has.
  TaskDefinition:
    Type: AWS::ECS::TaskDefinition
    Properties:
      Family: !Ref 'ServiceName'
      Cpu: !Ref 'ContainerCpu'
      Memory: !Ref 'ContainerMemory'
      NetworkMode: awsvpc
      RequiresCompatibilities:
        - FARGATE
      ExecutionRoleArn:
        Fn::ImportValue:
          !Join [':', [!Ref 'EnvironmentName', 'ECSTaskExecutionRole']]
      ContainerDefinitions:
        - Name: !Ref 'ServiceName'
          Cpu: !Ref 'ContainerCpu'
          Memory: !Ref 'ContainerMemory'
          Image: !Ref 'ImageUrl'
          Environment:
            - Name: REGION
              Value: !Ref 'AWS::Region'
            - Name: ENV_NAME
              Value: !Ref 'EnvironmentName'
            - Name: KONG_ADMIN_LISTEN
              Value: '0.0.0.0:8001, 0.0.0.0:8444 ssl'
            - Name: KONG_DATABASE
              Value: postgres
            - Name: KONG_PG_USER
              Value: kong
            - Name: KONG_PG_DATABASE
              Value: kong
            - Name: KONG_PLUGINS
              Value: oidc,oidc-consumer
            - Name: KONG_PG_HOST
              Value:
                Fn::ImportValue:
                    !Join [':', [!Ref 'EnvironmentName', 'DBAddress']]
            - Name: KONG_PG_PORT
              Value: 5432
            - Name: KONG_PG_PASSWORD
              Value: !Ref 'DBPassword'
          PortMappings:
            - ContainerPort: 8000
            - ContainerPort: 8001
          LogConfiguration:
            LogDriver: 'awslogs'
            Options:
              awslogs-group: !Join ['-', [!Ref 'EnvironmentName', 'service', !Ref 'ServiceName']]
              awslogs-region: !Ref 'AWS::Region'
              awslogs-stream-prefix: !Ref 'ServiceName'

  # The service. The service is a resource which allows you to run multiple
  # copies of a type of task, and gather up their logs and metrics, as well
  # as monitor the number of running tasks and replace any that have crashed
  Service:
    Type: AWS::ECS::Service
    Properties:
      ServiceName: !Ref 'ServiceName'
      Cluster:
        Fn::ImportValue:
          !Join [':', [!Ref 'EnvironmentName', 'ClusterName']]
      LaunchType: FARGATE
      DeploymentConfiguration:
        MaximumPercent: 200
        MinimumHealthyPercent: 75
      DesiredCount: 1
      NetworkConfiguration:
        AwsvpcConfiguration:
          Subnets:
            - Fn::ImportValue:
                !Join [':', [!Ref 'EnvironmentName', 'PublicSubnetOne']]
            - Fn::ImportValue:
                !Join [':', [!Ref 'EnvironmentName', 'PublicSubnetTwo']]
      TaskDefinition: !Ref 'TaskDefinition'<commit_msg>cfn.kong: try fix for pg timeout<commit_after>AWSTemplateFormatVersion: '2010-09-09'
Description: kong service
Parameters:
  EnvironmentName:
    Type: String
    Default: production
    Description: A name for the environment that this cloudformation will be part of.
                 Used to locate other resources in the same environment.
  ServiceName:
    Type: String
    Default: kong
    Description: A name for the service
  ImageUrl:
    Type: String
    Default: nginx
    Description: The url of a docker image that contains the application process that
                 will handle the traffic for this service
  ContainerCpu:
    Type: Number
    Default: 512
    Description: How much CPU to give the container. 1024 is 1 CPU
  ContainerMemory:
    Type: Number
    Default: 1024
    Description: How much memory in megabytes to give the container
  #DBAddress:
  #  Type: String
  #  Default: rds.amazonaws.com
  #  Description: address for the Postgres DB
  DBPassword:
    Type: String
    Default: <PASSWORD>
    Description: password for the Postgres DB
    NoEcho: 'true'
    MinLength: '8'

Resources:
  # A log group for storing the container logs for this service
  LogGroup:
    Type: AWS::Logs::LogGroup
    Properties:
      LogGroupName: !Join ['-', [!Ref 'EnvironmentName', 'service', !Ref 'ServiceName']]

  # The task definition. This is a simple metadata description of what
  # container to run, and what resource requirements it has.
  TaskDefinition:
    Type: AWS::ECS::TaskDefinition
    Properties:
      Family: !Ref 'ServiceName'
      Cpu: !Ref 'ContainerCpu'
      Memory: !Ref 'ContainerMemory'
      NetworkMode: awsvpc
      RequiresCompatibilities:
        - FARGATE
      ExecutionRoleArn:
        Fn::ImportValue:
          !Join [':', [!Ref 'EnvironmentName', 'ECSTaskExecutionRole']]
      ContainerDefinitions:
        - Name: !Ref 'ServiceName'
          Cpu: !Ref 'ContainerCpu'
          Memory: !Ref 'ContainerMemory'
          Image: !Ref 'ImageUrl'
          Environment:
            - Name: REGION
              Value: !Ref 'AWS::Region'
            - Name: ENV_NAME
              Value: !Ref 'EnvironmentName'
            - Name: KONG_ADMIN_LISTEN
              Value: '0.0.0.0:8001'
            - Name: KONG_DATABASE
              Value: postgres
            - Name: KONG_PG_USER
              Value: kong
            - Name: KONG_PG_DATABASE
              Value: kong
            - Name: KONG_PLUGINS
              Value: oidc,oidc-consumer
            - Name: KONG_PG_HOST
              Value:
                Fn::ImportValue:
                    !Join [':', [!Ref 'EnvironmentName', 'DBAddress']]
            - Name: KONG_PG_PORT
              Value: 5432
            - Name: KONG_PG_PASSWORD
              Value: !Ref 'DBPassword'
          PortMappings:
            - ContainerPort: 8000
            - ContainerPort: 8001
          LogConfiguration:
            LogDriver: 'awslogs'
            Options:
              awslogs-group: !Join ['-', [!Ref 'EnvironmentName', 'service', !Ref 'ServiceName']]
              awslogs-region: !Ref 'AWS::Region'
              awslogs-stream-prefix: !Ref 'ServiceName'

  # The service. The service is a resource which allows you to run multiple
  # copies of a type of task, and gather up their logs and metrics, as well
  # as monitor the number of running tasks and replace any that have crashed
  Service:
    Type: AWS::ECS::Service
    Properties:
      ServiceName: !Ref 'ServiceName'
      Cluster:
        Fn::ImportValue:
          !Join [':', [!Ref 'EnvironmentName', 'ClusterName']]
      LaunchType: FARGATE
      DeploymentConfiguration:
        MaximumPercent: 200
        MinimumHealthyPercent: 75
      DesiredCount: 1
      NetworkConfiguration:
        AwsvpcConfiguration:
          SecurityGroups:
            - Fn::ImportValue:
                !Join [':', [!Ref 'EnvironmentName', 'PublicSecurityGroup']]
          Subnets:
            - Fn::ImportValue:
                !Join [':', [!Ref 'EnvironmentName', 'PublicSubnetOne']]
            - Fn::ImportValue:
                !Join [':', [!Ref 'EnvironmentName', 'PublicSubnetTwo']]
      TaskDefinition: !Ref 'TaskDefinition'
{'fraction_non_alphanumeric': 0.08699334543254689, 'fraction_numerical': 0.012341197822141561, 'mean_word_length': 2.1513534121235227, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1340055', 'n_tokens_mistral': 2366, 'n_tokens_neox': 2261, 'n_words': 722}