'How do I set up a heartbeat module with a teams module

I'm working on two Modules, one that creates a Opsgenie Team and one that Creates a Heartbeat. settingup the Teams Module worked just fine but I am strugleing with the heartbeat module. heartbeat has a argument that requires a owner team. testing the configuration it seems that I need to create a team resource, what I would like to do instead though is use the team that is created with the teams module as the owner team, but since the resource for the team is in a different file I can't use the team I'd like to create as a owner team.

this is the main.tf of my teams:

  required_providers {
    opsgenie = {
      source  = "opsgenie/opsgenie"
      version = "0.6.8"
    }
  }
}

resource "opsgenie_team" "Terraform_Team" {
  name            = var.t_name
  description     = var.t_description
  ignore_members  = var.t_members
} 

and this is my heartbeat module:

terraform {
  required_providers {
    opsgenie = {
      source   = "opsgenie/opsgenie"
      version  = "0.6.8"
    }
  }
}

resource "opsgenie_heartbeat" "Heartbeat" {
  name            = var.hb_name
  description     = var.hb_desc
  interval_unit   = var.hb_interval
  interval        = var.hb_time
  enabled         = var.hb_status
  alert_message   = var.hb_message
  alert_priority  = var.hb_priority
  alert_tags      = var.hb_tags
  owner_team_id   = var.hb_teamId
}

I tried using a static owner_team_id as given by the documentation as well as this variable. but when I go back to my root.tf to set a owner team, the opsgenie_team.teamname.id turns red cause it cant find the ressource of the team. is there anyway I can reffer to the team name variable inside my teams module?

also please forgive my formating, for somereason I cant get out of the code block.


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source