Unit testing for replacement of stateful resources #26223
-
Hi, I've been reading about the built-in functionality of I haven't found any documentation for doing so. Can I somehow assert that the synthesized template does not cause a replacement for particular resources? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
@github-actions proposed-answer Unit tests will test that a template is generated a certain way. Given a construct If you make changes to your |
Beta Was this translation helpful? Give feedback.
-
Thank you, Peter! Very helpful |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
@github-actions proposed-answer Unit tests will test that a template is generated a certain way. Given a construct
StatefulConstruct
that creates both aBucket
and aTable
, you could write unit tests that verify when you instantiateStatefulConstruct
in a stack, aBucket
andTable
resource are created with XYZ properties. View this section of the CDK workshop to see how you might create tests. The properties that you want to test for sure are the properties in the CloudFormation document that are marked asUpdate requires: Replacement
If you make changes to your
StatefulConstruct
construct such that these unit tests will start producing different values for any resources marked asUpdate …