Skip to content

Commit 736b3a9

Browse files
authored
fix: build the shape list on the current AD (#88)
* fix: build the shape list on the current AD Signed-off-by: Andrea Marchesini <[email protected]>
1 parent c4c4ad0 commit 736b3a9

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

docs/terraformoptions.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
|https://registry.terraform.io/providers/hashicorp/oci/latest/docs/resources/core_volume_backup_policy_assignment[oci_core_volume_backup_policy_assignment.boot_volume_backup_policy] |resource
2727
|https://registry.terraform.io/providers/hashicorp/oci/latest/docs/data-sources/core_instance_credentials[oci_core_instance_credentials.credential] |data source
2828
|https://registry.terraform.io/providers/hashicorp/oci/latest/docs/data-sources/core_private_ips[oci_core_private_ips.private_ips] |data source
29-
|https://registry.terraform.io/providers/hashicorp/oci/latest/docs/data-sources/core_shapes[oci_core_shapes.ad1] |data source
29+
|https://registry.terraform.io/providers/hashicorp/oci/latest/docs/data-sources/core_shapes[oci_core_shapes.current_ad] |data source
3030
|https://registry.terraform.io/providers/hashicorp/oci/latest/docs/data-sources/core_subnet[oci_core_subnet.instance_subnet] |data source
3131
|https://registry.terraform.io/providers/hashicorp/oci/latest/docs/data-sources/core_vnic_attachments[oci_core_vnic_attachments.vnic_attachment] |data source
3232
|https://registry.terraform.io/providers/hashicorp/oci/latest/docs/data-sources/core_volume_backup_policies[oci_core_volume_backup_policies.default_backup_policies] |data source

main.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@ data "oci_core_subnet" "instance_subnet" {
4242
############
4343

4444
// Create a data source for compute shapes.
45-
// Filter on AD1 to remove duplicates. This should give all the shapes supported on the region.
45+
// Filter on current AD to remove duplicates and give all the shapes supported on the AD.
4646
// This will not check quota and limits for AD requested at resource creation
47-
data "oci_core_shapes" "ad1" {
47+
data "oci_core_shapes" "current_ad" {
4848
compartment_id = var.compartment_ocid
49-
availability_domain = local.ADs[0]
49+
availability_domain = local.ADs[(var.ad_number - 1)]
5050
}
5151

5252
locals {
5353
shapes_config = {
5454
// prepare data with default values for flex shapes. Used to populate shape_config block with default values
55-
// Iterate through data.oci_core_shapes.ad1.shapes (this exclude duplicate data in multi-ad regions) and create a map { name = { memory_in_gbs = "xx"; ocpus = "xx" } }
56-
for i in data.oci_core_shapes.ad1.shapes : i.name => {
55+
// Iterate through data.oci_core_shapes.current_ad.shapes (this exclude duplicate data in multi-ad regions) and create a map { name = { memory_in_gbs = "xx"; ocpus = "xx" } }
56+
for i in data.oci_core_shapes.current_ad.shapes : i.name => {
5757
"memory_in_gbs" = i.memory_in_gbs
5858
"ocpus" = i.ocpus
5959
}
@@ -77,7 +77,7 @@ resource "oci_core_instance" "instance" {
7777
shape = var.shape
7878
shape_config {
7979
// If shape name contains ".Flex" and instance_flex inputs are not null, use instance_flex inputs values for shape_config block
80-
// Else use values from data.oci_core_shapes.ad1 for var.shape
80+
// Else use values from data.oci_core_shapes.current_ad for var.shape
8181
memory_in_gbs = local.shape_is_flex == true && var.instance_flex_memory_in_gbs != null ? var.instance_flex_memory_in_gbs : local.shapes_config[var.shape]["memory_in_gbs"]
8282
ocpus = local.shape_is_flex == true && var.instance_flex_ocpus != null ? var.instance_flex_ocpus : local.shapes_config[var.shape]["ocpus"]
8383
}

0 commit comments

Comments
 (0)