Skip to content

Commit

Permalink
feat: add support for instance_state (RUNNING or STOPPED) (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
kral2 authored Oct 25, 2021
1 parent 6653f7b commit 5493523
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/terraformoptions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@
|`null`
|no

|[[input_instance_state]] <<input_instance_state,instance_state>>
|(Updatable) The target state for the instance. Could be set to RUNNING or STOPPED.
|`string`
|`"RUNNING"`
|no

|[[input_instance_timeout]] <<input_instance_timeout,instance_timeout>>
|Timeout setting for creating instance.
|`string`
Expand Down
4 changes: 3 additions & 1 deletion examples/instances_fixed_shape/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module "instance_nonflex" {
ad_number = var.instance_ad_number
instance_count = var.instance_count
instance_display_name = var.instance_display_name
instance_state = var.instance_state
shape = var.shape
source_ocid = var.source_ocid
source_type = var.source_type
Expand Down Expand Up @@ -57,7 +58,8 @@ module "instance_nonflex_custom" {
# compute instance parameters
ad_number = var.instance_ad_number
instance_count = var.instance_count
instance_display_name = "instance_nonflex_custom"
instance_display_name = "module_instance_nonflex_custom"
instance_state = var.instance_state
shape = var.shape
source_ocid = var.source_ocid
source_type = var.source_type
Expand Down
1 change: 1 addition & 0 deletions examples/instances_fixed_shape/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ compartment_ocid = "<compartment OCID>"
# compute instance parameters

source_ocid = "<The OCID of an image or a boot volume>"
instance_state = "RUNNING"

# operating system parameters

Expand Down
11 changes: 11 additions & 0 deletions examples/instances_fixed_shape/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ variable "instance_flex_ocpus" {
default = null
}

variable "instance_state" {
type = string
description = "(Updatable) The target state for the instance. Could be set to RUNNING or STOPPED."
default = "RUNNING"

validation {
condition = contains(["RUNNING", "STOPPED"], var.instance_state)
error_message = "Accepted values are RUNNING or STOPPED."
}
}

variable "shape" {
description = "The shape of an instance."
type = string
Expand Down
2 changes: 2 additions & 0 deletions examples/instances_flex_shape/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module "instance_flex" {
ad_number = var.instance_ad_number
instance_count = var.instance_count
instance_display_name = var.instance_display_name
instance_state = var.instance_state
shape = var.shape
source_ocid = var.source_ocid
source_type = var.source_type
Expand Down Expand Up @@ -60,6 +61,7 @@ output "instance_flex" {
# ad_number = null
# instance_count = 4
# instance_display_name = "instance_flex_custom"
# instance_state = var.instance_state
# shape = var.shape
# source_ocid = var.source_ocid
# source_type = var.source_type
Expand Down
1 change: 1 addition & 0 deletions examples/instances_flex_shape/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ compartment_ocid = "<compartment OCID>"
# compute instance parameters

source_ocid = "<The OCID of an image or a boot volume>"
instance_state = "RUNNING"

# operating system parameters

Expand Down
11 changes: 11 additions & 0 deletions examples/instances_flex_shape/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ variable "instance_flex_ocpus" {
default = null
}

variable "instance_state" {
type = string
description = "(Updatable) The target state for the instance. Could be set to RUNNING or STOPPED."
default = "RUNNING"

validation {
condition = contains(["RUNNING", "STOPPED"], var.instance_state)
error_message = "Accepted values are RUNNING or STOPPED."
}
}

variable "shape" {
description = "The shape of an instance."
type = string
Expand Down
1 change: 1 addition & 0 deletions examples/instances_reserved_public_ip/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module "instance_reserved_ip" {
ad_number = null
instance_count = 1
instance_display_name = "instance_reserved_ip"
instance_state = var.instance_state
shape = var.shape
source_ocid = var.source_ocid
source_type = var.source_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ compartment_ocid = "<compartment OCID>"
# compute instance parameters

source_ocid = "<The OCID of an image or a boot volume>"
instance_state = "RUNNING"

# operating system parameters

Expand Down
11 changes: 11 additions & 0 deletions examples/instances_reserved_public_ip/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ variable "instance_flex_ocpus" {
default = null
}

variable "instance_state" {
type = string
description = "(Updatable) The target state for the instance. Could be set to RUNNING or STOPPED."
default = "RUNNING"

validation {
condition = contains(["RUNNING", "STOPPED"], var.instance_state)
error_message = "Accepted values are RUNNING or STOPPED."
}
}

variable "shape" {
description = "The shape of an instance."
type = string
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ resource "oci_core_instance" "instance" {
extended_metadata = var.extended_metadata
ipxe_script = var.ipxe_script
preserve_boot_volume = var.preserve_boot_volume
state = var.instance_state
shape = var.shape
shape_config {
// If shape name contains ".Flex" and instance_flex inputs are not null, use instance_flex inputs values for shape_config block
Expand Down
11 changes: 11 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ variable "instance_flex_ocpus" {
default = null
}

variable "instance_state" {
type = string
description = "(Updatable) The target state for the instance. Could be set to RUNNING or STOPPED."
default = "RUNNING"

validation {
condition = contains(["RUNNING", "STOPPED"], var.instance_state)
error_message = "Accepted values are RUNNING or STOPPED."
}
}

variable "shape" {
description = "The shape of an instance."
type = string
Expand Down

0 comments on commit 5493523

Please sign in to comment.