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 attribute values to come from resource metadata #399

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

dhutchison
Copy link
Collaborator

@dhutchison dhutchison commented Dec 28, 2024

Fixes #394

I had started going down a bit of a rabbit hole of how hooks could be introduced so that attribute values could be more accurately generated, and that the library user could extend this instead of waiting on a library update to support new types. That seems quite complicated however for how infrequently I expect it to be required/used. The end of that approach was going to be that the hook updated the Metadata anyway (so calling GetAtt a second time for the same resource and attribute name would get a cached value so it was deterministic) - so if that idea comes back around, it will slot in to this fix.

This change allows what GetAtt returns to be set by the resource Metadata in the template. When unit testing there are no real AWS resources created, and cloud-radar does not attempt to realistically generate attribute values - a string is always returned. This works good enough most of the time, but there are some cases where if you are attempting to apply intrinsic functions against the attribute value it needs to be more correct.

Attribute values can be defined like this:

Resources:
  MediaPackageV2Channel:
    Type: AWS::MediaPackageV2::Channel
    Metadata:
      Cloud-Radar:
        attribute-values:
        # When unit testing there are no real AWS resources created, and cloud-radar
        # does not attempt to realistically generate attribute values - a string is always
        # returned. This works good enough most of the time, but there are some cases where
        # if you are attempting to apply intrinsic functions against the attribute value
        # it needs to be more correct.
        #
        # In this case, the attribute value is expected to be a List, not a string.
          IngestEndpointUrls:
            - http://one.example.com
            - http://two.example.com
    Properties:
      ChannelGroupName: dev_video_1
      ChannelName: !Sub ${AWS::StackName}-MediaPackageChannel

@dhutchison dhutchison added bug Something isn't working minor A new feature has been added. labels Dec 28, 2024
@dhutchison dhutchison force-pushed the fix/394-get-att-empty-values branch from db231e7 to b32a966 Compare December 28, 2024 12:21
@dhutchison dhutchison changed the base branch from master to develop December 28, 2024 12:22
Copy link

codecov bot commented Dec 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.80%. Comparing base (f1b9d72) to head (ca0ac45).
Report is 93 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #399      +/-   ##
===========================================
- Coverage    95.00%   94.80%   -0.20%     
===========================================
  Files           11       12       +1     
  Lines          760      847      +87     
  Branches       155      159       +4     
===========================================
+ Hits           722      803      +81     
- Misses          21       24       +3     
- Partials        17       20       +3     
Flag Coverage Δ
unit 94.80% <100.00%> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@dhutchison dhutchison marked this pull request as ready for review December 28, 2024 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working minor A new feature has been added.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Help with Intrinsic functions
1 participant