<commit_before>AWSTemplateFormatVersion: "2010-09-09"
Description: castle.prx.org application running in Docker
Mappings:
  ContainerNameMap:
    CastleApp:
      name: castle-phoenix
Parameters:
  # VPC ########################################################################
  VPC:
    Type: "AWS::EC2::VPC::Id"
  # Load Balancer ##############################################################
  PlatformALBDNSName:
    Type: String
  PlatformALBCanonicalHostedZoneID:
    Type: String
  PlatformALBHTTPListenerArn:
    Type: String
  PlatformALBHTTPSListenerArn:
    Type: String
  PlatformALBHTTPListenerPriority:
    Type: String
  PlatformALBHTTPSListenerPriority:
    Type: String
  # ECS Cluster ################################################################
  ECSCluster:
    Type: String
  ECSServiceAutoscaleIAMRoleArn:
    Type: String
  ECSServiceIAMRole:
    Type: String
  # Misc #######################################################################
  RootStackName:
    Type: String
  OpsDebugMessagesSNSTopicArn:
    Type: String
  EnvironmentTypeAbbreviation:
    Type: String
  ECRRegion:
    Type: String
  # Shared ENV #################################################################
  # Castle ECS #################################################################
  CastleECRImageTag:
    Type: String
  # Castle ENV #################################################################
  CastleEnvBasicAuthPass:
    Type: String
  CastleEnvBasicAuthUser:
    Type: String
  CastleEnvBqClientEmail:
    Type: String
  CastleEnvBqDataset:
    Type: String
  CastleEnvBqDownloadsTable:
    Type: String
  CastleEnvBqImpressionsTable:
    Type: String
  CastleEnvBqPrivateKey1:
    Type: String
  CastleEnvBqPrivateKey2:
    Type: String
  CastleEnvBqProjectId:
    Type: String
  CastleEnvRedisHost:
    Type: String
  CastleEnvRedisPoolSize:
    Type: String
  CastleEnvRedisPort:
    Type: String
Resources:
  CastleLogGroup:
    Type: "AWS::Logs::LogGroup"
    Properties:
      RetentionInDays: 14
  CastleALBTargetGroup:
    Type: "AWS::ElasticLoadBalancingV2::TargetGroup"
    Properties:
      HealthCheckIntervalSeconds: 60
      UnhealthyThresholdCount: 10
      HealthCheckPath: /
      Name: !Sub castle-${EnvironmentTypeAbbreviation}-${VPC}
      Port: 80
      Protocol: HTTP
      VpcId: !Ref VPC
  CastleALBHTTPHostListenerRule:
    Type: "AWS::ElasticLoadBalancingV2::ListenerRule"
    Properties:
      Actions:
        - TargetGroupArn: !Ref CastleALBTargetGroup
          Type: forward
      Conditions:
        - Field: host-header
          Values:
            - !Sub ${EnvironmentTypeAbbreviation}-castle.${VPC}.prx.tech
      ListenerArn: !Ref PlatformALBHTTPListenerArn
      Priority: !Ref PlatformALBHTTPListenerPriority
  CastleALBHTTPSHostListenerRule:
    Type: "AWS::ElasticLoadBalancingV2::ListenerRule"
    Properties:
      Actions:
        - TargetGroupArn: !Ref CastleALBTargetGroup
          Type: forward
      Conditions:
        - Field: host-header
          Values:
            - !Sub ${EnvironmentTypeAbbreviation}-castle.${VPC}.prx.tech
      ListenerArn: !Ref PlatformALBHTTPSListenerArn
      Priority: !Ref PlatformALBHTTPSListenerPriority
  CastleTaskDefinition:
    Type: "AWS::ECS::TaskDefinition"
    Properties:
      ContainerDefinitions:
        - Cpu: 128
          Environment:
            - Name: BASIC_AUTH_PASS
              Value: !Ref CastleEnvBasicAuthPass
            - Name: BASIC_AUTH_USER
              Value: !Ref CastleEnvBasicAuthUser
            - Name: BQ_CLIENT_EMAIL
              Value: !Ref CastleEnvBqClientEmail
            - Name: BQ_DATASET
              Value: !Ref CastleEnvBqDataset
            - Name: BQ_DOWNLOADS_TABLE
              Value: !Ref CastleEnvBqDownloadsTable
            - Name: BQ_IMPRESSIONS_TABLE
              Value: !Ref CastleEnvBqImpressionsTable
            - Name: BQ_PRIVATE_KEY
              Value: !Join ["", [!Ref "CastleEnvBqPrivateKey1", !Ref "CastleEnvBqPrivateKey2"]]
            - Name: BQ_PROJECT_ID
              Value: !Ref CastleEnvBqProjectId
            - Name: REDIS_HOST
              Value: !Ref CastleEnvRedisHost
            - Name: REDIS_POOL_SIZE
              Value: !Ref CastleEnvRedisPoolSize
            - Name: REDIS_PORT
              Value: !Ref CastleEnvRedisPort
          Essential: true
          # TODO
          Image: !Sub ${AWS::AccountId}.dkr.ecr.${ECRRegion}.amazonaws.com/castle.prx.org:${CastleECRImageTag}
          LogConfiguration:
            LogDriver: awslogs
            Options:
              awslogs-group: !Ref CastleLogGroup
              awslogs-region: !Ref AWS::Region
          Memory: 128
          Name: !FindInMap [ContainerNameMap, CastleApp, name]<commit_msg>pass in secrets env vars instead of all env vars<commit_after>AWSTemplateFormatVersion: "2010-09-09"
Description: castle.prx.org application running in Docker
Mappings:
  ContainerNameMap:
    CastleApp:
      name: castle-phoenix
Parameters:
  # VPC ########################################################################
  VPC:
    Type: "AWS::EC2::VPC::Id"
  # Load Balancer ##############################################################
  PlatformALBDNSName:
    Type: String
  PlatformALBCanonicalHostedZoneID:
    Type: String
  PlatformALBHTTPListenerArn:
    Type: String
  PlatformALBHTTPSListenerArn:
    Type: String
  PlatformALBHTTPListenerPriority:
    Type: String
  PlatformALBHTTPSListenerPriority:
    Type: String
  # ECS Cluster ################################################################
  ECSCluster:
    Type: String
  ECSServiceAutoscaleIAMRoleArn:
    Type: String
  ECSServiceIAMRole:
    Type: String
  # Misc #######################################################################
  RootStackName:
    Type: String
  OpsDebugMessagesSNSTopicArn:
    Type: String
  EnvironmentTypeAbbreviation:
    Type: String
  ECRRegion:
    Type: String
  SecretsBase:
    Type: String
  # Shared ENV #################################################################
  # Castle ECS #################################################################
  CastleECRImageTag:
    Type: String
  # Castle ENV #################################################################
  CastleSecretsVersion:
    Type: String
Resources:
  CastleLogGroup:
    Type: "AWS::Logs::LogGroup"
    Properties:
      RetentionInDays: 14
  CastleALBTargetGroup:
    Type: "AWS::ElasticLoadBalancingV2::TargetGroup"
    Properties:
      HealthCheckIntervalSeconds: 60
      UnhealthyThresholdCount: 10
      HealthCheckPath: /
      Name: !Sub castle-${EnvironmentTypeAbbreviation}-${VPC}
      Port: 80
      Protocol: HTTP
      VpcId: !Ref VPC
  CastleALBHTTPHostListenerRule:
    Type: "AWS::ElasticLoadBalancingV2::ListenerRule"
    Properties:
      Actions:
        - TargetGroupArn: !Ref CastleALBTargetGroup
          Type: forward
      Conditions:
        - Field: host-header
          Values:
            - !Sub ${EnvironmentTypeAbbreviation}-castle.${VPC}.prx.tech
      ListenerArn: !Ref PlatformALBHTTPListenerArn
      Priority: !Ref PlatformALBHTTPListenerPriority
  CastleALBHTTPSHostListenerRule:
    Type: "AWS::ElasticLoadBalancingV2::ListenerRule"
    Properties:
      Actions:
        - TargetGroupArn: !Ref CastleALBTargetGroup
          Type: forward
      Conditions:
        - Field: host-header
          Values:
            - !Sub ${EnvironmentTypeAbbreviation}-castle.${VPC}.prx.tech
      ListenerArn: !Ref PlatformALBHTTPSListenerArn
      Priority: !Ref PlatformALBHTTPSListenerPriority
  CastleTaskDefinition:
    Type: "AWS::ECS::TaskDefinition"
    Properties:
      ContainerDefinitions:
        - Cpu: 128
          Environment:
            - Name: APP_NAME
              Value: "castle"
            - Name: APP_ENV
              Value: !Ref EnvironmentTypeAbbreviation
            - Name: AWS_SECRETS_BASE
              Value: !Ref SecretsBase
            - Name: AWS_SECRETS_VERSION
              Value: !Ref CastleSecretsVersion
          Essential: true
          # TODO
          Image: !Sub ${AWS::AccountId}.dkr.ecr.${ECRRegion}.amazonaws.com/castle.prx.org:${CastleECRImageTag}
          LogConfiguration:
            LogDriver: awslogs
            Options:
              awslogs-group: !Ref CastleLogGroup
              awslogs-region: !Ref AWS::Region
          Memory: 128
          Name: !FindInMap [ContainerNameMap, CastleApp, name]
{'fraction_non_alphanumeric': 0.17578635014836796, 'fraction_numerical': 0.006646884272997033, 'mean_word_length': 3.0509615384615385, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '741808', 'n_tokens_mistral': 2443, 'n_tokens_neox': 2319, 'n_words': 471}