-
Notifications
You must be signed in to change notification settings - Fork 13
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
Function to find all Resources of a specific type (to use with Fn::ForEach) #138
Comments
I like this idea, but until something like that is supported, you could potentially create log and subscription resources from the same Collection parameter, in a single Fn::ForEach loop. EDIT: Maybe you've said that approach wouldn't work for your use case? If so, would you mind elaborating on why, maybe with an example? I'm wondering whether it would work if you included some conditions in your loop, to cover variations. |
I think either support for yaml anchors and tags, or an expansion of the SAM globals section (https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-template-anatomy-globals.html) would be a cleaner solution for this |
I will be giving this a try for my use case to see if it is good enough. My concern about using a collection was that I might miss the name of a Lambda resource or perhaps typo the name (the latter would probably fail fast). I lose the resource "type" connection and the ability to automatically include any new Lambda resources that are added without needing to copy and past the names. |
I don't think globals would quite cover the use case, YAML anchors are an interesting idea, though I would like the ability to override certain properties (like names of things), and overriding the whole property might not be what is needed. |
Makes sense - I was basing my suggestion on what you said here ...
But I now see you later clarified ...
Either way, I like the concept of the intrinsic function you propose. Please let us know how your testing goes - if you get something working, I'd love to see an example snippet. |
Community Note
Tell us about your request
An intrinsic function that can find all resources of a specific type. A bonus would be an ability to filter them based upon a Logical Id pattern or even other properties.
Tell us about the problem you are trying to solve. What are you trying to do, and why is it hard?
Example use case:
I would like to add an
AWS::Logs::SubscriptionFilter
for everyAWS::Logs::LogGroup
defined in my template. Every property is the same for the SubscriptionFilter except for the Logical Id, and theLogGroupName
. This seems like a great use case forFn::ForEach
, if I could just get the list of Logical Ids for the LogGroups. One other note: the LogGroups may have some variability so I cannot drive their creation using a list or map (and so do not have that to drive the creation of theSubscriptionFilter
resources). I have been unable to find a satisfactory solution in CloudFormation examples or documentation.Without this I end up having to maintain and copy/paste a lot of boilerplate configuration and run the risk of missing a
SubscriptionFilter
for aLogGroup
.Are you currently working around this issue?
I am currently copying and pasting the same
AWS::Logs::SubscriptionFilter
block and then changing the resource id andLogGroupName
.What is the expected behavior with this new feature
Rather than having to do something like this (simplified example)
I am envisioning something like this (in this case I am driving both the
LogGroup
and theSubscriptionFilter
off of theFunction
resources):Additional context
This could save time and prevent issues caused by copy/paste errors and omissions.
Attachments
The text was updated successfully, but these errors were encountered: