Amoghavarsh P
Amoghavarsh P

Reputation: 1

Cdktf Optional block

How to make block optional if the value for the below block not provided?

const BackupType=new TerraformVariable(this,"BackupType",{
      description:"(Required) The type of the backup. Possible values are Continuous and Periodic. Defaults to Periodic. Migration of Periodic to Continuous is one-way, changing Continuous to Periodic forces a new resource to be created."
    })
    const  BackupIntervalInMinutes=new TerraformVariable(this,"BackupIntervalInMinutes",{
      description:"(Optional) The interval in minutes between two backups. This is configurable only when type is Periodic. Possible values are between 60 and 1440."
    })
   const  BackupRetenti`enter code here`onInHours=new TerraformVariable(this,"BackupRetentionInHours",{
      description:"(Optional) The time in hours that each backup is retained. This is configurable only when type is Periodic. Possible values are between 8 and 720."
    })
   const  BackupStorageRedundancy=new TerraformVariable(this,"BackupStorageRedundancy",{
      description:"(Optional) The storage redundancy which is used to indicate type of backup residency. This is configurable only when type is Periodic. Possible values are Geo, Local and Zone."
    }) 

backup:{
      type:BackupType.value,
      intervalInMinutes:BackupIntervalInMinutes.value,
      retentionInHours:BackupRetentionInHours.value,
      storageRedundancy:BackupStorageRedundancy.value,
    },

Upvotes: 0

Views: 152

Answers (1)

Daniel Schmidt
Daniel Schmidt

Reputation: 11921

If the terraform variables are not passed the value will be synthesized as a refrence to the input, but at compile time it will have no data so it should be treated the same way as if it wasn't passed.

Upvotes: 0

Related Questions