oracle-terraform-modules/terraform-oci-bastion

issue with bastion images

rabihch opened this issue · 4 comments

Hello
anyone has an idea the causing of the following error?
Thank you

Error: Invalid index

on ../../../../equisoft.***.registry/oci/modules/bastion/compute.tf line 65, in resource "oci_core_instance" "bastion":
65: source_id = lookup(data.oci_core_images.bastion_images.images[0], "id")
|----------------
| data.oci_core_images.bastion_images.images is empty list of object

The given key does not identify an element in this collection value.

Error: Invalid index

on ../../../../eqt.***.registry/oci/modules/bastion/compute.tf line 65, in resource "oci_core_instance" "bastion":
65: source_id = lookup(data.oci_core_images.bastion_images.images[0], "id")
|----------------
| data.oci_core_images.bastion_images.images is empty list of object

The given key does not identify an element in this collection value.

Error: Invalid index

on ../../../../eqft.***.registry/oci/modules/compute/computes.tf line 62, in resource "oci_core_instance" "compute":
62: source_id = lookup(data.oci_core_images.getImages[count.index].images[0], "id")
|----------------
| count.index is 0
| data.oci_core_images.getImages is tuple with 1 element

The given key does not identify an element in this collection value.

##[error]Bash exited with code '1'.
##[error]Bash wrote one or more lines to the standard error stream.
##[error]
Error: Invalid index

##[error] on ../../../../eqft.***.registry/oci/modules/bastion/compute.tf line 65, in resource "oci_core_instance" "bastion":

##[error] 65: source_id = lookup(data.oci_core_images.bastion_images.images[0], "id")
|----------------
| data.oci_core_images.bastion_images.images is empty list of object

The given key does not identify an element in this collection value.

hyder commented

Hi,

Sorry for the late reply. Can you please try with latest release (2.1.0): https://github.com/oracle-terraform-modules/terraform-oci-bastion/releases/tag/v2.1.0

We've added ability to specify OS version

Hello Ali,
Thanks for your reply... well after some investigating I found that Oracle Autonomous Linux 7.8 is not available on OCI, but the image ocid can still be found on ocid images, but the data source try to get the data from oci didn't find the 7.8 ( I guess), but the problem now, if I change to 7.9 , it will destory all my instances!!! while I already added the :
lifecycle {
ignore_changes = [
source_details[0].source_id,
metadata
]
}
So is there a way to preserve the current VM images without destroying, even if the version 7.8 is not available or the image changed?

Thank you,

hyder commented

So, if I understand correctly, you want to keep a platform image even if the compute service has pulled it out?

yes exactly,
I have about 16 instances with the same image, so it is somek how hard and time consuming to destroy them, restore and don't know what may happen too....so I was wondering how can tell terraform to ignore them.
I change some command in lifecycle and I got the following with the plan:
Resource module.bastion.oci_core_instance.bastion[0] has
│ lifecycle.prevent_destroy set, but the plan calls for this resource to be
│ destroyed. To avoid this error and continue with the plan, either disable
│ lifecycle.prevent_destroy or reduce the scope of the plan using the -target
│ flag.

Thanks