Closed william8siew closed 1 month ago
Simple create+update+destroy run through with new ID
(base) wsiew@Williams-MacBook-Pro ibm-key-protect % terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# ibm_kms_instance_policies.instance_policy will be created
+ resource "ibm_kms_instance_policies" "instance_policy" {
+ endpoint_type = (known after apply)
+ id = (known after apply)
+ instance_id = (known after apply)
+ dual_auth_delete {
+ created_by = (known after apply)
+ creation_date = (known after apply)
+ enabled = false
+ last_updated = (known after apply)
+ updated_by = (known after apply)
}
+ key_create_import_access {
+ create_root_key = true
+ create_standard_key = true
+ created_by = (known after apply)
+ creation_date = (known after apply)
+ enabled = true
+ enforce_token = false
+ import_root_key = true
+ import_standard_key = true
+ last_updated = (known after apply)
+ updated_by = (known after apply)
}
+ metrics {
+ created_by = (known after apply)
+ creation_date = (known after apply)
+ enabled = true
+ last_updated = (known after apply)
+ updated_by = (known after apply)
}
+ rotation {
+ created_by = (known after apply)
+ creation_date = (known after apply)
+ enabled = true
+ interval_month = 3
+ last_updated = (known after apply)
+ updated_by = (known after apply)
}
}
# ibm_kms_key.key_part_of_key_ring will be created
+ resource "ibm_kms_key" "key_part_of_key_ring" {
+ crn = (known after apply)
+ endpoint_type = (known after apply)
+ force_delete = false
+ id = (known after apply)
+ instance_crn = (known after apply)
+ instance_id = (known after apply)
+ key_id = (known after apply)
+ key_name = "key_part_of_key_ring"
+ key_ring_id = "key-ring-id"
+ payload = (sensitive value)
+ registrations = (known after apply)
+ resource_controller_url = (known after apply)
+ resource_crn = (known after apply)
+ resource_group_name = (known after apply)
+ resource_name = (known after apply)
+ resource_status = (known after apply)
+ standard_key = false
+ type = (known after apply)
}
# ibm_kms_key_rings.key_ring will be created
+ resource "ibm_kms_key_rings" "key_ring" {
+ endpoint_type = (known after apply)
+ force_delete = false
+ id = (known after apply)
+ instance_id = (known after apply)
+ key_ring_id = "key-ring-id"
}
# ibm_kms_kmip_adapter.adapter1 will be created
+ resource "ibm_kms_kmip_adapter" "adapter1" {
+ created_at = (known after apply)
+ created_by = (known after apply)
+ description = "adding a description"
+ endpoint_type = (known after apply)
+ id = (known after apply)
+ instance_id = (known after apply)
+ name = (known after apply)
+ profile = "native_1.0"
+ profile_data = (known after apply)
+ updated_at = (known after apply)
+ updated_by = (known after apply)
}
# ibm_resource_instance.kp_instance will be created
+ resource "ibm_resource_instance" "kp_instance" {
+ account_id = (known after apply)
+ allow_cleanup = (known after apply)
+ created_at = (known after apply)
+ created_by = (known after apply)
+ crn = (known after apply)
+ dashboard_url = (known after apply)
+ deleted_at = (known after apply)
+ deleted_by = (known after apply)
+ extensions = (known after apply)
+ guid = (known after apply)
+ id = (known after apply)
+ last_operation = (known after apply)
+ location = "us-south"
+ locked = (known after apply)
+ name = "wsiew-2024-may"
+ plan = "tiered-pricing"
+ plan_history = (known after apply)
+ resource_aliases_url = (known after apply)
+ resource_bindings_url = (known after apply)
+ resource_controller_url = (known after apply)
+ resource_crn = (known after apply)
+ resource_group_crn = (known after apply)
+ resource_group_id = (known after apply)
+ resource_group_name = (known after apply)
+ resource_id = (known after apply)
+ resource_keys_url = (known after apply)
+ resource_name = (known after apply)
+ resource_plan_id = (known after apply)
+ resource_status = (known after apply)
+ restored_at = (known after apply)
+ restored_by = (known after apply)
+ scheduled_reclaim_at = (known after apply)
+ scheduled_reclaim_by = (known after apply)
+ service = "kms"
+ service_endpoints = (known after apply)
+ state = (known after apply)
+ status = (known after apply)
+ sub_type = (known after apply)
+ tags = (known after apply)
+ target_crn = (known after apply)
+ type = (known after apply)
+ update_at = (known after apply)
+ update_by = (known after apply)
}
Plan: 5 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
ibm_resource_instance.kp_instance: Creating...
ibm_resource_instance.kp_instance: Still creating... [10s elapsed]
ibm_resource_instance.kp_instance: Creation complete after 15s [id=crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1::]
ibm_kms_key_rings.key_ring: Creating...
ibm_kms_instance_policies.instance_policy: Creating...
ibm_kms_instance_policies.instance_policy: Creation complete after 1s [id=crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1::]
ibm_kms_key_rings.key_ring: Creation complete after 1s [id=key-ring-id:keyRing:crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1::]
ibm_kms_key.key_part_of_key_ring: Creating...
ibm_kms_key.key_part_of_key_ring: Creation complete after 1s [id=crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1:key:c00e6305-4edf-42f5-bb1d-17ebb4cca6ca]
ibm_kms_kmip_adapter.adapter1: Creating...
ibm_kms_kmip_adapter.adapter1: Creation complete after 1s [id=a5655c29-f468-4cfe-b040-af7c85829df1/1c04ba59-968e-4e10-b2f1-d1bda8ebba5d]
Apply complete! Resources: 5 added, 0 changed, 0 destroyed.
(base) wsiew@Williams-MacBook-Pro ibm-key-protect % terraform apply
ibm_resource_instance.kp_instance: Refreshing state... [id=crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1::]
ibm_kms_key_rings.key_ring: Refreshing state... [id=key-ring-id:keyRing:crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1::]
ibm_kms_instance_policies.instance_policy: Refreshing state... [id=crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1::]
ibm_kms_key.key_part_of_key_ring: Refreshing state... [id=crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1:key:c00e6305-4edf-42f5-bb1d-17ebb4cca6ca]
ibm_kms_kmip_adapter.adapter1: Refreshing state... [id=a5655c29-f468-4cfe-b040-af7c85829df1/1c04ba59-968e-4e10-b2f1-d1bda8ebba5d]
No changes. Your infrastructure matches the configuration.
Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
(base) wsiew@Williams-MacBook-Pro ibm-key-protect % terraform destroy
ibm_resource_instance.kp_instance: Refreshing state... [id=crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1::]
ibm_kms_key_rings.key_ring: Refreshing state... [id=key-ring-id:keyRing:crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1::]
ibm_kms_instance_policies.instance_policy: Refreshing state... [id=crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1::]
ibm_kms_key.key_part_of_key_ring: Refreshing state... [id=crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1:key:c00e6305-4edf-42f5-bb1d-17ebb4cca6ca]
ibm_kms_kmip_adapter.adapter1: Refreshing state... [id=a5655c29-f468-4cfe-b040-af7c85829df1/1c04ba59-968e-4e10-b2f1-d1bda8ebba5d]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
- destroy
Terraform will perform the following actions:
# ibm_kms_instance_policies.instance_policy will be destroyed
- resource "ibm_kms_instance_policies" "instance_policy" {
- id = "crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1::" -> null
- instance_id = "a5655c29-f468-4cfe-b040-af7c85829df1" -> null
- dual_auth_delete {
- created_by = "IBMid-6620028GBG" -> null
- creation_date = "2024-05-14 20:42:57 +0000 UTC" -> null
- enabled = false -> null
- last_updated = "2024-05-14 20:42:57 +0000 UTC" -> null
- updated_by = "IBMid-6620028GBG" -> null
}
- key_create_import_access {
- create_root_key = true -> null
- create_standard_key = true -> null
- created_by = "IBMid-6620028GBG" -> null
- creation_date = "2024-05-14 20:42:57 +0000 UTC" -> null
- enabled = true -> null
- enforce_token = false -> null
- import_root_key = true -> null
- import_standard_key = true -> null
- last_updated = "2024-05-14 20:42:57 +0000 UTC" -> null
- updated_by = "IBMid-6620028GBG" -> null
}
- metrics {
- created_by = "IBMid-6620028GBG" -> null
- creation_date = "2024-05-14 20:42:57 +0000 UTC" -> null
- enabled = true -> null
- last_updated = "2024-05-14 20:42:57 +0000 UTC" -> null
- updated_by = "IBMid-6620028GBG" -> null
}
- rotation {
- created_by = "IBMid-6620028GBG" -> null
- creation_date = "2024-05-14 20:42:57 +0000 UTC" -> null
- enabled = true -> null
- interval_month = 3 -> null
- last_updated = "2024-05-14 20:42:57 +0000 UTC" -> null
- updated_by = "IBMid-6620028GBG" -> null
}
}
# ibm_kms_key.key_part_of_key_ring will be destroyed
- resource "ibm_kms_key" "key_part_of_key_ring" {
- crn = "crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1:key:c00e6305-4edf-42f5-bb1d-17ebb4cca6ca" -> null
- endpoint_type = "public" -> null
- force_delete = false -> null
- id = "crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1:key:c00e6305-4edf-42f5-bb1d-17ebb4cca6ca" -> null
- instance_crn = "crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1::" -> null
- instance_id = "a5655c29-f468-4cfe-b040-af7c85829df1" -> null
- key_id = "c00e6305-4edf-42f5-bb1d-17ebb4cca6ca" -> null
- key_name = "key_part_of_key_ring" -> null
- key_ring_id = "key-ring-id" -> null
- registrations = [] -> null
- resource_controller_url = "https://cloud.ibm.com/services/kms/crn%3Av1%3Abluemix%3Apublic%3Akms%3Aus-south%3Aa%2Feba0f7b1166e441ab74ac94e564c72ec%3Aa5655c29-f468-4cfe-b040-af7c85829df1%3A%3A" -> null
- resource_crn = "crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1:key:c00e6305-4edf-42f5-bb1d-17ebb4cca6ca" -> null
- resource_name = "key_part_of_key_ring" -> null
- resource_status = "1" -> null
- standard_key = false -> null
- type = "kms" -> null
}
# ibm_kms_key_rings.key_ring will be destroyed
- resource "ibm_kms_key_rings" "key_ring" {
- endpoint_type = "public" -> null
- force_delete = false -> null
- id = "key-ring-id:keyRing:crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1::" -> null
- instance_id = "a5655c29-f468-4cfe-b040-af7c85829df1" -> null
- key_ring_id = "key-ring-id" -> null
}
# ibm_kms_kmip_adapter.adapter1 will be destroyed
- resource "ibm_kms_kmip_adapter" "adapter1" {
- created_at = "2024-05-14 20:42:59 +0000 UTC" -> null
- created_by = "IBMid-6620028GBG" -> null
- description = "adding a description" -> null
- id = "a5655c29-f468-4cfe-b040-af7c85829df1/1c04ba59-968e-4e10-b2f1-d1bda8ebba5d" -> null
- instance_id = "a5655c29-f468-4cfe-b040-af7c85829df1" -> null
- name = "kmip_adapter_QadGAl" -> null
- profile = "native_1.0" -> null
- profile_data = {
- "crk_id" = "c00e6305-4edf-42f5-bb1d-17ebb4cca6ca"
} -> null
- updated_at = "2024-05-14 20:42:59 +0000 UTC" -> null
- updated_by = "IBMid-6620028GBG" -> null
}
# ibm_resource_instance.kp_instance will be destroyed
- resource "ibm_resource_instance" "kp_instance" {
- account_id = "eba0f7b1166e441ab74ac94e564c72ec" -> null
- allow_cleanup = false -> null
- created_at = "2024-05-14T20:42:44.496Z" -> null
- created_by = "IBMid-6620028GBG" -> null
- crn = "crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1::" -> null
- dashboard_url = "/keyprotect/crn%3Av1%3Abluemix%3Apublic%3Akms%3Aus-south%3Aa%2Feba0f7b1166e441ab74ac94e564c72ec%3Aa5655c29-f468-4cfe-b040-af7c85829df1%3A%3A" -> null
- extensions = {
- "endpoints.private" = "https://private.us-south.kms.cloud.ibm.com"
- "endpoints.public" = "https://us-south.kms.cloud.ibm.com"
} -> null
- guid = "a5655c29-f468-4cfe-b040-af7c85829df1" -> null
- id = "crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1::" -> null
- last_operation = {
- "async" = "false"
- "cancelable" = "false"
- "description" = "Completed create instance operation"
- "poll" = "false"
- "state" = "succeeded"
- "type" = "create"
} -> null
- location = "us-south" -> null
- locked = false -> null
- name = "wsiew-2024-may" -> null
- plan = "tiered-pricing" -> null
- plan_history = [
- {
- resource_plan_id = "eedd3585-90c6-4c8f-be3d-062069e99fc3"
- start_date = "2024-05-14T20:42:44.496Z"
},
] -> null
- resource_aliases_url = "/v2/resource_instances/a5655c29-f468-4cfe-b040-af7c85829df1/resource_aliases" -> null
- resource_bindings_url = "/v2/resource_instances/a5655c29-f468-4cfe-b040-af7c85829df1/resource_bindings" -> null
- resource_controller_url = "https://cloud.ibm.com/services/" -> null
- resource_crn = "crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1::" -> null
- resource_group_crn = "crn:v1:bluemix:public:resource-controller::a/eba0f7b1166e441ab74ac94e564c72ec::resource-group:f956c41a82d1436fbbf68f418f831c05" -> null
- resource_group_id = "f956c41a82d1436fbbf68f418f831c05" -> null
- resource_group_name = "crn:v1:bluemix:public:resource-controller::a/eba0f7b1166e441ab74ac94e564c72ec::resource-group:f956c41a82d1436fbbf68f418f831c05" -> null
- resource_id = "ee41347f-b18e-4ca6-bf80-b5467c63f9a6" -> null
- resource_keys_url = "/v2/resource_instances/a5655c29-f468-4cfe-b040-af7c85829df1/resource_keys" -> null
- resource_name = "wsiew-2024-may" -> null
- resource_plan_id = "eedd3585-90c6-4c8f-be3d-062069e99fc3" -> null
- resource_status = "active" -> null
- service = "kms" -> null
- state = "active" -> null
- status = "active" -> null
- sub_type = "kms" -> null
- tags = [] -> null
- target_crn = "crn:v1:bluemix:public:globalcatalog::::deployment:eedd3585-90c6-4c8f-be3d-062069e99fc3%3Aus-south" -> null
- type = "service_instance" -> null
- update_at = "2024-05-14T20:42:44.854Z" -> null
}
Plan: 0 to add, 0 to change, 5 to destroy.
Do you really want to destroy all resources?
Terraform will destroy all your managed infrastructure, as shown above.
There is no undo. Only 'yes' will be accepted to confirm.
Enter a value: yes
ibm_kms_kmip_adapter.adapter1: Destroying... [id=a5655c29-f468-4cfe-b040-af7c85829df1/1c04ba59-968e-4e10-b2f1-d1bda8ebba5d]
ibm_kms_instance_policies.instance_policy: Destroying... [id=crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1::]
ibm_kms_instance_policies.instance_policy: Destruction complete after 0s
ibm_kms_kmip_adapter.adapter1: Destruction complete after 1s
ibm_kms_key.key_part_of_key_ring: Destroying... [id=crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1:key:c00e6305-4edf-42f5-bb1d-17ebb4cca6ca]
ibm_kms_key.key_part_of_key_ring: Destruction complete after 1s
ibm_kms_key_rings.key_ring: Destroying... [id=key-ring-id:keyRing:crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1::]
ibm_kms_key_rings.key_ring: Destruction complete after 0s
ibm_resource_instance.kp_instance: Destroying... [id=crn:v1:bluemix:public:kms:us-south:a/eba0f7b1166e441ab74ac94e564c72ec:a5655c29-f468-4cfe-b040-af7c85829df1::]
ibm_resource_instance.kp_instance: Still destroying... [id=crn:v1:bluemix:public:kms:us-south:a/eb...a5655c29-f468-4cfe-b040-af7c85829df1::, 10s elapsed]
ibm_resource_instance.kp_instance: Destruction complete after 11s
Destroy complete! Resources: 5 destroyed.
TODO:
So in the earlier PR, there was mention of the internal IDs for tf not including the hierarchy. This will be need to be changed.
We have adapters which follow instance-id/adapter-id We have certs which follow instance-id/adapter-id/cert-id certs should also be able to use adapter name for cert operations(which is already there) but must set the ID correctly
To test:
Nevermind, there seems to be an interesting behavior where for Computed fields, they don't count them under ExactlyOne, ~~
Notice the usage of ExactlyOneOf was not working as I was able specify both name and id for data source
<= data "ibm_kms_kmip_adapter" "myadapter_byname" {
+ adapter_id = "abc"
+ created_at = (known after apply)
+ created_by = (known after apply)
+ description = (known after apply)
+ endpoint_type = (known after apply)
+ id = (known after apply)
+ instance_id = "67d241f5-a9b8-442a-ae48-930143406336"
+ name = (known after apply)
+ profile = (known after apply)
+ profile_data = (known after apply)
+ updated_at = (known after apply)
+ updated_by = (known after apply)
}
data "ibm_kms_kmip_adapter" "myadapter_byname" {
instance_id = ibm_resource_instance.kp_instance.guid
name = ibm_kms_kmip_adapter.adapter1.name
adapter_id = "abc"
}
terraform import results for upcoming push
(base) wsiew@Williams-MacBook-Pro ibm-key-protect % terraform import ibm_kms_kmip_client_cert.tf_import_cert bb15f9c8-44d8-4ca6-a8b6-0bb091c811a0/45e03e0e-ff20-42b1-a759-52770d8e3dc1/986194f1-4872-46e6-84ed-6a2114e210d5
ibm_kms_kmip_client_cert.tf_import_cert: Importing from ID "bb15f9c8-44d8-4ca6-a8b6-0bb091c811a0/45e03e0e-ff20-42b1-a759-52770d8e3dc1/986194f1-4872-46e6-84ed-6a2114e210d5"...
ibm_kms_kmip_client_cert.tf_import_cert: Import prepared!
Prepared ibm_kms_kmip_client_cert for import
ibm_kms_kmip_client_cert.tf_import_cert: Refreshing state... [id=bb15f9c8-44d8-4ca6-a8b6-0bb091c811a0/45e03e0e-ff20-42b1-a759-52770d8e3dc1/986194f1-4872-46e6-84ed-6a2114e210d5]
Import successful!
The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
statefile:
{
"mode": "managed",
"type": "ibm_kms_kmip_client_cert",
"name": "tf_import_cert",
"provider": "provider[\"registry.terraform.io/ibm-cloud/ibm\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"adapter_id": "45e03e0e-ff20-42b1-a759-52770d8e3dc1",
"cert_id": "986194f1-4872-46e6-84ed-6a2114e210d5",
"certificate": "-----BEGIN CERTIFICATE-----\nMIIFRjCCAy4CCQDLhALhY/GxHzANBgkqhkiG9w0BAQsFADBlMQswCQYDVQQGEwJY\nWDELMAkGA1UECAwCVFgxDzANBgNVBAcMBkF1c3RpbjEMMAoGA1UECgwDSUJNMQsw\nCQYDVQQLDAJLUDEdMBsGA1UEAwwUQ29tbW9uTmFtZU9ySG9zdG5hbWUwHhcNMjQw\nNTE2MTYwMDU1WhcNMjQwNTE3MTYwMDU1WjBlMQswCQYDVQQGEwJYWDELMAkGA1UE\nCAwCVFgxDzANBgNVBAcMBkF1c3RpbjEMMAoGA1UECgwDSUJNMQswCQYDVQQLDAJL\nUDEdMBsGA1UEAwwUQ29tbW9uTmFtZU9ySG9zdG5hbWUwggIiMA0GCSqGSIb3DQEB\nAQUAA4ICDwAwggIKAoICAQDeRGmfE5xJtV5DtaYRPGaUTVqUufUvF1rTHPRABnjg\nqbOA+yKj69GelD1zrYQVO0evxssU/crloKa6P2vcPr0CiLDCjI3F348DC4FFDgGM\nGX1iKPCG5cjCSSJHetYeFaJ24K+f0MNGLj9XnxKeTVFYk+oNCpvPIk2ynVf0MSoY\nj9R1U2shOxzRGX0whT19Hwacp+KYehnV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K1ebwsv3t6eO66\nUl+6AaT+iYHPCO8dvOGyWlitKsJ9c6NKWAsjpWpLp5HVNJoBZU4/k0y/HrR4ask9\ncBq+7cVSwDQAuxhIIKHqgAOR6YLylKq95+4IzibMTsiIclPz7xzTQpg0/Rx906mp\nMrArCJT5vgm/3w==\n-----END CERTIFICATE-----",
"created_at": "2024-05-16 16:01:03 +0000 UTC",
"created_by": "IBMid-6620028GBG",
"endpoint_type": "public",
"id": "bb15f9c8-44d8-4ca6-a8b6-0bb091c811a0/45e03e0e-ff20-42b1-a759-52770d8e3dc1/986194f1-4872-46e6-84ed-6a2114e210d5",
"instance_id": "bb15f9c8-44d8-4ca6-a8b6-0bb091c811a0",
"name": "as"
},
"sensitive_attributes": [],
"private": "eyJzY2hlbWFfdmVyc2lvbiI6IjAifQ=="
}
]
},
(base) wsiew@Williams-MacBook-Pro ibm-key-protect % terraform state rm ibm_kms_kmip_client_cert.tf_import_certRemoved ibm_kms_kmip_client_cert.tf_import_cert
Successfully removed 1 resource instance(s).
for adapters
(base) wsiew@Williams-MacBook-Pro ibm-key-protect % terraform import ibm_kms_kmip_adapter.tf_import_adapter bb15f9c8-44d8-4ca6-a8b6-0bb091c811a0/45e03e0e-ff20-42b1-a759-52770d8e3dc1
ibm_kms_kmip_adapter.tf_import_adapter: Importing from ID "bb15f9c8-44d8-4ca6-a8b6-0bb091c811a0/45e03e0e-ff20-42b1-a759-52770d8e3dc1"...
ibm_kms_kmip_adapter.tf_import_adapter: Import prepared!
Prepared ibm_kms_kmip_adapter for import
ibm_kms_kmip_adapter.tf_import_adapter: Refreshing state... [id=bb15f9c8-44d8-4ca6-a8b6-0bb091c811a0/45e03e0e-ff20-42b1-a759-52770d8e3dc1]
Import successful!
The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
(base) wsiew@Williams-MacBook-Pro ibm-key-protect %
statefile:
{
"mode": "managed",
"type": "ibm_kms_kmip_adapter",
"name": "tf_import_adapter",
"provider": "provider[\"registry.terraform.io/ibm-cloud/ibm\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"adapter_id": "45e03e0e-ff20-42b1-a759-52770d8e3dc1",
"created_at": "2024-05-16 15:44:21 +0000 UTC",
"created_by": "IBMid-6620028GBG",
"description": "",
"endpoint_type": "public",
"id": "bb15f9c8-44d8-4ca6-a8b6-0bb091c811a0/45e03e0e-ff20-42b1-a759-52770d8e3dc1",
"instance_id": "bb15f9c8-44d8-4ca6-a8b6-0bb091c811a0",
"name": "kmip_adapter_IvWHAI",
"profile": "native_1.0",
"profile_data": {
"crk_id": "e9a935ef-4190-4465-a2aa-520a1336d592"
},
"updated_at": "2024-05-16 15:44:21 +0000 UTC",
"updated_by": "IBMid-6620028GBG"
},
"sensitive_attributes": [],
"private": "eyJzY2hlbWFfdmVyc2lvbiI6IjAifQ=="
}
]
},
delete:
(base) wsiew@Williams-MacBook-Pro ibm-key-protect % terraform state rm ibm_kms_kmip_adapter.tf_import_adapter
Removed ibm_kms_kmip_adapter.tf_import_adapter
Successfully removed 1 resource instance(s).
validate against import by name
(base) wsiew@Williams-MacBook-Pro ibm-key-protect % terraform import ibm_kms_kmip_client_cert.tf_import_cert bb15f9c8-44d8-4ca6-a8b6-0bb091c811a0/kmip_adapter_IvWHAI/986194f1-4872-46e6-84ed-6a2114e210d5
ibm_kms_kmip_client_cert.tf_import_cert: Importing from ID "bb15f9c8-44d8-4ca6-a8b6-0bb091c811a0/kmip_adapter_IvWHAI/986194f1-4872-46e6-84ed-6a2114e210d5"...
ibm_kms_kmip_client_cert.tf_import_cert: Import prepared!
Prepared ibm_kms_kmip_client_cert for import
ibm_kms_kmip_client_cert.tf_import_cert: Refreshing state... [id=bb15f9c8-44d8-4ca6-a8b6-0bb091c811a0/kmip_adapter_IvWHAI/986194f1-4872-46e6-84ed-6a2114e210d5]
╷
│ Error: [ERROR] The given id kmip_adapter_IvWHAI at index 1 of instance_id/adapter_id/cert_id is not a valid UUID
│
│
tested existing resources manually here for data sources and resouces .tf file
resource "ibm_resource_instance" "kms_instance" {
name = "instance-name"
service = "kms"
plan = "tiered-pricing"
location = "us-south"
}
resource "ibm_kms_key" "key" {
instance_id = ibm_resource_instance.kms_instance.guid
key_name = "key"
standard_key = false
}
resource "ibm_kms_kmip_adapter" "myadapter" {
instance_id = ibm_resource_instance.kms_instance.guid
profile = "native_1.0"
profile_data = {
"crk_id" = ibm_kms_key.key.key_id,
}
# description = "adding a description"
name = "wakaka"
}
data "ibm_kms_kmip_adapter" "myadapter_byname" {
instance_id = ibm_resource_instance.kms_instance.guid
name = ibm_kms_kmip_adapter.myadapter.name
}
data "ibm_kms_kmip_adapter" "myadapter_byid" {
instance_id = ibm_resource_instance.kms_instance.guid
adapter_id = ibm_kms_kmip_adapter.myadapter.adapter_id
}
resource "ibm_kms_kmip_client_cert" "mycert" {
instance_id = ibm_resource_instance.kms_instance.guid
adapter_id = ibm_kms_kmip_adapter.myadapter.adapter_id
certificate = "-----BEGIN CERTIFICATE-----\nMIIFRjCCAy4CCQDJeOJTTzej7DANBgkqhkiG9w0BAQsFADBlMQswCQYDVQQGEwJY\nWDELMAkGA1UECAwCVFgxDzANBgNVBAcMBkF1c3RpbjEMMAoGA1UECgwDSUJNMQsw\nCQYDVQQLDAJLUDEdMBsGA1UEAwwUQ29tbW9uTmFtZU9ySG9zdG5hbWUwHhcNMjQw\nNTE2MjEyMTA0WhcNMjQwNTE3MjEyMTA0WjBlMQswCQYDVQQGEwJYWDELMAkGA1UE\nCAwCVFgxDzANBgNVBAcMBkF1c3RpbjEMMAoGA1UECgwDSUJNMQswCQYDVQQLDAJL\nUDEdMBsGA1UEAwwUQ29tbW9uTmFtZU9ySG9zdG5hbWUwggIiMA0GCSqGSIb3DQEB\nAQUAA4ICDwAwggIKAoICAQDJjbVxUYBhQRoknc4Ov9b98GFStRuBgw3sL/r/iNpE\nCMmqf+a92zgvwQVx2yGU8TXMkDJf8K6CT5JiUQYzpa11/o4j4gwmVx2zGT7M8Yh6\nOivh4RVcoH+H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StpOj97SYfyZ14avRflkjkcfwZpQp\nMPZaGxwpCSjbg4JRJPAE1F9E9Ui6uLahIlPMcrnViuBDcX3HNogIx7HCdBqaW+7a\nbNJuh8enpWdZboUc3ONQCSs8XE/5gxxHmf1KAYlhv5LRwR/PEfE3Emnu3WfBOZCn\noQryQhfiCXj5MFPAfBU8GbS+Jlz8kK2PWAzYLA0HwZsdTyO6QQ9vOH176adT/DRL\n2r8evBdH8svVWg==\n-----END CERTIFICATE-----"
name = "ayay"
}
data "ibm_kms_kmip_client_cert" "mycert_byname" {
instance_id = ibm_resource_instance.kms_instance.guid
adapter_name = ibm_kms_kmip_adapter.myadapter.name
name = ibm_kms_kmip_client_cert.mycert.name
}
data "ibm_kms_kmip_client_cert" "mycert_byid" {
instance_id = ibm_resource_instance.kms_instance.guid
adapter_id = ibm_kms_kmip_adapter.myadapter.adapter_id
cert_id = ibm_kms_kmip_client_cert.mycert.cert_id
}
state file after apply
Changelog as a followup PR:
Meant as a followup to this as I do not have access to original branch owners fork
https://github.com/IBM-Cloud/terraform-provider-ibm/pull/5322
Community Note
Relates OR Closes #0000
Output from acceptance testing: