-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
Describe the bug
When using aws cloudformation package on a template file that uses Transform: AWS::LanguageExtensions with Fn::ForEach, the command fails with the message:
'list' object has no attribute 'get'
Expected Behavior
aws cloudformation package should accept any syntax accepted by the CloudFormation service engine.
Current Behavior
aws cloudformation package fails with 'list' object has no attribute 'get' when using a template with the Fn::ForEach language extension.
Reproduction Steps
This is a valid CloudFormation template that will create two InternetGateways:
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::LanguageExtensions
Resources:
Fn::ForEach::IGW:
- index
- ['A', 'B']
- IGW${index}:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: !Sub igw-${index}If you save that in a file named igws.yml and try this:
aws cloudformation package --template-file igws.yml --s3-bucket some-bucket --output-template-file igws-new.yml
It will throw the exception
Possible Solution
It fails because the Resource bloc usually only contains sub-objects like:
Resources:
VPC:
Type: AWS::EC2::VPC
Properties:
[clip...]
With the Fn::ForEach, we must define a list, like:
Resources:
Fn::ForEach::Subnets:
- index
- ['A', 'B']
- [clip...]
I guess the CLI parser is expecting anything under Resources to be a Python dictionary with a Type key so it tries to get that.
When it tries to do so on the Fn::ForEach list, that throws 'list' object has no attribute 'get'
Additional Information/Context
No response
CLI version used
aws-cli/2.13.5
Environment details (OS name and version, etc.)
Windows 10