From 8c32a68ad97ace574115f2e78fafe0ef84cf2ce1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87etin=20ARDAL?= Date: Sat, 13 Feb 2021 01:08:57 +0100 Subject: [PATCH] Add regional subnets support add Terraform and Provider minimum versions (> 0.12) change Block Volume default attachment type from iSCSI to paravirtualized remove boot volume custom default value in the module Documentation enhancement: Requirements, Providers, Inputs and Outputs tables in README are now autogenerated update README sample code for Terraform 0.12 syntax add description and type to module inputs Issue: #41 --- .gitignore | 10 +- CHANGELOG.md | 56 ++++- LICENSE.txt | 6 +- README.md | 228 ++++++++++-------- examples/instance_default/instance_default.tf | 26 +- examples/instance_default/outputs.tf | 10 +- main.tf | 31 ++- variables.tf | 101 +++++--- versions.tf | 4 - 9 files changed, 311 insertions(+), 161 deletions(-) delete mode 100644 versions.tf diff --git a/.gitignore b/.gitignore index 8e0a2df..1920aa0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,14 @@ .terraform terraform.tfstate *.tfstate* +*.lock terraform.tfvars +*.auto.tfvars .DS_Store -.idea \ No newline at end of file +.idea +.vscode + +tests + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 37f8670..975aae6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,28 +1,60 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and the versioning follows the [Semantic Versioning 2.0.0](https://semver.org/) specification. + +Given a version number MAJOR.MINOR.PATCH: + +- MAJOR version when making incompatible API changes, +- MINOR version when adding functionality in a backwards compatible manner, +- PATCH version when making backwards compatible bug fixes. + +## [UNRELEASED] + +### Changed + +- Terraform block now defines minimum terraform version and required providers. Block Moved to main.tf +- block volumes attachment type is now paravirtualized by default +- boot volume size default value is now passed by the service +- README content is automatically generated for the following sections: Requirements, Providers, Inputs, Outputs + +### Fixed + +Issue #41 - When regional subnets are used, the instance fails to detect the availability domain + +- Instance Domain selection do not rely on vnic AD anymore: use Data Source + a list local +- add var.ad_number, data.oci_identity_availability_domains.ad, local.ADs + +Documentation enhancement: + +- CHANGELOG format +- Sample code in the main README is now compliant with Terraform 0.12 syntax +- Missing description, type or default value for variables module inputs + ## 2.0.3 - 2021-01-31 ### Changed -* Upgrade to HCL2, for compatibility with Terraform 0.12 or higher -* Cleanup copyright notice statements in source files +- Upgrade to HCL2, for compatibility with Terraform 0.12 or higher +- Cleanup copyright notice statements in source files ## 2.0.2 - 2021-01-22 ### Added -* CONTRIBUTING.md - contributor's guide +- CONTRIBUTING.md - contributor's guide ### Changed -* Add link to CONTRIBUTING.md in README.md -* Bump copyright year to 2021 in README.md - +- Add link to CONTRIBUTING.md in README.md +- Bump copyright year to 2021 in README.md ## 2.0.1 - 2019-05-08 ### Changed -* v0.12 preparation: Fix metadata usage to be canonical - +- v0.12 preparation: Fix metadata usage to be canonical ## 2.0.0 - 2018-12-04 @@ -30,10 +62,10 @@ - Updated Hostname label for multiple compute instances - Updated Volume display name -- Changes variable assign_public_ip default from true to false +- Changes variable assign_public_ip default from true to false ### Added -* Support for multiple subnets -* Support for paravirtualized attachments -* Support for private IP list \ No newline at end of file +- Support for multiple subnets +- Support for paravirtualized attachments +- Support for private IP list diff --git a/LICENSE.txt b/LICENSE.txt index 83cca04..80585da 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -27,7 +27,7 @@ Apache License Version 2.0, January 2004 -http://www.apache.org/licenses/ +http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. @@ -46,9 +46,9 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION You must give any other recipients of the Work or Derivative Works a copy of this License; and You must cause any modified files to carry prominent notices stating that You changed the files; and You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and -If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. -You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. diff --git a/README.md b/README.md index 1e0275e..9a036f4 100644 --- a/README.md +++ b/README.md @@ -1,99 +1,129 @@ -# Oracle Cloud Infrastructure Compute Instance Terraform Module - -The Oracle Cloud Infrastructure Compute Instance Terraform Module provides an easy way to launch compute instances and optionally create and attach any number of block volumes. - -Please Note: - -* Oracle-provided images include firewall rules that restrict access to the boot and block volumes. Oracle recommends that you do not use custom images without these rules unless you understand the security risks. See [Compute Best Practices](https://docs.cloud.oracle.com/iaas/Content/Compute/References/bestpracticescompute.htm#two) for recommendations on how to manage instances. - -## Prerequisites - -See the [Oracle Cloud Infrastructure Terraform Provider docs](https://www.terraform.io/docs/providers/oci/index.html) for information about setting up and using the Oracle Cloud Infrastructure Terraform Provider. - -## How to use this module - -The [examples](https://github.com/oracle-terraform-modules/terraform-oci-compute-instance/tree/master/examples/instance_default) folder contains a detailed example that shows how to use this module. - -The following code example creates an Oracle Cloud Infrastructure compute instance: - -```hcl -module "instance" { - source = "oracle-terraform-modules/compute-instance/oci" - - compartment_ocid = "${var.compartment_ocid}" - instance_display_name = "${var.instance_display_name}" - source_ocid = "${var.source_ocid}" - subnet_ocids = "${var.subnet_ocids}" - ssh_authorized_keys = "${var.ssh_authorized_keys_file}" - block_storage_sizes_in_gbs = [60, 70] -} -``` - -**Following are arguments available to the Compute Instance module:** - -Argument | Description ---- | --- -compartment_ocid | Unique Oracle Cloud Identifier (OCID) of the compartment in which the VCN is created -instance_display_name | Display name of the compute instance -extended_metadata | Additional metadata key/value pairs provided by the user -ipxe_script | The iPXE script which initiates the boot process on the compute instance -preserve_boot_volume | Specifies whether to delete or preserve the boot volume when the instance is terminated -boot_volume_size_in_gbs | The size of the boot volume in GBs -shape | The instance shape -assign_public_ip | Specifies whether the VNIC should be assigned a public IP address -vnic_name | A user-friendly name for the VNIC -hostname_label | The hostname for the VNIC's primary private IP -private_ips | A list of private IP address of your choice to assign to the VNIC -skip_source_dest_check | Specifies whether the source/destination check is disabled on the VNIC -subnet_ocids | A list of the subnet OCIDs in which to place the instance's primary VNICs -ssh_authorized_keys | Path to the public SSH keys to place in the instance's **~/.ssh/authorized_keys** file for the default user on the instance -user_data | User-defined base64-encoded data to be used by `Cloud-Init` to run custom scripts, or provide a custom `Cloud-Init` configuration -source_ocid | Unique Oracle Cloud Identifier (OCID) of an image or a boot volume to use as source of instance creation, depending on the value of source_type. For more information, see [Oracle Cloud Infrastructure Images](https://docs.cloud.oracle.com/iaas/images/) -source_type | The source type for the instance -instance_timeout | Timeout setting for creating instance(Note: large instance types may need larger timeout than the default 25m) -instance_count | Number of instances to launch -block_storage_sizes_in_gbs | The size in GBs of block volumes created and attached to each instance -attachment_type | The type of volume attachment. Allowed values are: iscsi, paravirtualized -use_chap | Whether to use CHAP authentication for the volume attachment -resource_platform | Platform in which to create resources -vcn_ocid | Unique identifier (OCID) of the VCN - -## Windows remote scripts execution -Terraform supports using Windows Remote Management (WinRM) for connecting to Windows instances. Ensure that your Windows image has WinRM properly configured to allow remote access. Following is a sample WinRM configuration: - -```hcl -winrm quickconfig -q -winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="300"}’' -winrm set winrm/config ‘@{MaxTimeoutms=”1800000″}’ -winrm set winrm/config/service '@{AllowUnencrypted="true"}' -winrm set winrm/config/service/auth '@{Basic="true"}' - -netsh advfirewall firewall add rule name="WinRM 5985" protocol=TCP dir=in localport=5985 action=allow -netsh advfirewall firewall add rule name="WinRM 5986" protocol=TCP dir=in localport=5986 action=allow - -net stop winrm -sc.exe config winrm start=auto -net start winrm -``` - -## Configure iSCSI volume attachments -* For guidance configuring iSCSI on a Windows platform, see [Adding a Block Volume to a Windows Instance](https://docs.cloud.oracle.com/iaas/Content/GSG/Tasks/addingstorageForWindows.htm). - -* For guidance configuring iSCSI on a Linux platform, see [iSCSI Commands and Information](https://docs.cloud.oracle.com/iaas/Content/Block/Concepts/iscsiinformation.htm). See also this example of inline iSCSI commands execution using `iscsiadm` CLI called from terraform file: [instance.tf](https://github.com/terraform-providers/terraform-provider-oci/blob/master/examples/compute/instance/instance.tf). - - -## Contributing - -This project is open source. Oracle appreciates any contributions that are made by the open source community. - -Learn how to [contribute](CONTRIBUTING.md). - -[Folks who contributed with explanations, code, feedback, ideas, testing etc.](CONTRIBUTORS.md) - -## License - -Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. - -Licensed under the Universal Permissive License 1.0 or Apache License 2.0. - -See [LICENSE](https://github.com/oracle-terraform-modules/terraform-oci-compute-instance/blob/master/LICENSE.txt) for more details. +# Oracle Cloud Infrastructure Compute Instance Terraform Module + +The Oracle Cloud Infrastructure Compute Instance Terraform Module provides an easy way to launch compute instances and optionally create and attach any number of block volumes. + +Please Note: + +- Oracle-provided images include firewall rules that restrict access to the boot and block volumes. Oracle recommends that you do not use custom images without these rules unless you understand the security risks. See [Compute Best Practices](https://docs.cloud.oracle.com/iaas/Content/Compute/References/bestpracticescompute.htm#two) for recommendations on how to manage instances. + +## Prerequisites + +See the [Oracle Cloud Infrastructure Terraform Provider docs](https://www.terraform.io/docs/providers/oci/index.html) for information about setting up and using the Oracle Cloud Infrastructure Terraform Provider. + +## How to use this module + +The [examples](https://github.com/oracle-terraform-modules/terraform-oci-compute-instance/tree/master/examples/instance_default) folder contains a detailed example that shows how to use this module. + +The following code example creates an Oracle Cloud Infrastructure compute instance: + +```hcl +module "instance" { + source = "oracle-terraform-modules/compute-instance/oci" + instance_count = 1 # how many instances do you want? + ad_number = 1 # AD number to provision instances. If null, instances are provisionned in a rolling manner starting with AD1 + compartment_ocid = var.compartment_ocid + instance_display_name = var.instance_display_name + source_ocid = var.source_ocid + subnet_ocids = var.subnet_ocids + assign_public_ip = var.assign_public_ip + ssh_authorized_keys = var.ssh_authorized_keys_file + block_storage_sizes_in_gbs = [60, 70] + shape = var.shape +} +``` + + +## Requirements + +| Name | Version | +|------|---------| +| terraform | >= 0.12 | +| oci | >= 3.27 | + +## Providers + +| Name | Version | +|------|---------| +| oci | >= 3.27 | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| ad\_number | (Optional) The availability domain number of the instance. If none is provided, it will start with AD-1 and continue in round-robin. | `number` | `null` | no | +| assign\_public\_ip | Whether the VNIC should be assigned a public IP address. | `bool` | `false` | no | +| attachment\_type | (Optional) The type of volume. The only supported values are iscsi and paravirtualized. | `string` | `"paravirtualized"` | no | +| block\_storage\_sizes\_in\_gbs | Sizes of volumes to create and attach to each instance. | `list(number)` | `[]` | no | +| boot\_volume\_size\_in\_gbs | The size of the boot volume in GBs. | `number` | `null` | no | +| compartment\_ocid | (Required) (Updatable) The OCID of the compartment where to create all resources | `string` | n/a | yes | +| extended\_metadata | (Optional) (Updatable) Additional metadata key/value pairs that you provide. | `map(any)` | `{}` | no | +| hostname\_label | The hostname for the VNIC's primary private IP. | `string` | `""` | no | +| instance\_count | Number of instances to launch. | `number` | `1` | no | +| instance\_display\_name | (Optional) (Updatable) A user-friendly name for the instance. Does not have to be unique, and it's changeable. | `string` | `""` | no | +| instance\_timeout | Timeout setting for creating instance. | `string` | `"25m"` | no | +| ipxe\_script | (Optional) The iPXE script which to continue the boot process on the instance. | `string` | `null` | no | +| preserve\_boot\_volume | Specifies whether to delete or preserve the boot volume when terminating an instance. | `bool` | `false` | no | +| private\_ips | Private IP addresses of your choice to assign to the VNICs. | `list(string)` | `[]` | no | +| resource\_platform | Platform to create resources in. | `string` | `"linux"` | no | +| shape | The shape of an instance. | `string` | `"VM.Standard2.1"` | no | +| skip\_source\_dest\_check | Whether the source/destination check is disabled on the VNIC. | `bool` | `false` | no | +| source\_ocid | The OCID of an image or a boot volume to use, depending on the value of source\_type. | `string` | n/a | yes | +| source\_type | The source type for the instance. | `string` | `"image"` | no | +| ssh\_authorized\_keys | Public SSH keys path to be included in the ~/.ssh/authorized\_keys file for the default user on the instance. | `string` | n/a | yes | +| subnet\_ocids | The unique identifiers (OCIDs) of the subnets in which the instance primary VNICs are created. | `list(string)` | n/a | yes | +| use\_chap | (Applicable when attachment\_type=iscsi) Whether to use CHAP authentication for the volume attachment. | `bool` | `false` | no | +| user\_data | Provide your own base64-encoded data to be used by Cloud-Init to run custom scripts or provide custom Cloud-Init configuration. | `string` | `null` | no | +| vnic\_name | A user-friendly name for the VNIC. | `string` | `""` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| instance\_id | ocid of created instances. | +| instance\_password | Passwords to login to Windows instance. | +| instance\_username | Usernames to login to Windows instance. | +| private\_ip | Private IPs of created instances. | +| public\_ip | Public IPs of created instances. | + + + +## Windows remote scripts execution + +Terraform supports using Windows Remote Management (WinRM) for connecting to Windows instances. Ensure that your Windows image has WinRM properly configured to allow remote access. Following is a sample WinRM configuration: + +```HCL +winrm quickconfig -q +winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="300"}’' +winrm set winrm/config ‘@{MaxTimeoutms=”1800000″}’ +winrm set winrm/config/service '@{AllowUnencrypted="true"}' +winrm set winrm/config/service/auth '@{Basic="true"}' + +netsh advfirewall firewall add rule name="WinRM 5985" protocol=TCP dir=in localport=5985 action=allow +netsh advfirewall firewall add rule name="WinRM 5986" protocol=TCP dir=in localport=5986 action=allow + +net stop winrm +sc.exe config winrm start=auto +net start winrm +``` + +## Configure iSCSI volume attachments + +- For guidance configuring iSCSI on a Windows platform, see [Adding a Block Volume to a Windows Instance](https://docs.cloud.oracle.com/iaas/Content/GSG/Tasks/addingstorageForWindows.htm). + +- For guidance configuring iSCSI on a Linux platform, see [iSCSI Commands and Information](https://docs.cloud.oracle.com/iaas/Content/Block/Concepts/iscsiinformation.htm). See also this example of inline iSCSI commands execution using `iscsiadm` CLI called from terraform file: [instance.tf](https://github.com/terraform-providers/terraform-provider-oci/blob/master/examples/compute/instance/instance.tf). + +## Contributing + +This project is open source. Oracle appreciates any contributions that are made by the open source community. + +Learn how to [contribute](CONTRIBUTING.md). + +[Folks who contributed with explanations, code, feedback, ideas, testing etc.](CONTRIBUTORS.md) + +## License + +Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + +Licensed under the Universal Permissive License 1.0 or Apache License 2.0. + +See [LICENSE](https://github.com/oracle-terraform-modules/terraform-oci-compute-instance/blob/master/LICENSE.txt) for more details. diff --git a/examples/instance_default/instance_default.tf b/examples/instance_default/instance_default.tf index a9eea32..09e7891 100644 --- a/examples/instance_default/instance_default.tf +++ b/examples/instance_default/instance_default.tf @@ -1,24 +1,31 @@ -// Copyright (c) 2018, 2021 Oracle and/or its affiliates. +// Copyright (c) 2018, 2021 Oracle and/or its affiliates. variable "tenancy_ocid" { + type = string } variable "user_ocid" { + type = string } variable "fingerprint" { + type = string } variable "private_key_path" { + type = string } variable "region" { + type = string } variable "compartment_ocid" { + type = string } variable "instance_display_name" { + type = string } variable "subnet_ocids" { @@ -26,9 +33,11 @@ variable "subnet_ocids" { } variable "source_ocid" { + type = string } variable "ssh_authorized_keys" { + type = string } variable "block_storage_sizes_in_gbs" { @@ -36,6 +45,15 @@ variable "block_storage_sizes_in_gbs" { } variable "shape" { + type = string +} + +variable "assign_public_ip" { + type = bool +} + +variable "instance_count" { + type = number } provider "oci" { @@ -47,8 +65,9 @@ provider "oci" { } module "instance" { - source = "../../" - + source = "../../" + instance_count = var.instance_count + ad_number = 3 compartment_ocid = var.compartment_ocid instance_display_name = var.instance_display_name source_ocid = var.source_ocid @@ -56,4 +75,5 @@ module "instance" { ssh_authorized_keys = var.ssh_authorized_keys block_storage_sizes_in_gbs = var.block_storage_sizes_in_gbs shape = var.shape + assign_public_ip = var.assign_public_ip } diff --git a/examples/instance_default/outputs.tf b/examples/instance_default/outputs.tf index fb86f49..e66968e 100644 --- a/examples/instance_default/outputs.tf +++ b/examples/instance_default/outputs.tf @@ -2,26 +2,26 @@ output "instance_id" { description = "ocid of created instances. " - value = [module.instance.instance_id] + value = module.instance.instance_id } output "private_ip" { description = "Private IPs of created instances. " - value = [module.instance.private_ip] + value = module.instance.private_ip } output "public_ip" { description = "Public IPs of created instances. " - value = [module.instance.public_ip] + value = module.instance.public_ip } output "instance_username" { description = "Usernames to login to Windows instance. " - value = [module.instance.instance_username] + value = module.instance.instance_username } output "instance_password" { description = "Passwords to login to Windows instance. " sensitive = true - value = [module.instance.instance_password] + value = module.instance.instance_password } diff --git a/main.tf b/main.tf index 18d3a1a..82c0a94 100644 --- a/main.tf +++ b/main.tf @@ -1,4 +1,25 @@ -// Copyright (c) 2018, 2021, Oracle and/or its affiliates. +// Copyright (c) 2018, 2021, Oracle and/or its affiliates. + +terraform { + required_version = ">= 0.12" // terraform version below 0.12 is not tested/supported with this module + required_providers { + oci = { + version = ">= 3.27" // force downloading oci-provider compatible with terraform v0.12 + } + } +} + +// Get all the Availability Domains for the region +data "oci_identity_availability_domains" "ad" { + compartment_id = var.compartment_ocid +} + +locals { + ADs = [ + // Iterate through data.oci_identity_availability_domains.ad and create a list containing AD names + for i in data.oci_identity_availability_domains.ad.availability_domains : i.name + ] +} #################### # Subnet Datasource @@ -12,8 +33,9 @@ data "oci_core_subnet" "this" { # Instance ############ resource "oci_core_instance" "this" { - count = var.instance_count - availability_domain = data.oci_core_subnet.this[count.index % length(data.oci_core_subnet.this.*.availability_domain)].availability_domain + count = var.instance_count + // If no explicit AD number, spread instances on all ADs in round-robin. Looping to the first when last AD is reached + availability_domain = var.ad_number == null ? element(local.ADs, count.index) : element(local.ADs, var.ad_number - 1) compartment_id = var.compartment_ocid display_name = var.instance_display_name == "" ? "" : var.instance_count != "1" ? "${var.instance_display_name}_${count.index + 1}" : var.instance_display_name extended_metadata = var.extended_metadata @@ -30,7 +52,8 @@ resource "oci_core_instance" "this" { length(var.private_ips) == 0 ? 0 : count.index, ) skip_source_dest_check = var.skip_source_dest_check - subnet_id = data.oci_core_subnet.this[count.index % length(data.oci_core_subnet.this.*.id)].id + // Current implementation requires providing a list of subnets when using ad-specific subnets + subnet_id = data.oci_core_subnet.this[count.index % length(data.oci_core_subnet.this.*.id)].id } metadata = { diff --git a/variables.tf b/variables.tf index aa0b02c..2bcb4e0 100644 --- a/variables.tf +++ b/variables.tf @@ -1,114 +1,155 @@ -// Copyright (c) 2018, 2021, Oracle and/or its affiliates. +// Copyright (c) 2018, 2021, Oracle and/or its affiliates. variable "compartment_ocid" { - description = "Compartment's OCID where VCN will be created. " + description = "(Required) (Updatable) The OCID of the compartment where to create all resources" + type = string } +variable "ad_number" { + description = "(Optional) The availability domain number of the instance. If none is provided, it will start with AD-1 and continue in round-robin." + type = number + default = null +} + +# variable "fd_number" { +# // for future use, adding fault domain support +# description = "(Optional) (Updatable) The fault domain of the instance." +# type = number +# default = null +# } + variable "instance_display_name" { - description = "Name of Instance. " + description = "(Optional) (Updatable) A user-friendly name for the instance. Does not have to be unique, and it's changeable." + type = string default = "" } variable "extended_metadata" { - description = "Additional metadata key/value pairs that you provide. " + description = "(Optional) (Updatable) Additional metadata key/value pairs that you provide." + type = map(any) default = {} } variable "ipxe_script" { - description = "The iPXE script which to continue the boot process on the instance. " - default = "" + description = "(Optional) The iPXE script which to continue the boot process on the instance." + type = string + default = null } variable "preserve_boot_volume" { - description = "Specifies whether to delete or preserve the boot volume when terminating an instance. " + description = "Specifies whether to delete or preserve the boot volume when terminating an instance." + type = bool default = false } variable "boot_volume_size_in_gbs" { - description = "The size of the boot volume in GBs. " - default = "50" + description = "The size of the boot volume in GBs." + type = number + default = null } variable "shape" { - description = "The shape of an instance. " + description = "The shape of an instance." + type = string default = "VM.Standard2.1" } variable "assign_public_ip" { - description = "Whether the VNIC should be assigned a public IP address. " + description = "Whether the VNIC should be assigned a public IP address." + type = bool default = false } variable "vnic_name" { - description = "A user-friendly name for the VNIC. " + description = "A user-friendly name for the VNIC." + type = string default = "" } variable "hostname_label" { - description = "The hostname for the VNIC's primary private IP. " + description = "The hostname for the VNIC's primary private IP." + type = string default = "" } variable "private_ips" { - description = "Private IP addresses of your choice to assign to the VNICs. " + description = "Private IP addresses of your choice to assign to the VNICs." type = list(string) default = [] } variable "skip_source_dest_check" { - description = "Whether the source/destination check is disabled on the VNIC. " + description = "Whether the source/destination check is disabled on the VNIC." + type = bool default = false } variable "subnet_ocids" { - description = "The unique identifiers (OCIDs) of the subnets in which the instance primary VNICs are created. " + description = "The unique identifiers (OCIDs) of the subnets in which the instance primary VNICs are created." type = list(string) } variable "ssh_authorized_keys" { - description = "Public SSH keys path to be included in the ~/.ssh/authorized_keys file for the default user on the instance. " + description = "Public SSH keys path to be included in the ~/.ssh/authorized_keys file for the default user on the instance." + type = string } variable "user_data" { - description = "Provide your own base64-encoded data to be used by Cloud-Init to run custom scripts or provide custom Cloud-Init configuration. " - default = "" + description = "Provide your own base64-encoded data to be used by Cloud-Init to run custom scripts or provide custom Cloud-Init configuration." + type = string + default = null } variable "source_ocid" { - description = "The OCID of an image or a boot volume to use, depending on the value of source_type. " + description = "The OCID of an image or a boot volume to use, depending on the value of source_type." + type = string } variable "source_type" { - description = "The source type for the instance. " + description = "The source type for the instance." + type = string default = "image" } variable "instance_timeout" { - description = "Timeout setting for creating instance. " + description = "Timeout setting for creating instance." + type = string default = "25m" } variable "instance_count" { - description = "Number of instances to launch. " - default = "1" + description = "Number of instances to launch." + type = number + default = 1 } variable "block_storage_sizes_in_gbs" { - description = "Sizes of volumes to create and attach to each instance. " + description = "Sizes of volumes to create and attach to each instance." + type = list(number) default = [] } +# variable "block_storage_enable_autotune" { +# // for future use, adding block volume performance auto-tune +# description = "(Optional) (Updatable) Specifies whether the auto-tune performance is enabled for this volume." +# type = bool +# default = true +# } + variable "attachment_type" { - description = "Attachment type. " - default = "iscsi" + description = "(Optional) The type of volume. The only supported values are iscsi and paravirtualized." + type = string + default = "paravirtualized" } variable "use_chap" { - description = "Whether to use CHAP authentication for the volume attachment. " + description = "(Applicable when attachment_type=iscsi) Whether to use CHAP authentication for the volume attachment." + type = bool default = false } variable "resource_platform" { - description = "Platform to create resources in. " + description = "Platform to create resources in." + type = string default = "linux" -} \ No newline at end of file +} diff --git a/versions.tf b/versions.tf deleted file mode 100644 index ac97c6a..0000000 --- a/versions.tf +++ /dev/null @@ -1,4 +0,0 @@ - -terraform { - required_version = ">= 0.12" -}