Cdktf testing resources

Hi there,

I’m trying to move my TF code to cdktf in golang and i’m making some test, one of them should check if a resource has the correct properties. Code:

func TestKmsProperties(t *testing.T){
    properties := map[string]interface{}{
        "EnableKeyRotation": "true",
        "DeletionWindowInDays": "7",

    assertion := cdktf.Testing_ToHaveResourceWithProperties(cdktf.Testing_FullSynth(stack), "kms_bucket_state", &properties)

    if !*assertion  {
        t.Error("Assertion Failed")

How could i get the resource type of the kms object? kms comes from a terraform module and it doesn’t have tfResouceType() function that i see on the examples. Some guidance would be appreciated.


For the expected value you would use KmsKey_TfResourceType assuming you are talking about a KMS key. In general it is <ResourceName>_TfResourceType in the package of the resource. (it’s the equivalent of a static method on a class in TS in JSII / cdktf).

For the actual value you need to use myKmsKey.TerraformResourceType()

1 Like

Sorry for the delay and thank you for the answer, it works!! Cheers!