I have a bit of a chicken and egg situation and I’d welcome some input from more some more knowledgeable folks.
I’m attempting to use Mastercard’s restapi provider to interact with an API, but the difficulty is that I need to make use of an ID returned on creation of the resource.
I can get the ID of the cluster from the API’s response when initially creating the cluster, but then I would need to use that in the nodepool creation in order to specify the correct API path. Below is some code which I know won’t work, but it shows what I want to achieve.
resource "restapi_object" "cluster" {
...
}
output "clusterid" {
value = jsondecode(restapi_object.cluster.api_response).id
}
resource "restapi_object" "nodepool" {
path = "/v5/clusters/${output.clusterid}/nodepools/"
...
depends_on = [
restapi_object.cluster,
]
}
Any suggestions welcome!