Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for instance_state (RUNNING or STOPPED). #79

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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