This module provisions and manages Oracle Cloud Infrastructure (OCI) compute instances using Terraform. It is designed to be flexible and configurable, allowing users to customize instance settings, networking options, storage configurations, and more.
- Create and manage OCI compute instances
- Configure instance metadata, shape, and state
- Manage networking settings including VNICs, public/private IPs, and subnets
- Configure storage options including boot volumes and block storage
- Tagging support with freeform and defined tags
- Fault domain and availability domain configuration
- Support for Oracle Cloud Agent plugins
- OCI account with the necessary permissions
- Terraform installed
module "oci_compute_instance" {
source = "./path/to/module"
tenancy_ocid = "ocid1.tenancy.oc1..example"
compute_cmp = "ComputeCompartmentName"
network_cmp = "NetworkCompartmentName"
security_cmp = "SecurityCompartmentName"
volume_bk_policy_cmp = "VolumeBackupPolicyCompartmentName"
instance_count = 2
instance_display_name = "MyInstance"
shape = "VM.Standard2.1"
source_ocid = "ocid1.image.oc1..example"
ssh_public_keys = file("~/.ssh/id_rsa.pub")
user_data = file("path/to/cloud-init-script.sh")
freeform_tags = {
Project = "MyProject"
}
defined_tags = {
"Oracle-Tags.CostCenter" = "12345"
}
}
tenancy_ocid
(string, required): The OCID of the root compartment.compute_cmp
(string, optional): Compartment name for compute resource. Default isnull
.network_cmp
(string, optional): Compartment name for networking resources. Default isnull
.security_cmp
(string, optional): Compartment name for security resources. Default isnull
.volume_bk_policy_cmp
(string, optional): Compartment name for volume backup policy resource. Default isnull
.
instance_count
(number, optional): Number of identical instances to launch. Default is1
.ad_number
(number, optional): The availability domain number. If none is provided, instances will be distributed across ADs. Default isnull
.instance_display_name
(string, optional): A user-friendly name for the instance. Default is""
.shape
(string, optional): The shape of the instance. Default is"VM.Standard2.1"
.source_ocid
(string, required): The OCID of an image or a boot volume to use.instance_state
(string, optional): The target state for the instance (RUNNING
orSTOPPED
). Default isRUNNING
.
public_ip
(string, optional): Whether to create a public IP and its lifetime (NONE
,RESERVED
,EPHEMERAL
). Default isNONE
.private_ips
(list(string), optional): Private IP addresses to assign to the VNICs. Default is[]
.subnet_ocids
(list(string), optional): OCIDs of the subnets in which the instance primary VNICs are created. Default isnull
.vnic_name
(string, optional): A user-friendly name for the VNIC. Default is""
.
boot_volume_size_in_gbs
(number, optional): The size of the boot volume in GBs. Default isnull
.block_storage_sizes_in_gbs
(list(number), optional): Sizes of volumes to create and attach to each instance. Default is[]
.vpus_per_gb
(number, optional): The number of volume performance units per GB. Default is10
.
freeform_tags
(map(string), optional): Simple key-value pairs to tag the resources. Default isnull
.defined_tags
(map(string), optional): Predefined and scoped to a namespace to tag the resources. Default isnull
.
ssh_public_keys
(string, optional): Public SSH keys to include in the~/.ssh/authorized_keys
file. Default is""
.user_data
(string, optional): Base64-encoded data for Cloud-Init to run custom scripts or provide custom Cloud-Init configuration. Default isnull
.
instances_summary
: Private and public IPs for each instance.instance_id
: OCIDs of created instances.private_ip
: Private IPs of created instances.public_ip
: Public IPs of created instances.instance_username
: Usernames to login to Windows instances.instance_password
: Passwords to login to Windows instances (sensitive).instance_all_attributes
: All attributes of created instances.public_ip_all_attributes
: All attributes of created public IPs.private_ips_all_attributes
: All attributes of created private IPs.vnic_attachment_all_attributes
: All attributes of created VNIC attachments.volume_all_attributes
: All attributes of created volumes.volume_attachment_all_attributes
: All attributes of created volume attachments.
This project is licensed under the MIT License. See the LICENSE file for details.
Andres F. Montealegre
- Email: [email protected]
- GitHub: https://github.com/andresmonteal