Hi there, I have the next problem, maybe trivial, but I cannot wrap my head around it.
I have a need to query the existing OpsGenie team by a given name and only if the team that I am trying to create, does not exist I will create it.
I do believe there should be a way for doing so in a convenient way in the TF using some conditional logic, but unfortunately enough, I couldn’t find this way yet.
Please let me know if it is surmountable at all.
Here is a small example of what I was talking about:
provider “opsgenie” {
api_key = “XXXXXXXXXXXXXXXXXX”
api_url = “api.opsgenie.XXX.com”
}
data “opsgenie_team” “checking-the-team” {
name = “abra-kadabra”
}
resource “opsgenie_team” “new_team” {
name = data.opsgenie_team.checking-the-team.id != “” ? data.opsgenie_team.checking-the-team.id : “abra-kadabra”
}
This is what I get when I use terraform plan:
Error: Error occurred with Status code: 404, Message: No team exists with name [abra-kadabra], Took: 0.009000…
I would like to get an empty value for a non-existing data source, so please let me if any of you have already dealt with the issue I am trying to describe.