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

Allow "aws cloudformation package" to succeed when a Resource is not a key-value pair #8096

Merged
merged 17 commits into from
Dec 14, 2023

Conversation

arthurboghossian
Copy link
Contributor

Issue #, if available: #8075

Description of changes:

Allow "aws cloudformation package" to succeed when a Resource is not a key-value pair.

This includes supporting the new Fn::ForEach intrinsic function, which can be provided as a key-value pair within the Resources section, where the value is not a key-value pair, as expected, but a list.

Note: was able to successfully run aws cloudformation package and aws cloudformation deploy on CloudFormation templates that contained the Fn::ForEach intrinsic function.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@arthurboghossian
Copy link
Contributor Author

Added a warning message that local artifacts aren't currently supported in Resources that aren't defined as key-value pairs

…ic function by recursively calling the export function on the fragment property of Fn::ForEach
@arthurboghossian
Copy link
Contributor Author

In the latest commit, modified artifact_explorer, where instead of skipping over resources that aren't dictionaries, modifying the export method to be able to handle the Fn::ForEach intrinsic function by recursively calling the export function on the fragment property of Fn::ForEach

@codecov-commenter
Copy link

codecov-commenter commented Sep 27, 2023

Codecov Report

Attention: 11 lines in your changes are missing coverage. Please review.

Comparison is base (42cdbca) 0.08% compared to head (7e7b8c2) 0.08%.

Files Patch % Lines
...customizations/cloudformation/artifact_exporter.py 0.00% 9 Missing ⚠️
awscli/customizations/cloudformation/exceptions.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           develop   #8096      +/-   ##
==========================================
- Coverage     0.08%   0.08%   -0.01%     
==========================================
  Files          208     208              
  Lines        16673   16682       +9     
==========================================
  Hits            14      14              
- Misses       16659   16668       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I just had some smaller comments.


resource_type = resource.get("Type", None)
if resource_type is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a particular reason this if check was added for the Type? A sample CFN template snippet would help illustrate what it is addressing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had added this (removed it from the latest commit) to prevent the need to go through the items in self.resources_to_export if the resource_type resolves to None (see loop below)

            resource_type = resource.get("Type", None)
            # ...
            for exporter_class in self.resources_to_export:
                if exporter_class.RESOURCE_TYPE != resource_type:
                    continue
                # ...

However, looking at the Resource class, if RESOURCE_TYPE is not defined for a subclass of a Resource, it would also resolve to None, thought I don't think we'd every have such a subclass, but it is possible, so opting to not have this change as part of this PR

Copy link
Contributor

@hssyoo hssyoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@hssyoo hssyoo merged commit 2676a46 into aws:develop Dec 14, 2023
aws-sdk-python-automation added a commit that referenced this pull request Dec 15, 2023
* release-1.32.2:
  Bumping version to 1.32.2
  Update changelog based on model updates
  Support Fn::ForEach intrinsic function (#8096)
AvnerCohen pushed a commit to hiredscorelabs/aws-cli that referenced this pull request Dec 26, 2023
Allow "aws cloudformation package" to succeed when a Resource is not a key-value pair.
@rhbecker
Copy link

A fix very similar to what this PR addressed is needed for the sam cli. Is there any chance that the authors of this PR would be willing to take that on?

smasset-veolia added a commit to smasset-veolia/serverless-application-model that referenced this pull request Aug 14, 2024
smasset-veolia added a commit to smasset-veolia/serverless-application-model that referenced this pull request Aug 14, 2024
smasset-veolia added a commit to smasset-veolia/serverless-application-model that referenced this pull request Aug 17, 2024
smasset-veolia added a commit to smasset-veolia/serverless-application-model that referenced this pull request Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants