Open christopherhein opened 5 years ago
This looks awesome. I was just trying to figure out how to spin up my own definitions... it'd be great to not have to built out resources every time you want a new one.
This looks awesome. I was just trying to figure out how to spin up my own definitions... it'd be great to not have to built out resources every time you want a new one.
Thanks! There are some open items I still need to document, and try and find solutions for. For example the valid responses for CFN params aren't documented which will make automated validation difficult.
What do you mean by "valid responses for CFN params"?
Sorry, without context that doesn’t make sense. I’ve been trying to implement more logic at the operator/CRD side since k8s can natively validate resources on request, at first glance this isn’t going to be possible with the CFN Resource spec, because I’m the schema there is no key for acceptable values, so if we have a spec.status which the CFN expects to be “enabled” or “disabled” and you set to “true” or “false” you won’t know until the CFN stack fails instead of getting that upfront
@christopherhein Ah, yes.
I wonder if it might be possible to pull some of those sorts of validations out of the API generator models...
As an example:
Amazon CloudFront Distribution LambdaFunctionAssociation has a field EventType, which is a String. But that string is constrained to be a valid value, which is defined in the API docs: LambdaFunctionAssociation.
Those values are: viewer-request
| viewer-response
| origin-request
| origin-response
I'm not precisely sure where to get the canonical versions of these model files... but they seem to be in the generated AWS API clients...
LambdaFunctionAssociation -> EventType -> EventType shape, which is:
"EventType":{
"type":"string",
"enum":[
"viewer-request",
"viewer-response",
"origin-request",
"origin-response"
]
}
I'll grant the path is a bit circuitous, and may not all be in structured forms. But there might be some potential here...
@jpeddicord Really great thoughts, will take some work to get them munging together but shouldn't be too difficult!
@jpeddicord Really great thoughts, will take some work to get them munging together but shouldn't be too difficult!
Think you meant @jlongtine ;P
That I did :) Thanks!
@christopherhein Great! I'd definitely be interested in helping build out some of this generation (presuming I can manage to find time in addition to my day job 😄).
@christopherhein Great! I'd definitely be interested in helping build out some of this generation (presuming I can manage to find time in addition to my day job 😄).
Awesome, I'll definitely take you up on that. I'm right now working on the guts of this change likely it won't include things like validation (#164) (also the OpenV3Schema) or defaulting (#163) once the guts are inplace maybe we can work on those other two?
Sounds good, @christopherhein 😄
@jlongtine found something that might be even better, we can contribute back to the cfn-linting project @cmmeyer pointed me to the CFN specs which they've been manually adding AllowedValues
as a key for the resources. It's not complete but it gives us a less hacky way of getting all the data.
Check out - https://github.com/awslabs/cfn-python-lint/issues/50 if you are interested in adding some of those maps I'm going to change my code generation to reference these.
@christopherhein That looks awesome! I'll see if I can make some time to help flesh this out.
the goformation project has go structures for all (?) cf resources, I guess they could be just marshalled from yaml, with some metadata added?
https://github.com/awslabs/goformation/tree/master/cloudformation/resources
Idea
Using the AWS CloudFormation Resource Specification code generate all resources instead of having to manually design each resource.
Spec: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-resource-specification.html
Example S3 Bucket Spec
Example Kubernetes S3 Custom Resource
Changes
You'll notice a few specific ways these are still customized to make composing the resources easier for example we remove the parent key name from nested resources like
CorsRules
changes torules
under thecors
key. Also removingconfiguration(s)
since everything in this is a configuration and that is duplicative. Other component is using similar to Kubernetes core resources like Secrets and ConfigMaps allowing you to reference by ARN or by Kubernetes namespace/name mappings. So if a key is postfixed withArn
convert into something like: