Repository: aws-cloudformation/cfn-lint

Issue:
E1012 incorrectly raised when using Fn::ForEach with !FindInMap
### CloudFormation Lint Version

0.79.6

### What operating system are you using?

Amazon Linux 2023

### Describe the bug

Using `!FindInMap` within `Fn::ForEach` is throwing the error `E1012: Ref Microservice not found as a resource or parameter`. This doesn't occur on all `!FindInMap` instances.

In the example template, this occurs on the following line.
```yaml
          Conditions:
            - Field: path-pattern
              PathPatternConfig:
                Values: !FindInMap
                  - MicroserviceConfig
                  - !Ref Microservice
                  - FilterPatternConfig
```

But not these lines.
```yaml
          Port: !FindInMap
            - MicroserviceConfig
            - !Ref Microservice
            - Port
...
          HealthCheckPath: !FindInMap
            - MicroserviceConfig
            - !Ref Microservice
            - HealthCheckPath
...
          Priority: !FindInMap
            - MicroserviceConfig
            - !Ref Microservice
            - Priority
```

### Expected behavior

The template deploys as expected via CloudFormation, so I expect `cfn-lint` to be ok with this template also.

### Reproduction template

```yaml
AWSTemplateFormatVersion: "2010-09-09"

Transform: AWS::LanguageExtensions

Parameters:
  VPCID:
    Type: AWS::EC2::VPC::Id

  ApplicationLoadBalancer:
    Type: String

  ApplicationLoadBalancerListener:
    Type: String

  ApplicationLoadBalancerCertificate:
    Type: String

Mappings:
  MicroserviceConfig:
    ExmapleService:
      Priority: 1
      Port: 9000
      FilterPatternConfig:
        - /some-path*
        - /some-other-path*
      HealthCheckPath: /some-path/healthcheck

Resources:
  Fn::ForEach::Microservices:
    - Microservice
    - - ExampleService
    - ${Microservice}LoadBalancerListener:
        Type: AWS::ElasticLoadBalancingV2::Listener
        Properties:
          LoadBalancerArn: !Ref ApplicationLoadBalancer
          Protocol: HTTPS
          Port: !FindInMap
            - MicroserviceConfig
            - !Ref Microservice
            - Port
          SslPolicy: ELBSecurityPolicy-FS-1-2-Res-2020-10
          Certificates:
            - CertificateArn: !Ref ApplicationLoadBalancerCertificate
          DefaultActions:
            - Type: forward
              TargetGroupArn: !Ref
                Fn::Sub: ${Microservice}LoadBalancerTarget

      ${Microservice}LoadBalancerTarget:
        Type: AWS::ElasticLoadBalancingV2::TargetGroup
        Properties:
          VpcId: !Ref VPCID
          Protocol: HTTPS
          Port: 8443
          HealthCheckPath: !FindInMap
            - MicroserviceConfig
            - !Ref Microservice
            - HealthCheckPath
          TargetType: instance

      ${Microservice}ListenerRule:
        Type: AWS::ElasticLoadBalancingV2::ListenerRule
        Properties:
          Actions:
            - Type: forward
              ForwardConfig:
                TargetGroups:
                  - TargetGroupArn: !Ref
                      Fn::Sub: ${Microservice}LoadBalancerTarget
                    Weight: 1
          Conditions:
            - Field: path-pattern
              PathPatternConfig:
                Values: !FindInMap
                  - MicroserviceConfig
                  - !Ref Microservice
                  - FilterPatternConfig
          ListenerArn: !Ref ApplicationLoadBalancerListener
          Priority: !FindInMap
            - MicroserviceConfig
            - !Ref Microservice
            - Priority
```


Discussion:

Resolving patch:
diff --git a/src/cfnlint/template/transforms/_language_extensions.py b/src/cfnlint/template/transforms/_language_extensions.py
--- a/src/cfnlint/template/transforms/_language_extensions.py
+++ b/src/cfnlint/template/transforms/_language_extensions.py
@@ -22,7 +22,7 @@
 # initializing size of string
 _N = 7
 
-_SCALAR_TYPES = (str, int, float)
+_SCALAR_TYPES = (str, int, float, bool)
 
 
 class _ResolveError(Exception):
@@ -159,7 +159,7 @@ def _walk(self, item: Any, params: MutableMapping[str, Any], cfn: Any):
                         if map_value is None:
                             continue
                         # if we can resolve it we will return it
-                        if isinstance(map_value, _SCALAR_TYPES):
+                        if isinstance(map_value, tuple([list]) + _SCALAR_TYPES):
                             return map_value
                     except Exception as e:  # pylint: disable=broad-exception-caught
                         # We couldn't resolve the FindInMap so we are going to leave it as it is
@@ -293,7 +293,6 @@ def value(
             params = {}
         t_map = deepcopy(self._map)
         mapping = None
-
         try:
             mapping = cfn.template.get("Mappings", {}).get(
                 t_map[0].value(cfn, params, only_params)


Test patch: