prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  E2502 is mistaken about IamInstanceProfile
  *cfn-lint version: 0.4.2*
  
  *Description of issue.*
  
  Linting a template returned:
  ```
  E2502 Property IamInstanceProfile shouldn't be an ARN for Resources/BuildkiteSpotfleet/Properties/SpotFleetRequestConfigData/LaunchSpecifications/0/IamInstanceProfile/Arn/Fn::GetAtt
  ```
  
  However that property can be an ARN according to https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-spotfleet-spotfleetrequestconfigdata-launchspecifications.html#cfn-ec2-spotfleet-spotfleetrequestconfigdata-launchspecifications-iaminstanceprofile
  
  It can be an `{"Arn": "profile_arn"}` structure.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/cfnlint/rules/resources/iam/InstanceProfile.py`
  Content:
  ```
  1 """
  2   Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3 
  4   Permission is hereby granted, free of charge, to any person obtaining a copy of this
  5   software and associated documentation files (the "Software"), to deal in the Software
  6   without restriction, including without limitation the rights to use, copy, modify,
  7   merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
  8   permit persons to whom the Software is furnished to do so.
  9 
  10   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  11   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  12   PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  13   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  14   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  15   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16 """
  17 from cfnlint import CloudFormationLintRule
  18 from cfnlint import RuleMatch
  19 
  20 
  21 class InstanceProfile(CloudFormationLintRule):
  22     """Check if IamInstanceProfile are used"""
  23     id = 'E2502'
  24     shortdesc = 'Check if IamInstanceProfile are using the name and not ARN'
  25     description = 'See if there are any properties IamInstanceProfile' + \
  26                   'are using name and not ARN'
  27     source_url = 'https://github.com/awslabs/cfn-python-lint'
  28     tags = ['properties']
  29 
  30     def match(self, cfn):
  31         """Check CloudFormation IamInstanceProfile Parameters"""
  32 
  33         matches = list()
  34 
  35         # Build the list of keys
  36         trees = cfn.search_deep_keys('Fn::GetAtt')
  37         # Filter only resoureces
  38         # Disable pylint for Pylint 2
  39         # pylint: disable=W0110
  40         trees = filter(lambda x: x[0] == 'Resources', trees)
  41         for tree in trees:
  42             if any(e == 'IamInstanceProfile' for e in tree):
  43                 obj = tree[-1]
  44                 objtype = cfn.template.get('Resources', {}).get(obj[0], {}).get('Type')
  45                 if objtype:
  46                     if objtype != 'AWS::IAM::InstanceProfile':
  47                         message = 'Property IamInstanceProfile should relate to AWS::IAM::InstanceProfile for %s' % (
  48                             '/'.join(map(str, tree[:-1])))
  49                         matches.append(RuleMatch(tree[:-1], message))
  50                     else:
  51                         if obj[1] == 'Arn':
  52                             message = 'Property IamInstanceProfile shouldn\'t be an ARN for %s' % (
  53                                 '/'.join(map(str, tree[:-1])))
  54                             matches.append(RuleMatch(tree[:-1], message))
  55 
  56         # Search Refs
  57         trees = cfn.search_deep_keys('Ref')
  58         # Filter only resoureces
  59         trees = filter(lambda x: x[0] == 'Resources', trees)
  60         for tree in trees:
  61             if any(e == 'IamInstanceProfile' for e in tree):
  62                 obj = tree[-1]
  63                 objtype = cfn.template.get('Resources', {}).get(obj, {}).get('Type')
  64                 if objtype:
  65                     if objtype != 'AWS::IAM::InstanceProfile':
  66                         message = 'Property IamInstanceProfile should relate to AWS::IAM::InstanceProfile for %s' % (
  67                             '/'.join(map(str, tree[:-1])))
  68                         matches.append(RuleMatch(tree[:-1], message))
  69 
  70         return matches
  71
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/cfnlint/rules/resources/iam/InstanceProfile.py b/src/cfnlint/rules/resources/iam/InstanceProfile.py
  --- a/src/cfnlint/rules/resources/iam/InstanceProfile.py
  +++ b/src/cfnlint/rules/resources/iam/InstanceProfile.py
  @@ -48,10 +48,16 @@
                               '/'.join(map(str, tree[:-1])))
                           matches.append(RuleMatch(tree[:-1], message))
                       else:
  -                        if obj[1] == 'Arn':
  -                            message = 'Property IamInstanceProfile shouldn\'t be an ARN for %s' % (
  -                                '/'.join(map(str, tree[:-1])))
  -                            matches.append(RuleMatch(tree[:-1], message))
  +                        if cfn.template.get('Resources', {}).get(tree[1], {}).get('Type') in ['AWS::EC2::SpotFleet']:
  +                            if obj[1] != 'Arn':
  +                                message = 'Property IamInstanceProfile should be an ARN for %s' % (
  +                                    '/'.join(map(str, tree[:-1])))
  +                                matches.append(RuleMatch(tree[:-1], message))
  +                        else:
  +                            if obj[1] == 'Arn':
  +                                message = 'Property IamInstanceProfile shouldn\'t be an ARN for %s' % (
  +                                    '/'.join(map(str, tree[:-1])))
  +                                matches.append(RuleMatch(tree[:-1], message))
   
           # Search Refs
           trees = cfn.search_deep_keys('Ref')
  
verification_info: {"golden_diff": "diff --git a/src/cfnlint/rules/resources/iam/InstanceProfile.py b/src/cfnlint/rules/resources/iam/InstanceProfile.py\n--- a/src/cfnlint/rules/resources/iam/InstanceProfile.py\n+++ b/src/cfnlint/rules/resources/iam/InstanceProfile.py\n@@ -48,10 +48,16 @@\n                             '/'.join(map(str, tree[:-1])))\n                         matches.append(RuleMatch(tree[:-1], message))\n                     else:\n-                        if obj[1] == 'Arn':\n-                            message = 'Property IamInstanceProfile shouldn\\'t be an ARN for %s' % (\n-                                '/'.join(map(str, tree[:-1])))\n-                            matches.append(RuleMatch(tree[:-1], message))\n+                        if cfn.template.get('Resources', {}).get(tree[1], {}).get('Type') in ['AWS::EC2::SpotFleet']:\n+                            if obj[1] != 'Arn':\n+                                message = 'Property IamInstanceProfile should be an ARN for %s' % (\n+                                    '/'.join(map(str, tree[:-1])))\n+                                matches.append(RuleMatch(tree[:-1], message))\n+                        else:\n+                            if obj[1] == 'Arn':\n+                                message = 'Property IamInstanceProfile shouldn\\'t be an ARN for %s' % (\n+                                    '/'.join(map(str, tree[:-1])))\n+                                matches.append(RuleMatch(tree[:-1], message))\n \n         # Search Refs\n         trees = cfn.search_deep_keys('Ref')\n", "issue": "E2502 is mistaken about IamInstanceProfile\n*cfn-lint version: 0.4.2*\r\n\r\n*Description of issue.*\r\n\r\nLinting a template returned:\r\n```\r\nE2502 Property IamInstanceProfile shouldn't be an ARN for Resources/BuildkiteSpotfleet/Properties/SpotFleetRequestConfigData/LaunchSpecifications/0/IamInstanceProfile/Arn/Fn::GetAtt\r\n```\r\n\r\nHowever that property can be an ARN according to https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-spotfleet-spotfleetrequestconfigdata-launchspecifications.html#cfn-ec2-spotfleet-spotfleetrequestconfigdata-launchspecifications-iaminstanceprofile\r\n\r\nIt can be an `{\"Arn\": \"profile_arn\"}` structure.\n", "before_files": [{"content": "\"\"\"\n  Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this\n  software and associated documentation files (the \"Software\"), to deal in the Software\n  without restriction, including without limitation the rights to use, copy, modify,\n  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n  permit persons to whom the Software is furnished to do so.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\"\"\"\nfrom cfnlint import CloudFormationLintRule\nfrom cfnlint import RuleMatch\n\n\nclass InstanceProfile(CloudFormationLintRule):\n    \"\"\"Check if IamInstanceProfile are used\"\"\"\n    id = 'E2502'\n    shortdesc = 'Check if IamInstanceProfile are using the name and not ARN'\n    description = 'See if there are any properties IamInstanceProfile' + \\\n                  'are using name and not ARN'\n    source_url = 'https://github.com/awslabs/cfn-python-lint'\n    tags = ['properties']\n\n    def match(self, cfn):\n        \"\"\"Check CloudFormation IamInstanceProfile Parameters\"\"\"\n\n        matches = list()\n\n        # Build the list of keys\n        trees = cfn.search_deep_keys('Fn::GetAtt')\n        # Filter only resoureces\n        # Disable pylint for Pylint 2\n        # pylint: disable=W0110\n        trees = filter(lambda x: x[0] == 'Resources', trees)\n        for tree in trees:\n            if any(e == 'IamInstanceProfile' for e in tree):\n                obj = tree[-1]\n                objtype = cfn.template.get('Resources', {}).get(obj[0], {}).get('Type')\n                if objtype:\n                    if objtype != 'AWS::IAM::InstanceProfile':\n                        message = 'Property IamInstanceProfile should relate to AWS::IAM::InstanceProfile for %s' % (\n                            '/'.join(map(str, tree[:-1])))\n                        matches.append(RuleMatch(tree[:-1], message))\n                    else:\n                        if obj[1] == 'Arn':\n                            message = 'Property IamInstanceProfile shouldn\\'t be an ARN for %s' % (\n                                '/'.join(map(str, tree[:-1])))\n                            matches.append(RuleMatch(tree[:-1], message))\n\n        # Search Refs\n        trees = cfn.search_deep_keys('Ref')\n        # Filter only resoureces\n        trees = filter(lambda x: x[0] == 'Resources', trees)\n        for tree in trees:\n            if any(e == 'IamInstanceProfile' for e in tree):\n                obj = tree[-1]\n                objtype = cfn.template.get('Resources', {}).get(obj, {}).get('Type')\n                if objtype:\n                    if objtype != 'AWS::IAM::InstanceProfile':\n                        message = 'Property IamInstanceProfile should relate to AWS::IAM::InstanceProfile for %s' % (\n                            '/'.join(map(str, tree[:-1])))\n                        matches.append(RuleMatch(tree[:-1], message))\n\n        return matches\n", "path": "src/cfnlint/rules/resources/iam/InstanceProfile.py"}], "after_files": [{"content": "\"\"\"\n  Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this\n  software and associated documentation files (the \"Software\"), to deal in the Software\n  without restriction, including without limitation the rights to use, copy, modify,\n  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n  permit persons to whom the Software is furnished to do so.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\"\"\"\nfrom cfnlint import CloudFormationLintRule\nfrom cfnlint import RuleMatch\n\n\nclass InstanceProfile(CloudFormationLintRule):\n    \"\"\"Check if IamInstanceProfile are used\"\"\"\n    id = 'E2502'\n    shortdesc = 'Check if IamInstanceProfile are using the name and not ARN'\n    description = 'See if there are any properties IamInstanceProfile' + \\\n                  'are using name and not ARN'\n    source_url = 'https://github.com/awslabs/cfn-python-lint'\n    tags = ['properties']\n\n    def match(self, cfn):\n        \"\"\"Check CloudFormation IamInstanceProfile Parameters\"\"\"\n\n        matches = list()\n\n        # Build the list of keys\n        trees = cfn.search_deep_keys('Fn::GetAtt')\n        # Filter only resoureces\n        # Disable pylint for Pylint 2\n        # pylint: disable=W0110\n        trees = filter(lambda x: x[0] == 'Resources', trees)\n        for tree in trees:\n            if any(e == 'IamInstanceProfile' for e in tree):\n                obj = tree[-1]\n                objtype = cfn.template.get('Resources', {}).get(obj[0], {}).get('Type')\n                if objtype:\n                    if objtype != 'AWS::IAM::InstanceProfile':\n                        message = 'Property IamInstanceProfile should relate to AWS::IAM::InstanceProfile for %s' % (\n                            '/'.join(map(str, tree[:-1])))\n                        matches.append(RuleMatch(tree[:-1], message))\n                    else:\n                        if cfn.template.get('Resources', {}).get(tree[1], {}).get('Type') in ['AWS::EC2::SpotFleet']:\n                            if obj[1] != 'Arn':\n                                message = 'Property IamInstanceProfile should be an ARN for %s' % (\n                                    '/'.join(map(str, tree[:-1])))\n                                matches.append(RuleMatch(tree[:-1], message))\n                        else:\n                            if obj[1] == 'Arn':\n                                message = 'Property IamInstanceProfile shouldn\\'t be an ARN for %s' % (\n                                    '/'.join(map(str, tree[:-1])))\n                                matches.append(RuleMatch(tree[:-1], message))\n\n        # Search Refs\n        trees = cfn.search_deep_keys('Ref')\n        # Filter only resoureces\n        trees = filter(lambda x: x[0] == 'Resources', trees)\n        for tree in trees:\n            if any(e == 'IamInstanceProfile' for e in tree):\n                obj = tree[-1]\n                objtype = cfn.template.get('Resources', {}).get(obj, {}).get('Type')\n                if objtype:\n                    if objtype != 'AWS::IAM::InstanceProfile':\n                        message = 'Property IamInstanceProfile should relate to AWS::IAM::InstanceProfile for %s' % (\n                            '/'.join(map(str, tree[:-1])))\n                        matches.append(RuleMatch(tree[:-1], message))\n\n        return matches\n", "path": "src/cfnlint/rules/resources/iam/InstanceProfile.py"}]}