-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Labels
Description
Description
The SAM CLI fails to parse templates using the ForEach intrinsic function to define resources. The build first fails in aws-sam-translator code.
Comments in a similar issue reported in the sam-cli project (aws/aws-sam-cli#5647) point to a fix recently merged in AWS CLI (aws/aws-cli#8096). Applying similar changes in both aws-sam-translator (see #3636) and aws-sam-cli on a local test environment fixes the issue.
Steps to reproduce
Run sam build with the example provided in the function reference documentation
Observed result
The command fails in aws-sam-translator code with the following traceback:
Starting Build use cache
2024-07-05 08:13:52 Plugin 'ServerlessAppPlugin' raised an exception: 'list' object has no attribute 'get'
Traceback (most recent call last):
File "samtranslator/plugins/sam_plugins.py", line 130, in act
File "samtranslator/metrics/method_decorator.py", line 116, in wrapper_cw_timer
File "samtranslator/plugins/application/serverless_app_plugin.py", line 124, in on_before_transform_template
File "samtranslator/sdk/template.py", line 34, in iterate
File "samtranslator/sdk/resource.py", line 26, in __init__
AttributeError: 'list' object has no attribute 'get'
Error: 'list' object has no attribute 'get'
Traceback:
File "click/core.py", line 1055, in main
File "click/core.py", line 1657, in invoke
[...]
File "samcli/lib/samlib/wrapper.py", line 73, in run_plugins
File "samcli/lib/samlib/wrapper.py", line 130, in parse
File "samtranslator/plugins/sam_plugins.py", line 136, in act
File "samtranslator/plugins/sam_plugins.py", line 130, in act
File "samtranslator/metrics/method_decorator.py", line 116, in wrapper_cw_timer
File "samtranslator/plugins/application/serverless_app_plugin.py", line 124, in on_before_transform_template
File "samtranslator/sdk/template.py", line 34, in iterate
File "samtranslator/sdk/resource.py", line 26, in __init__
An unexpected error was encountered while executing "sam build".
Search for an existing issue:
https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20sam%20build%20-%20AttributeError
Or create a bug report:
https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20sam%20build%20-%20AttributeError
Expected result
The command shouldn't fail and output:
Build Succeeded
Additional environment details
- OS: Debian Bookworm
- If using the SAM CLI,
sam --version: reproduced with bothSAM CLI, version 1.121.0andSAM CLI, version 1.123.0 - AWS region: eu-west-1
aaythapa