Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Fn::ForEach function breaks cloudformation package CLI #8075

Closed
JeremieRodon opened this issue Jul 31, 2023 · 8 comments
Closed

New Fn::ForEach function breaks cloudformation package CLI #8075

JeremieRodon opened this issue Jul 31, 2023 · 8 comments
Labels
bug This issue is a bug. cloudformation package-deploy cloudformation customization Issues related to CLI customizations (located in /awscli/customizations) p3 This is a minor priority issue

Comments

@JeremieRodon
Copy link

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

@JeremieRodon JeremieRodon added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 31, 2023
@JeremieRodon
Copy link
Author

Update: It also fails when packaging a template with nested templates when one of the nested templates uses the Fn::ForEach

@aBurmeseDev aBurmeseDev self-assigned this Aug 2, 2023
@aBurmeseDev aBurmeseDev added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Aug 3, 2023
@aBurmeseDev
Copy link
Member

Hi @JeremieRodon - thanks for reporting this behavior. I was able to reproduce it on my end and we will need to further investigate with the team. I'll post here once we have an update.

@aBurmeseDev aBurmeseDev added cloudformation p2 This is a standard priority issue labels Aug 4, 2023
@aBurmeseDev
Copy link
Member

From further discussion with the team, we have been advised to refer users of CloudFormation package to the AWS SAM CLI and sam-package command. Any changes related to the CloudFormation customization are currently not prioritized but you're welcome to submit contribution PR on this and the team will be able to take a look.
As an alternative, are you able to use the AWS SAM CLI or do you know if this issue present there as well?

@aBurmeseDev aBurmeseDev added cloudformation package-deploy p3 This is a minor priority issue response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. p2 This is a standard priority issue labels Aug 8, 2023
@dansepp-gale
Copy link

As best I can tell, this is an issue with the AWS SAM CLI as well.

@richard-grainger-veeva
Copy link

I am also seeing this issue.

@tim-finnigan
Copy link
Contributor

Just wanted to follow up and let everyone know that we are aware of the issue, and the team owning the CloudFormation customization is planning to work on it. Also found a related issue in the SAM CLI repository: aws/aws-sam-cli#5647

@tim-finnigan tim-finnigan added customization Issues related to CLI customizations (located in /awscli/customizations) and removed response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Aug 15, 2023
@aBurmeseDev aBurmeseDev removed their assignment Aug 22, 2023
@hssyoo
Copy link
Contributor

hssyoo commented Jan 2, 2024

The Fn::ForEach intrinsic function is available in v1 and v2: #8096

@hssyoo hssyoo closed this as completed Jan 2, 2024
Copy link

github-actions bot commented Jan 2, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. cloudformation package-deploy cloudformation customization Issues related to CLI customizations (located in /awscli/customizations) p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

6 participants