terraform: guard against a nil resource