Closed kral2 closed 3 years ago
@aorcl I reproduced the issue. It is due to how instance_count
and ad-specific subnets
are implemented in the current version of the module.
length(var.subnet_ocids) < 3 && length(var.subnet_ocids) < var.instance_count
With the current instance_count
implementation, the recommentations are the following:
var.instance_count
together, try to always declare as many subnets as the region have Availability Domains. In this situation, instances will always get affected a valid subnet ocid related to the ad they are affected.Plan is to probably deprecate var.instance_count
in a future release or go through a major refactoring.
There is better ways to handle multiple instances creation at once today than it was possible two years ago, using either Terraform new capabilities or OCI API new capabilities.
Some options:
for_each
inside the module on oci_core_instance
count
and for_each
on a moduleoci_core_instance_configuration
and oci_core_instance_pool
as they now support attaching and detaching instancesLet me know if if works for you.
It seems the issue is related to PR #46 Additional tests required to identify the exact conditions to reproduce the problem. My current tests successfully provision instances with count 1 to 6 all with public IPs, on regional subnets. Probably additional checks needed with ad-specific subnets.
Originally posted by @kral2 in https://github.com/oracle-terraform-modules/terraform-oci-compute-instance/issues/49#issuecomment-781216556