Repository: aws-cloudformation/cfn-lint

Issue:
E0002 Unknown exception for rules E1010,  E1019,  E1029 on AWS::EC2::TransitGatewayPeeringAttachment
_cfn-lint version:_ (cfn-lint --version) cfn-lint 0.72.3

_Description of issue:_   The latest release of cfn-lint (`0.72.3`) fails linting on `AWS::EC2::TransitGatewayPeeringAttachment` resource that worked with version `0.72.2` and earlier.  According to the [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-transitgatewaypeeringattachment.html#cfn-ec2-transitgatewaypeeringattachment-peeraccountid), everything looks correct.


Example of the resourced defined in the template
```
  PeeringTransitGatewayAttachment:
    Type: AWS::EC2::TransitGatewayPeeringAttachment
    Properties:
      PeerAccountId: 100101010101
      PeerRegion: us-west-2
      PeerTransitGatewayId: aaa-0d57f575ea39ed5ab
      Tags:
        - Key: Name
          Value: transit-gateway-peering-attachment
      TransitGatewayId: !Ref TransitGateway
```

The following linting errors are thrown when running `cfn-lint network.yml`
```
E0002 Unknown exception while processing rule E1010: 'NoneType' object has no attribute 'get'
network.yml:1:1

E0002 Unknown exception while processing rule E1019: 'NoneType' object has no attribute 'get'
network.yml:1:1

E0002 Unknown exception while processing rule E1029: 'NoneType' object has no attribute 'get'
network.yml:1:1
```

Line 1 of template:  `AWSTemplateFormatVersion: 2010-09-09`


An example of one of the exception traces when debug (`-D`) is enabled:
```
E0002 Unknown exception while processing rule E1029: Traceback (most recent call last):
  File "C:\...\.venv\lib\site-packages\cfnlint\rules\__init__.py", line 320, in run_check
    return check(*args)
  File "C:\...\.venv\lib\site-packages\cfnlint\rules\__init__.py", line 44, in wrapper
    results = match_function(self, filename, cfn, *args, **kwargs)
  File "C:\...\.venv\lib\site-packages\cfnlint\rules\__init__.py", line 202, in matchall
    return self.match(cfn)  # pylint: disable=E1102
  File "C:\...\.venv\lib\site-packages\cfnlint\rules\functions\SubNeeded.py", line 78, in match
    getatts = cfn.get_valid_getatts()
  File "C:\...\.venv\lib\site-packages\cfnlint\template.py", line 278, in get_valid_getatts
    for item in build_output_string(
  File "C:\...\.venv\lib\site-packages\cfnlint\template.py", line 241, in build_output_string
    for k, v in prop.get("Properties", {}).items():
AttributeError: 'NoneType' object has no attribute 'get'
```




Discussion:

Resolving patch:
diff --git a/src/cfnlint/template.py b/src/cfnlint/template.py
--- a/src/cfnlint/template.py
+++ b/src/cfnlint/template.py
@@ -238,13 +238,14 @@ def build_output_string(resource_type, property_name):
             prop = propertytypes.get(f"{resource_type}.{property_name}")
             if prop is None:
                 yield None, None
-            for k, v in prop.get("Properties", {}).items():
-                t = v.get("Type")
-                if t:
-                    for item in build_output_string(resource_type, v):
-                        yield f"{k}.{item[0]}", item[1]
-                else:
-                    yield k, v.get("PrimitiveType")
+            else:
+                for k, v in prop.get("Properties", {}).items():
+                    t = v.get("Type")
+                    if t:
+                        for item in build_output_string(resource_type, v):
+                            yield f"{k}.{item[0]}", item[1]
+                    else:
+                        yield k, v.get("PrimitiveType")
 
         for name, value in resources.items():
             if "Type" in value:


Test patch: