aws-ia / taskcat

Test all the CloudFormation things! (with TaskCat)
https://aws-ia.github.io/taskcat/
Apache License 2.0
1.17k stars 213 forks source link

Taskcat failing when Fn::ForEach exist in the template #815

Open gopinjag opened 11 months ago

gopinjag commented 11 months ago

Describe the bug Taskcat failing with the error TypeError: list indices must be integers or slices, not str when Fn::ForEach exist in the template.

To Reproduce Steps to reproduce the behavior:

  1. Are you testing a QuickStart or Custom template? Tested the example AWS template which has Fn::ForEach

  2. Attach or link a copy of the template if possible (remove any sensitive info) - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-foreach-example-resource.html#intrinsic-function-reference-foreach-example-reference-replicated-resource.yaml

  3. Provide the parameters that you passed. (remove any sensitive info) - No parameters but ami id can be replaced with any ami id

  4. How did you install taskcat? (docker or pip3) - pip3

  5. Are you using a profile, an instance role or access keys to run taskcat? - STS credentials from IAM identity center

  6. Is your AWS environment configured via aws configure? yes

Expected behavior Taskcat should deploy and tear down resources but its failing even before linting with the error ``TypeError: list indices must be integers or slices, not str``` .

I had added -d flag and figured out the below error

File "/opt/homebrew/lib/python3.11/site-packages/taskcat/_cfn/template.py", line 156, in _find_children
    if resource["Type"] == "AWS::CloudFormation::Stack":

Troubleshooting further since the 'Fn::ForEach::Instances': is present in resource block self.template["Resources"].keys() is causing the failure , hence the logic should be updated to handle Fn::ForEach

Screenshots If applicable, add screenshots to help explain your problem.

**Version (Please make sure you are running the latest version of taskcat)

To find versions: Via taskcat: taskcat -V Via pip3: pip3 show taskcat

Note: both version should match

To update taskcat run: for docker : docker pull taskcat/taskcat for pip3: pip3 install --upgrade taskcat

Additional context Add any other context about the problem here.