terraform: fix potential case where cycle is made