Allow attribute values to come from resource metadata #399
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: