Fn::ForEach Cloud formation template | SAM Validation Bug

1

Hello Everyone, I am trying to create resources using Fn::ForEach in Cloud formation template using YAML format. I am referring aws documentation example. with the same template I am getting AttributeError: 'list' object has no attribute 'get' error. Have tried multiple combinations of this and nothing worked.

profile picture
AGS
질문됨 일 년 전1564회 조회
4개 답변
2
수락된 답변

Looks like SAM CLI doesn't support language extensions with sam validate. There is an open issue for the same AWS CLI ISSUE.

profile picture
AGS
답변함 일 년 전
profile picture
전문가
검토됨 4달 전
0

Hello.
There are several templates listed in the document, which one did you use?

profile picture
전문가
답변함 일 년 전
  • Actually Tried almost everything, we can take this up:

    AWSTemplateFormatVersion: 2010-09-09
    Transform: 'AWS::LanguageExtensions'
    Resources:
      'Fn::ForEach::Tables':
        - TableName
        - [Points, Score, Name, Leaderboard]
        - 'DynamoDB${TableName}':
            Type: 'AWS::DynamoDB::Table'
            Properties:
              TableName: !Ref TableName
              AttributeDefinitions:
                - AttributeName: id
                  AttributeType: S
              KeySchema:
                - AttributeName: id
                  KeyType: HASH
              ProvisionedThroughput:
                ReadCapacityUnits: '5'
                WriteCapacityUnits: '5'
    
  • Thanks for the reply. I was able to deploy successfully on my AWS account. Deployment was done from the management console. Check to see if indentation, etc. is not broken and deploy again.

  • Thanks for the reply, Have tried from aws console, its is working. I would be requiring this to done from SAM since I wouldn't be able to access management console in all the ENVs. If I try doing SAM deployment from pipeline or SAM CLI, getting AttributeError: 'list' object has no attribute 'get' for the same template.

  • With AWS SAM I got the same error. So please use CloudFormation instead of AWS SAM. CloudFormation can also be deployed via AWS CLI. The following commands will enable deployment.

    aws cloudformation create-stack --stack-name test --template-body file://template.yml --capabilities CAPABILITY_AUTO_EXPAND
    
  • Hi Yes this was working as expected, thank you

0

Hi. Just tried with this one above and it works. Try to create yaml from scratch, copy this template and upload it via console to CloudFormation. If there is an error, please show a screen from a console.

profile picture
답변함 일 년 전
  • Thanks for the reply, Have tried from aws console, its is working. I would be requiring this to done from SAM since I wouldn't be able to access management console in all the ENVs. If I try doing SAM deployment from pipeline or SAM CLI, getting AttributeError: 'list' object has no attribute 'get' for the same template.

0

I can confirm that this is an issue when using SAM. When running SAM validate I get the following error: Error: 'list' object has no attribute 'get'.

Ace
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인