Hi, Thanks for the explanation.
However here are results of my investigation.
Terraform using ID to identify objects regardless it is belonging to the same type of resources or not. It was surprise for me . I though if we have resource of type A and resource of type B and both of them have the same id- terraform consider them as a different resources. (I’m not sure about it, but looks like).
So, here is idea I implemented.
We have resource1 of type A, we have resource 2 of type B.
Resource A has implementation of method Create and empty implementation for other methods. Resource A does not have guid_id as a parameter
Resource B has update functionality in both Create and Update and has guid_id as a parameter
Main point- both resources has id generated based on name of resources, like
d.SetId(“A_”+iaas_output.ID) and d.SetId(“B_”+iaas_output.ID)
So, terraform consider them as separate resources and does whatever I want.
So , by doing that I can implement scenario with update.
Here is a terraform script which (works!) does create resource and update
terraform {
required_providers {
orch = {
version = “1.0.1”
source = “localhost/company/orch”
}
}
}
provider “orch” {
}
variable “iaas_name” {
description=“Name of iaas provider”
}
variable “iaas_url” {
description=“Url of iaas provider”
}
variable “iaas_update_url” {
description=“Url of iaas provider”
}
variable “iaas_type” {
description=“Url of iaas provider”
}
variable “iaas_guid” {
description=“guild of iaas provider”
}
resource “orch_iaas_resource” “my_iaas” {
type=var.iaas_type
name=var.iaas_name
url=var.iaas_url
}
resource “orch_iaas_update_resource” “my_iaas_update” {
guid_id=orch_iaas_resource.my_iaas.guid_id
type=var.iaas_type
name=var.iaas_name
url=var.iaas_update_url
}
output “my_iaas_output” {
value=[orch_iaas_update_resource.my_iaas_update.guid_id,orch_iaas_update_resource.my_iaas_update.url]
}
So, I can do update any time and manage dependencies…
What do you think?
Best regards,
Dmitriy