-
Notifications
You must be signed in to change notification settings - Fork 27
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
Generic Data Provider #167
Comments
I like this idea! Is there any reason for there to be a single generic data provider? Why not have each Lambda (or each resource type handler) stand alone? |
Originally this solution come about as a CFN CR Lambda which had to be deployed to each account, so aggregation simply serv the purpose of having smaller deployment footprint, as the benefit side is only more customisable return dict structure and filters, and an even more limited, already read-only permission. But for registry it might make sense to break it down, just need to figure out a way to generate the resource specific extensions, as if it's all individually maintained then it would be probably with limited resource type only, due to large maintenance overhead, however that might be OK as there is a rather limited core service list where this is currently a pain-point and would be useful, R53 zones, VPC, Subnets, SG's, |
I think I'd rather see it broken down into separate resources. |
In that case it would make sense to have identical return data structure as the default CFN resource, so for example for a Route53 Domain Hence when used in code, the structure would be almost the same, so instead of
it would be something like:
Where the fields which are originally there for the create act as the filter. If you can help to understand the repo structure and where should I stick it in I can prep a single resource example, and then we can pick it up from there. In the meantime a question on supported error handling strategies. I believe this behaviour should be one of the input parameter, if not individually set for each type of potential errors:
Apart from the first and last, the other two can have different resolution, you might want to pick randomly if you are looking for just one but the filter match more then one, or you might want to just error, same if you get only one when asking for a list, you might just format it into a single item list, or might error on it, so how much flexibilty should be for the end-user to handle the errors, and how to give that freedom, for example:
|
Each of these would go into the Error handling is an interesting case. For finding one of a list, I think that would just be a single element list that's returned, unless it should always return multiple values. We should only go to the trouble of configuring for these cases if those are valid use cases - in most cases I would assume that if you don't get back the expected number of elements, it should be an error. |
Ok just reviewed the repo structure and the contribution docs, and I might need to untick the "I can help with this box" I used pure CFN a lot, and pretty comfortable with it, but don't really have any of an experience abstractions layers above above it, like Tropo, CDK or like this case SAM. As far as I understand based on https://github.com/aws-cloudformation/community-registry-extensions/blob/main/CONTRIBUTING.md
I tried SAM a while ago, but that time I seen no value just added complication, and lack of portability, so I need to start again from scratch. Unless if there is some means to translate backwards as well between CFN and SAM, as SAM renders to CFN too, which case I am happy to do it with CFN. |
Ok, no worries if you can't do the development yourself, we like the idea so we'll try to find someone to work on it. You don't actually have to be a SAM expert, it's only used to mock Lambda locally to facilitate contract testing for the resource handlers. The |
So I tried the
If these presumptions above are right, then my understanding is that I would need to write the Lambda code somewhere in the |
Here are the docs for the The two main things you need to do are to model the resource in the schema file, |
Would it make sense to use the CloudControl API for this? eg: Resources:
HostedZoneName:
Type: AwsCommunity::CloudControlApi::ListResourcesQuery
Properties:
TypeName: AWS::Route53::HostedZone
ResourceModel: {} # optional, json dict
Query: ResourceDescriptions[0].Properties.Name
Outputs:
HostedZoneName:
Value: HostedZoneName.Result or if you know the identifier: Resources:
HostedZoneName:
Type: AwsCommunity::CloudControlApi::GetResourceQuery
Properties:
TypeName: AWS::Route53::HostedZone
Identifier: !Ref HostedZoneId
Query: ResourceDescription.Properties.Name
Outputs:
HostedZoneName:
Value: HostedZoneName.Result downsides:
upsides:
neutral:
Edit: Resources:
HostedZoneId:
Type: AwsCommunity::CloudControlApi::ListResourcesQuery
Properties:
TypeName: AWS::Route53::HostedZone
ResourceModel: {} # optional, json dict
Query: ResourceDescriptions[0].Identifier
HostedZoneName:
Type: AwsCommunity::CloudControlApi::GetResourceQuery
Properties:
TypeName: AWS::Route53::HostedZone
Identifier: !GetAtt HostedZoneId.Result
Query: ResourceDescription.Properties.Name
Outputs:
HostedZoneName:
Value: HostedZoneName.Result |
That's a good point about contract testing. We might need to create a dummy resource under the hood. |
This issue might be covered by #190 |
Agree, looks relevant, will test it next week, and if covers the use-case will close the ticket. |
Thanks for the effort put into this so far. I tested the current version of Lookup and it does what the docs says 👍
|
Thank you for the feedback, @kallu ! On the note on the current version, I wrote an unrelated PR update today, that was merged a few minutes ago, with 2 fixes (see the merged PR's notes). There was similar feedback from @benbridts on the initial PR that I submitted; I had thought of those properties too (see my comment in reply on that PR). If this resource type would emit those fields in one additional output field containing the whole JSON string with properties (as it is not possible to map all the properties for all the supported query target resources to discrete fields in this resource type's schema), one could use |
@mrinaudo-aws For the |
Hi @ericzbeard @kallu @kisst @benbridts - I have worked on a PR, merged today (#223) that adds the ability to the lookup resource type to reference the whole JSON-formatted, property-related output from Cloud Control API for a given resource type lookup target that is supported by Cloud Control API. An example output excerpt for resource properties is: As I mentioned previously, I think it would be desirable to have a way to natively consume a value from JSON data such as the above, given a key. I have created this issue in the |
What type of extension are you looking for?
Other
Describe the extension you'd like to request
Loosely coupled infra has it's advantages, but also pitfalls, however other IaC solutions go around the problem with data provider.
Used when a large solution is split into multiple stack, for either size, complexity or segregation of duty the glue between Stacks currently can be cfn-export, SSM, or manual via CFN parameters, the better solution is to have the lookup based on given filters and have a virtual resource which then can be used with Ref or GetAtt.
For example:
If a CFN Stack needs to be deployed to a VPC ( non default ) then the info about the VPC should be self contained within the Stack, based on given filters the VPC would be available to be Ref or GetAtt, if based on the given filters, the given expected is returned.
For example searching for VPC tagged "mycorp" in the current region, would return the VPC, but a query for a list, with filter subnet's with tag "private" can return one or more subnets.
Describe the solution you'd like
A generic version of my initial attempt https://github.com/kisst/CFN-CR-Dataprovider made available for masses.
Additional context
No response
Is this something that you'd be interested in working on?
Would this feature include a breaking change?
The text was updated successfully, but these errors were encountered: