Skip to content

Commit b58f75f

Browse files
authored
added support for flex shape (#14)
1 parent d7daa24 commit b58f75f

File tree

5 files changed

+42
-11
lines changed

5 files changed

+42
-11
lines changed

compute.tf

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
resource "oci_core_instance" "bastion" {
55
availability_domain = element(local.ad_names, (var.availability_domain - 1))
66
compartment_id = var.compartment_id
7-
freeform_tags = var.tags
7+
freeform_tags = var.tags
88

99
create_vnic_details {
1010
assign_public_ip = true
@@ -15,6 +15,10 @@ resource "oci_core_instance" "bastion" {
1515

1616
display_name = var.label_prefix == "none" ? "bastion" : "${var.label_prefix}-bastion"
1717

18+
launch_options {
19+
network_type = "PARAVIRTUALIZED"
20+
}
21+
1822
# prevent the bastion from destroying and recreating itself if the image ocid changes
1923
lifecycle {
2024
ignore_changes = [source_details[0].source_id]
@@ -25,11 +29,20 @@ resource "oci_core_instance" "bastion" {
2529
user_data = data.template_cloudinit_config.bastion[0].rendered
2630
}
2731

28-
shape = var.bastion_shape
32+
shape = lookup(var.bastion_shape, "shape", "VM.Standard.E2.2")
33+
34+
dynamic "shape_config" {
35+
for_each = length(regexall("Flex", lookup(var.bastion_shape, "shape", "VM.Standard.E3.Flex"))) > 0 ? [1] : []
36+
content {
37+
ocpus = max(1, lookup(var.bastion_shape, "ocpus", 1))
38+
memory_in_gbs = (lookup(var.bastion_shape, "memory", 4) / lookup(var.bastion_shape, "ocpus", 1)) > 64 ? (lookup(var.bastion_shape, "ocpus", 1) * 4) : lookup(var.bastion_shape, "memory", 4)
39+
}
40+
}
2941

3042
source_details {
31-
source_type = "image"
32-
source_id = local.bastion_image_id
43+
boot_volume_size_in_gbs = lookup(var.bastion_shape, "boot_volume_size", 50)
44+
source_type = "image"
45+
source_id = local.bastion_image_id
3346
}
3447

3548
timeouts {

datasources.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ data "template_file" "autonomous_cloud_init_file" {
5151
data "oci_core_images" "autonomous_images" {
5252
compartment_id = var.compartment_id
5353
operating_system = "Oracle Autonomous Linux"
54-
shape = var.bastion_shape
54+
shape = lookup(var.bastion_shape, "shape", "VM.Standard.E2.2")
5555
sort_by = "TIMECREATED"
5656
}
5757

docs/terraformoptions.adoc

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,19 @@ Ensure you review the {uri-terraform-dependencies}[dependencies].
139139
|Autonomous
140140

141141
|`bastion_shape`
142-
|The shape of bastion instance.
143-
|e.g. VM.Standard.E2.2
144-
|VM.Standard.E2.2
142+
|The shape of bastion instance. This is now specified as a map and supports E3.Flex. If a non-Flex shape is specified, then the other parameters are ignored.
143+
|e.g. `bastion_shape = {
144+
shape="VM.Standard.E3.Flex",
145+
ocpus=1,
146+
memory=4,
147+
boot_volume_size=50
148+
}`
149+
|`bastion_shape = {
150+
shape="VM.Standard.E3.Flex",
151+
ocpus=1,
152+
memory=4,
153+
boot_volume_size=50
154+
}`
145155

146156
|`bastion_upgrade`
147157
|Whether to upgrade the bastion host packages after provisioning. It's useful to set this to false during development/testing so the bastion is provisioned faster.

terraform.tfvars.example

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ bastion_enabled = true
3737

3838
bastion_image_id = "Autonomous"
3939

40-
bastion_shape = "VM.Standard.E2.2"
40+
bastion_shape = {
41+
# shape = "VM.Standard.E2.2"
42+
shape="VM.Standard.E3.Flex",
43+
ocpus=1,
44+
memory=4,
45+
boot_volume_size=50
46+
}
4147

4248
bastion_upgrade = false
4349

variables.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ variable "bastion_image_id" {
9797

9898
variable "bastion_shape" {
9999
description = "The shape of bastion instance."
100-
default = "VM.Standard.E2.2"
101-
type = string
100+
default = {
101+
shape = "VM.Standard.E3.Flex", ocpus = 1, memory = 4, boot_volume_size = 50
102+
}
103+
type = map(any)
102104
}
103105

104106
variable "bastion_upgrade" {

0 commit comments

Comments
 (0)