terraform-provider-ibm
terraform-provider-ibm copied to clipboard
data source that uses crn and tags to find a list of instances
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Description
My specific use case:
In terraform I would like to reference versions of the images I’m creating in the development. Step 2:
I think the answer is a resource instance search based on tags. See https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/resource_instance
There is an existing resource:
data "ibm_resource_instance" "testacc_ds_resource_instance" {
name = "myobjectstore"
location = "global"
resource_group_id = data.ibm_resource_group.group.id
service = "cloud-object-storage"
}
Maybe there should be a CRN and TAG based search for list or resources. See:
See the CRN spec: https://cloud.ibm.com/docs/account?topic=account-crn
From a quick read of the docs it would look something like this (maybe something else would be better?)
data "ibm_resource_instances" "test" {
name = "myobjectstore" // optional
location = "global"
resource_group_id = data.ibm_resource_group.group.id
service = "cloud-object-storage"
// Some of these look the same as the ones above? from CRN docs:
version = ""
cname = ""
ctype = "public"
service_name = "is"
ocation = "global" covered above
scope=
service_instance =
resource_type =
resource =
// tags
tags = ["tagname1", "tagname2:tagvalue"]
}
Retrieve a list of instances that match the search parameters
The crn I'm looking for:
crn:version:cname :ctype :service-name:location :scope :service-instance :resource-type :resource
crn:v1 :bluemix:public :is :us-south :a/713c783d9a507a53135fe6793c37cc74: :image :r006-e0c96113-8bd3-440b-979b-5088185546ed
The tags are version:1.2
So the data source would be:
data "ibm_resource_instances" "image12" {
resource_group_id = data.ibm_resource_group.group.id
ctype = "public"
service_name = "is"
location = "us_south"
resource_type = "image"
tags = ["version:1.2"]
}
In my use case it would return a list of one element. I could then use the ID returned as a parameter to https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/is_instance
Docs would be needed to determine how to get the image = data.ibm_resource_instances.image12[0].???
from the data value.
maybe the list needs to be sorted by an attribute as well, so that If more then one was returned the latest would be returned?
New or Affected Resource(s)
- ibm_resource_instances
Potential Terraform Configuration
# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key.
See above
References
- #0000
Using the cli:
ibmcloud resource search 'service_name:is AND type:image AND tags:"version:1.2"'