This project aims to create a module to deploy instance(s) on openstack provider.
Note: This module requires Terraform version 1.5.0 or higher and OpenStack provider version 3.2.0 or higher.
module "instance-module" {
source = "atlet99/instance-module/openstack"
version = "1.0.5"
# insert the 4 required variables here
}module "test_instance_simple" {
source = "atlet99/instance-module/openstack"
version = "1.0.5"
name = "instance"
flavor_name = "m1.xs"
image_id = "<image_id>"
key_pair_name = "my_key_pair"
public_ip_network = "floating"
ports = [
{
name = "db_port",
network_id = "db_network_id",
subnet_id = "db_subnet_id",
},
{
name = "web_port",
network_id = "web_network_id",
subnet_id = "web_subnet_id",
}
]
server_groups = ["web"]
}For root volume creation, set exactly one source input:
image_idimage_namesnapshot_idsource_vol_idbackup_id
Any other combination is invalid in strict mode and can fail in provider/runtime behavior.
Stable outputs intended for cross-module integration:
instance_idprivate_ipsfloating_ipsroot_volume_id
Extended outputs (instance_info, all_metadata, all_tags, timestamps, etc.) are best-effort and may evolve over time.
| Name | Version |
|---|---|
| terraform | >= 1.5.0 |
| openstack | ~> 3.2.0 |
| Name | Version |
|---|---|
| openstack | 3.2.0 |
| Name | Type |
|---|---|
| openstack_blockstorage_volume_v3.volume_os | resource |
| openstack_compute_instance_v2.instance | resource |
| openstack_compute_interface_attach_v2.hot_ports_attach | resource |
| openstack_compute_volume_attach_v2.extra_volumes | resource |
| openstack_networking_floatingip_associate_v2.ipa | resource |
| openstack_networking_floatingip_v2.ip | resource |
| openstack_networking_port_v2.boot_ports | resource |
| openstack_networking_port_v2.hot_ports | resource |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| admin_pass | The administrative password to assign to the server. | string |
null |
no |
| availability_zone | AZ where volume's available. | string |
null |
no |
| backup_id | The backup ID from which to create the root volume. Mutually exclusive with snapshot_id, source_vol_id, image_id, image_name. | string |
null |
no |
| block_device_delete_on_termination | Delete block device when instance is shut down | bool |
true |
no |
| block_device_description | The description of the block device. | string |
null |
no |
| block_device_device_type | The low-level device type that will be used (e.g., cdrom). | string |
null |
no |
| block_device_disk_bus | The low-level disk bus that will be used (e.g., virtio, scsi). | string |
null |
no |
| block_device_guest_format | Specifies the guest server disk file system format, such as ext4 or swap. | string |
null |
no |
| block_device_metadata | Metadata key/value pairs to associate with the volume. | map(string) |
{} |
no |
| block_device_scheduler_hints | Provide the Cinder scheduler with hints on where to instantiate a volume. | object({ |
null |
no |
| block_device_volume_size | The volume size of block device | number |
20 |
no |
| boot_volume_metadata | Additional metadata for the boot volume. Merged over block_device_metadata. |
map(string) |
{} |
no |
| config_drive | Whether to use the config_drive feature to configure the instance. | bool |
true |
no |
| consistency_group_id | The consistency group to place the volume in. | string |
null |
no |
| enable_online_resize | When this option is set it allows extending attached volumes. | bool |
true |
no |
| extra_volumes | A list of additional volumes to attach to the instance. | list(object({ |
[] |
no |
| fip_description | Human-readable description for the floating IP. | string |
null |
no |
| fip_dns_domain | The floating IP DNS domain. Must be empty or end with a dot (for example: example.com.). | string |
null |
no |
| fip_dns_name | The floating IP DNS name. | string |
null |
no |
| fip_fixed_ip | Optional fixed IP of the target port to associate with the floating IP. | string |
null |
no |
| fip_subnet_ids | Optional list of subnet IDs for floating IP allocation. The first subnet ID is used by the provider when multiple are passed. | list(string) |
[] |
no |
| flavor_id | Instance's flavor id referenced in openstack | string |
null |
no |
| flavor_name | Instance's flavor name referenced in openstack | string |
null |
no |
| floating_ip_port_index | The index of the port to associate the floating IP with (0 for first boot-port, then hot-ports). | number |
0 |
no |
| force_delete | Whether to force the OpenStack instance to be forcefully deleted. | bool |
false |
no |
| hot_ports | Ports attached after instance creation (hot-plug). Does not cause replacement. | list(object({ |
[] |
no |
| hypervisor_hostname | Specifies the exact hypervisor hostname on which to create the instance. | string |
null |
no |
| ignore_boot_volume_metadata_changes | Ignore boot volume metadata drift caused by provider/platform-managed keys. | bool |
true |
no |
| image_id | The image ID referenced in OpenStack. Use as one root-volume source (mutually exclusive with image_name, snapshot_id, source_vol_id, backup_id). | string |
null |
no |
| image_name | The image name referenced in OpenStack (resolved to image ID). Use as one root-volume source (mutually exclusive with image_id, snapshot_id, source_vol_id, backup_id). | string |
null |
no |
| instance_availability_zone | The availability zone in which to create the server. | string |
null |
no |
| instance_availability_zone_hints | The availability zone hints in which to create the server. | string |
null |
no |
| instance_metadata | Additional metadata for the OpenStack instance. Merged over metadata. |
map(string) |
{} |
no |
| key_pair_name | The name of the ssh key referenced in openstack | string |
n/a | yes |
| metadata | Metadata for the OpenStack instance. | map(string) |
{} |
no |
| name | Instance's name | string |
n/a | yes |
| network_mode | Special string for network option: 'auto' or 'none'. Conflicts with boot ports (var.ports). | string |
null |
no |
| personalities | A list of files to inject into the instance at boot time. | list(object({ |
[] |
no |
| ports | Ports attached at boot time (causes replacement on change). If empty, OpenStack will create a default port. | list(object({ |
[] |
no |
| power_state | The VM state. Only 'active', 'shutoff', 'paused' and 'shelved_offloaded' are supported values. | string |
"active" |
no |
| public_ip_network | The name of the network who give floating IPs | string |
null |
no |
| region | Region where volume's located. | string |
null |
no |
| scheduler_hints | Provide the Nova scheduler with hints on where to instantiate an instance. | object({ |
null |
no |
| snapshot_id | The snapshot ID from which to create the root volume. Mutually exclusive with source_vol_id, backup_id, image_id, image_name. | string |
null |
no |
| source_replica | The volume ID to replicate with. | string |
null |
no |
| source_vol_id | The volume ID from which to create the root volume. Mutually exclusive with snapshot_id, backup_id, image_id, image_name. | string |
null |
no |
| stop_before_destroy | Whether to try stop instance gracefully before destroying it. | bool |
false |
no |
| strict_validations | Enable strict module-level validations and preconditions. Disable only for backward-compatibility troubleshooting. | bool |
true |
no |
| tags | The instances tags | list(string) |
[] |
no |
| user_data | The user data for instance | string |
null |
no |
| vendor_options | Vendor-specific options for the instance. | object({ |
null |
no |
| volume_retype_policy | Migration policy when changing volume_type. Allowed values: null, 'never', 'on-demand'. | string |
null |
no |
| volume_type | The type of volume to use, e.g., 'ceph-ssd', 'kz-ala-1-san-nvme-h1' or 'ceph-hdd' | string |
"ceph-ssd" |
no |
| Name | Description |
|---|---|
| access_ip_v4 | The first detected IPv4 address of the instance. |
| access_ip_v6 | The first detected IPv6 address of the instance. |
| admin_pass | The administrative password assigned to the server. |
| all_fixed_ips | Full list of all fixed IP addresses on all ports. |
| all_metadata | All metadata key/value pairs associated with the instance. |
| all_tags | All tags associated with the instance. |
| availability_info | Availability zone and hints for the instance. |
| boot_port_ids | IDs of ports attached at boot time. |
| boot_ports | Details of ports attached at boot time. |
| created_at | The creation time of the instance. |
| extra_volume_attachment_ids | List of volume attachment IDs for additional volumes. |
| extra_volume_ids | List of attached additional volume IDs. |
| floating_ips | Flat list of floating IP addresses. |
| hot_port_ids | IDs of ports attached after boot (hot-plug). |
| hot_ports | Details of ports attached after boot (hot-plug). |
| instance_id | Instance ID. |
| instance_ids | Flat list of instance IDs. |
| instance_info | Detailed list of all ports (boot and hot) with tags, IPs, MAC addresses and binding info. |
| instance_metadata | The metadata associated with the instance. |
| private_ips | Flat list of the first private IP address for all ports. |
| root_volume_id | The ID of the instance boot volume. |
| root_volume_metadata | Metadata returned by OpenStack for the boot volume, including platform-managed keys. |
| updated_at | The time when the instance was last updated. |