-
Notifications
You must be signed in to change notification settings - Fork 216
Description
Now that #622 is merged it's a lot easier to work with Taskcat from inside python. During the process of developing the feature for functional testing from inside python I kept having problems with credentials. Setting them on the CLI and then refreshing them. It was a nightmare. It had me thinking about this whole testing thing and really the types of tests that I was writing were really only testing the Cloudformation service. Things like is X resource created or is "String" in Resource Name. None of these things need to be deployed to AWS be tested. What I was really doing was writing my unit tests as functional tests to make them work.
So I started thinking about what would it take to test a cloudformation template locally in order to do these unit tests.
- Load all the template parameters either by taking user input or using the defaults provided for that parameter.
- Resolve the conditionals
- Resolve all intrinsic functions in the resources/outputs section.
The only somewhat tricky part here I found is when dealing with a nested intrinsic function you need to resolve from the deepest function and work your way out. It took 3 or 4 hours but I was able to build a rough POC. After a few days I had a nice working MVP. You can see how it works in the README under 'Usage'. The logic is quite simple and is all here. It's mostly ready to go except these few shortcomings:
- Implement all AWS intrinsic functions.
- Only
!Ref
,!Sub
,!Equals
and!If
currently supported.
- Only
- Add full functionality to pseudo variables.
- Variables like
Partition
,URLSuffix
should change if the region changes. - Variables like
StackName
andStackId
should have a better default than ""
- Variables like
- Handle References to resources that shouldn't exist.
- It's currently possible that a
!Ref
to a Resource stays in the final template even if that resource is later removed because of a conditional.
- It's currently possible that a
If the Taskcat maintainers would like this functionality I can begin porting it into taskcat.