nixops-aws
nixops-aws copied to clipboard
Checklist for adding a new resource
I am in the process of adding a DBSubnetGroup resource to this plugin, I have somehow copied the code from EC2 Security Group resource and tried to adapt everything to make it work, so far I understood I need to:
- [x] Create a Nix config file, like
ec2-rds-dbsubnet-group.nix
withmkOption
. - [x] Add it to the
default.nix
usingevalResources
(which I am not sure to understand what it does exactly). - [x] Create a Python logic file, like
ec2_rds_dbsubnet_group.py
which implements a Definition and a State and to ensure in the definition that resource type are matching. - [x] Import it into the
nixops.resources.__init__.py
file.
Did I miss something? While my code is "working", it's not picking up the new resource declaration in one of my infrastructure.nix
file.
EDIT: I add that I can see the resource inside my nixops info
table, but I don't see it when I try to generate the plan of deployment. I don't know what exactly that means. Also, dependencies are set up so that VPCSubnet are all created before DBSubnet is created and DBInstance depends on DBSubnet, so I am supposed to see the correct order of dependencies and I'm unsure it is the case.
EDIT2: Finally made work a resource.
Basically, it seems like there are different practices to store referenced resources, some includes {name}.{type}.{resourceStateName ? key}
when using the DiffEngine, or some override completely and use their own manual diff engine.
I think it'd be great to document how the diff engine works, what is its expectations, to improve its debuggability (I had to chase all the paths of code through many prints…) and maybe generalize it / improve it so that all use case can enter into them (I see some EC2 resources do not use a diff engine, I understand for the EC2 resource, but for others, I believe they can enter in the context of the diff engine).
Also, it'd be great to give some pointers on how to write and compose resources, I suppose it's cool to explain how we can references each resource by generating some identifier which enough data to rebuild the info during traversal.
Also, mixing manual XML stuff and diff engine seems to disable diff engine, I still don't really know why.