Parameters:
  contactLensDataS3BucketName:
    Type: String
    Description: The S3 bucket name where the Contact Lens data is stored.
  processRedactedOnly:
    Type: String
    Default: "false"
    AllowedValues:
      - "true"
      - "false"
    Description: Set to 'true' to process only redacted Contact Lens analysis files (Analysis/Voice/Redacted/). When 'false', all files under Analysis/Voice/ are processed.
  operataGroupId:
    Type: String
    Description: Operata Group ID provided by Operata
  operataAPIKey:
    Type: String
    Description: API key generated in the Operata console
    NoEcho: true
  apiEndpointUrl:
    Type: String
    Default: https://api.operata.io
    Description: Operata API endpoint URL
Resources:
  operataAPIKeySM:
    Type: AWS::SecretsManager::Secret
    Properties:
      Description: Operata API token
      Name:
        Fn::Join:
          - ""
          - - cloud-collector-v3/cld/
            - Ref: operataGroupId
            - /apiToken
      SecretString:
        Ref: operataAPIKey
    Metadata:
      aws:cdk:path: ContactLensEbStack/operataAPIKeySM
  operatacontactlensdatastream7910F04C:
    Type: AWS::Kinesis::Stream
    Properties:
      Name:
        Fn::Join:
          - ""
          - - operata-contact-lens-data-stream-
            - Ref: operataGroupId
      RetentionPeriodHours: 24
      ShardCount: 1
      StreamEncryption:
        Fn::If:
          - AwsCdkKinesisEncryptedStreamsUnsupportedRegions
          - Ref: AWS::NoValue
          - EncryptionType: KMS
            KeyId: alias/aws/kinesis
    UpdateReplacePolicy: Retain
    DeletionPolicy: Delete
    Metadata:
      aws:cdk:path: ContactLensEbStack/operata-contact-lens-data-stream/Resource
  ccv3s3kinesisintegratorServiceRole0750CE21:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Statement:
          - Action: sts:AssumeRole
            Effect: Allow
            Principal:
              Service: lambda.amazonaws.com
        Version: "2012-10-17"
      ManagedPolicyArns:
        - Fn::Join:
            - ""
            - - "arn:"
              - Ref: AWS::Partition
              - :iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
    Metadata:
      aws:cdk:path: ContactLensEbStack/ccv3-s3-kinesis-integrator/ServiceRole/Resource
  ccv3s3kinesisintegratorServiceRoleDefaultPolicy8508F0CA:
    Type: AWS::IAM::Policy
    Properties:
      PolicyDocument:
        Statement:
          - Action: s3:GetObject
            Effect: Allow
            Resource:
              Fn::Join:
                - ""
                - - "arn:aws:s3:::"
                  - Ref: contactLensDataS3BucketName
          - Action:
              - kinesis:ListShards
              - kinesis:PutRecord
              - kinesis:PutRecords
            Effect: Allow
            Resource:
              Fn::GetAtt:
                - operatacontactlensdatastream7910F04C
                - Arn
          - Action:
              - s3:GetBucket*
              - s3:GetObject*
              - s3:List*
            Effect: Allow
            Resource:
              - Fn::Join:
                  - ""
                  - - "arn:aws:s3:::"
                    - Ref: contactLensDataS3BucketName
                    - /*
              - Fn::Join:
                  - ""
                  - - "arn:aws:s3:::"
                    - Ref: contactLensDataS3BucketName
        Version: "2012-10-17"
      PolicyName: ccv3s3kinesisintegratorServiceRoleDefaultPolicy8508F0CA
      Roles:
        - Ref: ccv3s3kinesisintegratorServiceRole0750CE21
    Metadata:
      aws:cdk:path: ContactLensEbStack/ccv3-s3-kinesis-integrator/ServiceRole/DefaultPolicy/Resource
  ccv3s3kinesisintegratorF9FA8167:
    Type: AWS::Lambda::Function
    Properties:
      Code:
        S3Bucket:
          Fn::Join:
            - ""
            - - Ref: AWS::Region
              - -operata-shared-assets-prod
        S3Key: ccv3-lambdas/v1.2.6/cloud-collector-v3-contact-lens-data.zip
      Environment:
        Variables:
          TARGET_KINESIS_STREAM_NAME:
            Ref: operatacontactlensdatastream7910F04C
          LOG_LEVEL: "1"
          BUILD_VERSION: v1.2.6
      Handler: bootstrap
      Role:
        Fn::GetAtt:
          - ccv3s3kinesisintegratorServiceRole0750CE21
          - Arn
      Runtime: provided.al2023
      Timeout: 60
    DependsOn:
      - ccv3s3kinesisintegratorServiceRoleDefaultPolicy8508F0CA
      - ccv3s3kinesisintegratorServiceRole0750CE21
    Metadata:
      aws:cdk:path: ContactLensEbStack/ccv3-s3-kinesis-integrator/Resource
  contactlensdatabucketNotifications0C1A176A:
    Type: Custom::S3BucketNotifications
    Properties:
      ServiceToken:
        Fn::GetAtt:
          - BucketNotificationsHandler050a0587b7544547bf325f094a3db8347ECC3691
          - Arn
      BucketName:
        Ref: contactLensDataS3BucketName
      NotificationConfiguration:
        EventBridgeConfiguration: {}
      Managed: false
      SkipDestinationValidation: false
    Metadata:
      aws:cdk:path: ContactLensEbStack/contact-lens-data-bucket/Notifications/Resource
  BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleB6FB88EC:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Statement:
          - Action: sts:AssumeRole
            Effect: Allow
            Principal:
              Service: lambda.amazonaws.com
        Version: "2012-10-17"
      ManagedPolicyArns:
        - Fn::Join:
            - ""
            - - "arn:"
              - Ref: AWS::Partition
              - :iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
    Metadata:
      aws:cdk:path: ContactLensEbStack/BucketNotificationsHandler050a0587b7544547bf325f094a3db834/Role/Resource
  BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleDefaultPolicy2CF63D36:
    Type: AWS::IAM::Policy
    Properties:
      PolicyDocument:
        Statement:
          - Action:
              - s3:GetBucketNotification
              - s3:PutBucketNotification
            Effect: Allow
            Resource:
              Fn::Join:
                - ""
                - - "arn:aws:s3:::"
                  - Ref: contactLensDataS3BucketName
        Version: "2012-10-17"
      PolicyName: BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleDefaultPolicy2CF63D36
      Roles:
        - Ref: BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleB6FB88EC
    Metadata:
      aws:cdk:path: ContactLensEbStack/BucketNotificationsHandler050a0587b7544547bf325f094a3db834/Role/DefaultPolicy/Resource
  BucketNotificationsHandler050a0587b7544547bf325f094a3db8347ECC3691:
    Type: AWS::Lambda::Function
    Properties:
      Description: AWS CloudFormation handler for "Custom::S3BucketNotifications" resources (@aws-cdk/aws-s3)
      Code:
        ZipFile: |-
          import boto3  # type: ignore
          import json
          import logging
          import urllib.request

          s3 = boto3.client("s3")

          EVENTBRIDGE_CONFIGURATION = 'EventBridgeConfiguration'
          CONFIGURATION_TYPES = ["TopicConfigurations", "QueueConfigurations", "LambdaFunctionConfigurations"]

          def handler(event: dict, context):
            response_status = "SUCCESS"
            error_message = ""
            try:
              props = event["ResourceProperties"]
              notification_configuration = props["NotificationConfiguration"]
              managed = props.get('Managed', 'true').lower() == 'true'
              skipDestinationValidation = props.get('SkipDestinationValidation', 'false').lower() == 'true'
              stack_id = event['StackId']
              old = event.get("OldResourceProperties", {}).get("NotificationConfiguration", {})
              if managed:
                config = handle_managed(event["RequestType"], notification_configuration)
              else:
                config = handle_unmanaged(props["BucketName"], stack_id, event["RequestType"], notification_configuration, old)
              s3.put_bucket_notification_configuration(Bucket=props["BucketName"], NotificationConfiguration=config, SkipDestinationValidation=skipDestinationValidation)
            except Exception as e:
              logging.exception("Failed to put bucket notification configuration")
              response_status = "FAILED"
              error_message = f"Error: {str(e)}. "
            finally:
              submit_response(event, context, response_status, error_message)

          def handle_managed(request_type, notification_configuration):
            if request_type == 'Delete':
              return {}
            return notification_configuration

          def handle_unmanaged(bucket, stack_id, request_type, notification_configuration, old):
            def get_id(n):
              n['Id'] = ''
              sorted_notifications = sort_filter_rules(n)
              strToHash=json.dumps(sorted_notifications, sort_keys=True).replace('"Name": "prefix"', '"Name": "Prefix"').replace('"Name": "suffix"', '"Name": "Suffix"')
              return f"{stack_id}-{hash(strToHash)}"
            def with_id(n):
              n['Id'] = get_id(n)
              return n

            external_notifications = {}
            existing_notifications = s3.get_bucket_notification_configuration(Bucket=bucket)
            for t in CONFIGURATION_TYPES:
              if request_type == 'Update':
                  old_incoming_ids = [get_id(n) for n in old.get(t, [])]
                  external_notifications[t] = [n for n in existing_notifications.get(t, []) if not get_id(n) in old_incoming_ids]      
              elif request_type == 'Delete':
                  external_notifications[t] = [n for n in existing_notifications.get(t, []) if not n['Id'].startswith(f"{stack_id}-")]
              elif request_type == 'Create':
                  external_notifications[t] = [n for n in existing_notifications.get(t, [])]
            if EVENTBRIDGE_CONFIGURATION in existing_notifications:
              external_notifications[EVENTBRIDGE_CONFIGURATION] = existing_notifications[EVENTBRIDGE_CONFIGURATION]

            if request_type == 'Delete':
              return external_notifications

            notifications = {}
            for t in CONFIGURATION_TYPES:
              external = external_notifications.get(t, [])
              incoming = [with_id(n) for n in notification_configuration.get(t, [])]
              notifications[t] = external + incoming

            if EVENTBRIDGE_CONFIGURATION in notification_configuration:
              notifications[EVENTBRIDGE_CONFIGURATION] = notification_configuration[EVENTBRIDGE_CONFIGURATION]
            elif EVENTBRIDGE_CONFIGURATION in external_notifications:
              notifications[EVENTBRIDGE_CONFIGURATION] = external_notifications[EVENTBRIDGE_CONFIGURATION]

            return notifications

          def submit_response(event: dict, context, response_status: str, error_message: str):
            response_body = json.dumps(
              {
                "Status": response_status,
                "Reason": f"{error_message}See the details in CloudWatch Log Stream: {context.log_stream_name}",
                "PhysicalResourceId": event.get("PhysicalResourceId") or event["LogicalResourceId"],
                "StackId": event["StackId"],
                "RequestId": event["RequestId"],
                "LogicalResourceId": event["LogicalResourceId"],
                "NoEcho": False,
              }
            ).encode("utf-8")
            headers = {"content-type": "", "content-length": str(len(response_body))}
            try:
              req = urllib.request.Request(url=event["ResponseURL"], headers=headers, data=response_body, method="PUT")
              with urllib.request.urlopen(req) as response:
                print(response.read().decode("utf-8"))
              print("Status code: " + response.reason)
            except Exception as e:
                print("send(..) failed executing request.urlopen(..): " + str(e))

          def sort_filter_rules(json_obj):
            if not isinstance(json_obj, dict):
                return json_obj
            for key, value in json_obj.items():
                if isinstance(value, dict):
                    json_obj[key] = sort_filter_rules(value)
                elif isinstance(value, list):
                    json_obj[key] = [sort_filter_rules(item) for item in value]
            if "Filter" in json_obj and "Key" in json_obj["Filter"] and "FilterRules" in json_obj["Filter"]["Key"]:
                filter_rules = json_obj["Filter"]["Key"]["FilterRules"]
                sorted_filter_rules = sorted(filter_rules, key=lambda x: x["Name"])
                json_obj["Filter"]["Key"]["FilterRules"] = sorted_filter_rules
            return json_obj
      Handler: index.handler
      Role:
        Fn::GetAtt:
          - BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleB6FB88EC
          - Arn
      Runtime: python3.13
      Timeout: 300
    DependsOn:
      - BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleDefaultPolicy2CF63D36
      - BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleB6FB88EC
    Metadata:
      aws:cdk:path: ContactLensEbStack/BucketNotificationsHandler050a0587b7544547bf325f094a3db834/Resource
  operataS3EventBridgeRule4F01CDE3:
    Type: AWS::Events::Rule
    Properties:
      EventPattern:
        source:
          - aws.s3
        detail-type:
          - Object Created
        detail:
          bucket:
            name:
              - Ref: contactLensDataS3BucketName
          object:
            key:
              - wildcard:
                  Fn::If:
                    - processRedactedOnlyCondition
                    - Analysis/Voice/Redacted/*.json
                    - Analysis/Voice/*.json
      State: ENABLED
      Targets:
        - Arn:
            Fn::GetAtt:
              - ccv3s3kinesisintegratorF9FA8167
              - Arn
          Id: Target0
    Metadata:
      aws:cdk:path: ContactLensEbStack/operataS3EventBridgeRule/Resource
  operataS3EventBridgeRuleAllowEventRuleContactLensEbStackccv3s3kinesisintegrator5026A34173610D22:
    Type: AWS::Lambda::Permission
    Properties:
      Action: lambda:InvokeFunction
      FunctionName:
        Fn::GetAtt:
          - ccv3s3kinesisintegratorF9FA8167
          - Arn
      Principal: events.amazonaws.com
      SourceArn:
        Fn::GetAtt:
          - operataS3EventBridgeRule4F01CDE3
          - Arn
    Metadata:
      aws:cdk:path: ContactLensEbStack/operataS3EventBridgeRule/AllowEventRuleContactLensEbStackccv3s3kinesisintegrator5026A341
  operataConnection322BC7D8:
    Type: AWS::Events::Connection
    Properties:
      AuthParameters:
        ApiKeyAuthParameters:
          ApiKeyName: Operata-API-Key
          ApiKeyValue:
            Ref: operataAPIKey
        InvocationHttpParameters:
          HeaderParameters:
            - IsValueSecret: false
              Key: Operata-Group-Id
              Value:
                Ref: operataGroupId
      AuthorizationType: API_KEY
      Description:
        Fn::Join:
          - ""
          - - "EventBridge APIConnection for transmitting Contact Lens Data to Operata [group ID: "
            - Ref: operataGroupId
            - "]"
      Name:
        Fn::Join:
          - ""
          - - operataAPIConnection-Group-
            - Ref: operataGroupId
    Metadata:
      aws:cdk:path: ContactLensEbStack/operataConnection/Connection
  operataApiDestinationFE63AEAB:
    Type: AWS::Events::ApiDestination
    Properties:
      ConnectionArn:
        Fn::GetAtt:
          - operataConnection322BC7D8
          - Arn
      Description:
        Fn::Join:
          - ""
          - - "EventBridge APIDestination for sending Contact Lens Data to Operata [group ID: "
            - Ref: operataGroupId
            - "]"
      HttpMethod: POST
      InvocationEndpoint:
        Fn::Join:
          - ""
          - - Ref: apiEndpointUrl
            - /v1/raw/*
      Name:
        Fn::Join:
          - ""
          - - operataEndpoint-Group-
            - Ref: operataGroupId
    DependsOn:
      - operataConnection322BC7D8
    Metadata:
      aws:cdk:path: ContactLensEbStack/operataApiDestination/ApiDestination
  operataApiDestinationEventsRole4FD22EDD:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Statement:
          - Action: sts:AssumeRole
            Effect: Allow
            Principal:
              Service: events.amazonaws.com
        Version: "2012-10-17"
    DependsOn:
      - operataConnection322BC7D8
    Metadata:
      aws:cdk:path: ContactLensEbStack/operataApiDestination/EventsRole/Resource
  operataApiDestinationEventsRoleDefaultPolicy52D28D35:
    Type: AWS::IAM::Policy
    Properties:
      PolicyDocument:
        Statement:
          - Action: events:InvokeApiDestination
            Effect: Allow
            Resource:
              Fn::GetAtt:
                - operataApiDestinationFE63AEAB
                - Arn
        Version: "2012-10-17"
      PolicyName: operataApiDestinationEventsRoleDefaultPolicy52D28D35
      Roles:
        - Ref: operataApiDestinationEventsRole4FD22EDD
    DependsOn:
      - operataConnection322BC7D8
    Metadata:
      aws:cdk:path: ContactLensEbStack/operataApiDestination/EventsRole/DefaultPolicy/Resource
  operataEventBridgePipeRole3EA09E25:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Statement:
          - Action: sts:AssumeRole
            Effect: Allow
            Principal:
              Service: pipes.amazonaws.com
        Version: "2012-10-17"
      Description: Operata Event Bridge Pipes Role
    Metadata:
      aws:cdk:path: ContactLensEbStack/operataEventBridgePipeRole/Resource
  operataEventBridgePipeRoleDefaultPolicyDD50B370:
    Type: AWS::IAM::Policy
    Properties:
      PolicyDocument:
        Statement:
          - Action:
              - logs:CreateLogStream
              - logs:PutLogEvents
            Effect: Allow
            Resource:
              Fn::GetAtt:
                - eventBridgePipeLogGroupF7A55BD8
                - Arn
        Version: "2012-10-17"
      PolicyName: operataEventBridgePipeRoleDefaultPolicyDD50B370
      Roles:
        - Ref: operataEventBridgePipeRole3EA09E25
    Metadata:
      aws:cdk:path: ContactLensEbStack/operataEventBridgePipeRole/DefaultPolicy/Resource
  operataEventBridgeKinesisPipeSourcePolicy754E6190:
    Type: AWS::IAM::Policy
    Properties:
      PolicyDocument:
        Statement:
          - Action:
              - kinesis:DescribeStream
              - kinesis:DescribeStreamSummary
              - kinesis:GetRecords
              - kinesis:GetShardIterator
              - kinesis:ListShards
              - kinesis:ListStreams
            Effect: Allow
            Resource:
              Fn::GetAtt:
                - operatacontactlensdatastream7910F04C
                - Arn
        Version: "2012-10-17"
      PolicyName:
        Fn::Join:
          - ""
          - - KinesisPipeSourcePolicy-Operata-GroupId-
            - Ref: operataGroupId
      Roles:
        - Ref: operataEventBridgePipeRole3EA09E25
    Metadata:
      aws:cdk:path: ContactLensEbStack/operataEventBridgeKinesisPipeSourcePolicy/Resource
  operataEventBridgePipeAPIDestinationPolicy6F5D8899:
    Type: AWS::IAM::Policy
    Properties:
      PolicyDocument:
        Statement:
          - Action: events:InvokeApiDestination
            Effect: Allow
            Resource:
              Fn::GetAtt:
                - operataApiDestinationFE63AEAB
                - Arn
        Version: "2012-10-17"
      PolicyName:
        Fn::Join:
          - ""
          - - APIDestinationPolicy-Operata-GroupId-
            - Ref: operataGroupId
      Roles:
        - Ref: operataEventBridgePipeRole3EA09E25
    Metadata:
      aws:cdk:path: ContactLensEbStack/operataEventBridgePipeAPIDestinationPolicy/Resource
  eventBridgePipeLogGroupF7A55BD8:
    Type: AWS::Logs::LogGroup
    Properties:
      LogGroupName:
        Fn::Join:
          - ""
          - - /aws/pipes/operataCLensPipe-Group-
            - Ref: operataGroupId
      RetentionInDays: 7
    UpdateReplacePolicy: Delete
    DeletionPolicy: Delete
    Metadata:
      aws:cdk:path: ContactLensEbStack/eventBridgePipeLogGroup/Resource
  operataPipe:
    Type: AWS::Pipes::Pipe
    Properties:
      Description:
        Fn::Join:
          - ""
          - - "Pipe for sending Contact Lens Data to Operata [group ID: "
            - Ref: operataGroupId
            - "] | Source Kinesis ARN ["
            - Fn::GetAtt:
                - operatacontactlensdatastream7910F04C
                - Arn
            - "] | Target APIDestination ARN ["
            - Fn::GetAtt:
                - operataApiDestinationFE63AEAB
                - Arn
            - "]"
      DesiredState: RUNNING
      LogConfiguration:
        CloudwatchLogsLogDestination:
          LogGroupArn:
            Fn::GetAtt:
              - eventBridgePipeLogGroupF7A55BD8
              - Arn
        IncludeExecutionData:
          - ALL
        Level: ERROR
      Name:
        Fn::Join:
          - ""
          - - operataCLensPipe-Group-
            - Ref: operataGroupId
      RoleArn:
        Fn::GetAtt:
          - operataEventBridgePipeRole3EA09E25
          - Arn
      Source:
        Fn::GetAtt:
          - operatacontactlensdatastream7910F04C
          - Arn
      SourceParameters:
        KinesisStreamParameters:
          BatchSize: 1
          MaximumRecordAgeInSeconds: -1
          MaximumRetryAttempts: -1
          StartingPosition: LATEST
      Target:
        Fn::GetAtt:
          - operataApiDestinationFE63AEAB
          - Arn
      TargetParameters:
        HttpParameters:
          PathParameterValues:
            - cloudContactLensSummary
        InputTemplate: |-
          {
            "AccountId": <$.data.AccountId>,
            "Categories": <$.data.Categories>,
            "Channel": <$.data.Channel>,
            "ContentMetadata": <$.data.ContentMetadata>,
            "ConversationCharacteristics": <$.data.ConversationCharacteristics>,
            "CustomerMetadata": <$.data.CustomerMetadata>,
            "CustomModels": <$.data.CustomModels>,
            "JobStatus": <$.data.JobStatus>,
            "LanguageCode": <$.data.LanguageCode>,
            "Participants": <$.data.Participants>,
            "Version": <$.data.Version>
          }
    DependsOn:
      - eventBridgePipeLogGroupF7A55BD8
    Metadata:
      aws:cdk:path: ContactLensEbStack/operataPipe
  operataContactLensEventBridgeRule29ED9827:
    Type: AWS::Events::Rule
    Properties:
      EventPattern:
        source:
          - aws.connect
        detail-type:
          - Contact Lens Realtime Rules Matched
          - Contact Lens Post Call Rules Matched
        detail:
          actionName:
            - prefix: operata_
      State: ENABLED
      Targets:
        - Arn:
            Fn::GetAtt:
              - operataApiDestinationFE63AEAB
              - Arn
          HttpParameters:
            PathParameterValues:
              - cloudContactLensEvent
          Id: Target0
          RoleArn:
            Fn::GetAtt:
              - operataApiDestinationEventsRole4FD22EDD
              - Arn
    Metadata:
      aws:cdk:path: ContactLensEbStack/operataContactLensEventBridgeRule/Resource
  CDKMetadata:
    Type: AWS::CDK::Metadata
    Properties:
      Analytics: v2:deflate64:H4sIAAAAAAAA/1VQXU/DMAz8LbyngZVJPDPQeEGi6n4A8lJTec1HFSdDqMp/J8lWNJ7u7DtfYrey3W7kwx18c6OGqdF0lMshgJrEy5ftwIPBgF5k/XNhVB4DG7AwopfZcKgdMZFFJi6THsGU0QtLgh/lLqoJww4YhQZzHEAu+2hVIGeL85Z36A0x5yoJAiOX3mksQsXOaVI/1VdZEnhGG/K7fbzaKjpr8S/ypnqe6RU5kIVV/N9JQrsxp7278c27OBfHypOYaUYuS3eZpGv0QGtUj+yiV/UbHzHMMSRh3YDyxPfndis3T/nMJyZqfLSBDMr+gr+TRBrZgwEAAA==
    Metadata:
      aws:cdk:path: ContactLensEbStack/CDKMetadata/Default
    Condition: CDKMetadataAvailable
Conditions:
  AwsCdkKinesisEncryptedStreamsUnsupportedRegions:
    Fn::Or:
      - Fn::Equals:
          - Ref: AWS::Region
          - cn-north-1
      - Fn::Equals:
          - Ref: AWS::Region
          - cn-northwest-1
  processRedactedOnlyCondition:
    Fn::Equals:
      - Ref: processRedactedOnly
      - "true"
  CDKMetadataAvailable:
    Fn::Or:
      - Fn::Or:
          - Fn::Equals:
              - Ref: AWS::Region
              - af-south-1
          - Fn::Equals:
              - Ref: AWS::Region
              - ap-east-1
          - Fn::Equals:
              - Ref: AWS::Region
              - ap-northeast-1
          - Fn::Equals:
              - Ref: AWS::Region
              - ap-northeast-2
          - Fn::Equals:
              - Ref: AWS::Region
              - ap-northeast-3
          - Fn::Equals:
              - Ref: AWS::Region
              - ap-south-1
          - Fn::Equals:
              - Ref: AWS::Region
              - ap-south-2
          - Fn::Equals:
              - Ref: AWS::Region
              - ap-southeast-1
          - Fn::Equals:
              - Ref: AWS::Region
              - ap-southeast-2
          - Fn::Equals:
              - Ref: AWS::Region
              - ap-southeast-3
      - Fn::Or:
          - Fn::Equals:
              - Ref: AWS::Region
              - ap-southeast-4
          - Fn::Equals:
              - Ref: AWS::Region
              - ca-central-1
          - Fn::Equals:
              - Ref: AWS::Region
              - ca-west-1
          - Fn::Equals:
              - Ref: AWS::Region
              - cn-north-1
          - Fn::Equals:
              - Ref: AWS::Region
              - cn-northwest-1
          - Fn::Equals:
              - Ref: AWS::Region
              - eu-central-1
          - Fn::Equals:
              - Ref: AWS::Region
              - eu-central-2
          - Fn::Equals:
              - Ref: AWS::Region
              - eu-north-1
          - Fn::Equals:
              - Ref: AWS::Region
              - eu-south-1
          - Fn::Equals:
              - Ref: AWS::Region
              - eu-south-2
      - Fn::Or:
          - Fn::Equals:
              - Ref: AWS::Region
              - eu-west-1
          - Fn::Equals:
              - Ref: AWS::Region
              - eu-west-2
          - Fn::Equals:
              - Ref: AWS::Region
              - eu-west-3
          - Fn::Equals:
              - Ref: AWS::Region
              - il-central-1
          - Fn::Equals:
              - Ref: AWS::Region
              - me-central-1
          - Fn::Equals:
              - Ref: AWS::Region
              - me-south-1
          - Fn::Equals:
              - Ref: AWS::Region
              - sa-east-1
          - Fn::Equals:
              - Ref: AWS::Region
              - us-east-1
          - Fn::Equals:
              - Ref: AWS::Region
              - us-east-2
          - Fn::Equals:
              - Ref: AWS::Region
              - us-west-1
      - Fn::Equals:
          - Ref: AWS::Region
          - us-west-2
Outputs:
  contactLensPipeStateOutput:
    Description: The current state of the Contact Lens EventBridge pipe
    Value:
      Fn::GetAtt:
        - operataPipe
        - CurrentState
  secretsManagerSecretARNOutput:
    Description: The Operata API key is stored in AWS Secrets Manager with the following ARN. To change the key create a change set in CloudFormation and update the API Key parameter using the existing template.
    Value:
      Fn::GetAtt:
        - operataConnection322BC7D8
        - SecretArn
  operataGroupIdOutput:
    Description: Contact Lens data is being sent to the following Operata Group ID
    Value:
      Ref: operataGroupId
  contactLensSummaryDataKinesisStream:
    Description: The Kinesis stream where the Contact Lens summary data is being populated from the source S3 bucket
    Value:
      Fn::GetAtt:
        - operatacontactlensdatastream7910F04C
        - Arn
  eventBridgeRule:
    Description: "The EventBridge Rule created to capture and send Contact Lens Events to Operata "
    Value:
      Fn::GetAtt:
        - operataContactLensEventBridgeRule29ED9827
        - Arn
  buildVersionOutput:
    Description: Build version of this template
    Value: v1.2.6

