This Terraform module creates and configures OpenStack compute instances with optional attached storage volumes and networking configurations.
Copyright © EUMETSAT 2025.
The provided code and instructions are licensed under the MIT license. They are intended to automate the setup of an environment that includes third-party software components. The usage and distribution terms of the resulting environment are subject to the individual licenses of those third-party libraries.
Users are responsible for reviewing and complying with the licenses of all third-party components included in the environment.
Contact EUMETSAT for details on the usage and distribution terms.
- Create OpenStack compute instances with customizable configurations
- Optionally boot from volume with configurable size
- Support for attaching additional volumes
- Floating IP assignment for public access
- Security group configuration
- Integration with cloud-init for instance initialization
- Flexible networking options
- Resource tagging support with automatic app_name tagging
Before proceeding, if you lack OpenStack Application Credentials or do not know how to make them available to Ansible in your development environment, make sure to check out the EWC documentation.
module "web_server" {
source = "path/to/openstack-compute"
app_name = "web"
instance_name = "server"
instance_index = 1
image_id = "your-image-id"
flavor_id = "your-flavor-id"
keypair_name = "your-keypair-name"
networks = ["internal"]
instance_has_fip = true
os_volume = {
enable = true
size = 80
}
extra_volume = true
extra_volume_size = 100
security_groups = ["default", "web"]
instance_metadata = {
environment = "production"
role = "web"
}
tags = {
environment = "production"
project = "website"
owner = "team-alpha"
}
}| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| app_name | Application name, used as prefix in the full instance name | string |
n/a | yes |
| instance_name | Name of the instance, used in the full instance name | string |
n/a | yes |
| instance_index | Index or identifier for the instance, used as suffix in the full instance name | number |
n/a | yes |
| image_id | (Optional; Required if image_name is empty and not booting from a volume. Do not specify if booting from a volume.) The image ID to use for the instance | string |
n/a | no |
| flavor_id | (Optional; Required if flavor_name is empty) The flavor ID to use for the instance | string |
n/a | no |
| image_name | (Optional; Required if image_id is empty and not booting from a volume. Do not specify if booting from a volume.) The name of the image to use for the instance | string |
n/a | no |
| flavor_name | (Optional; Required if flavor_id is empty) The name the flavor to use for the instance | string |
n/a | no |
| keypair_name | Name of the keypair to use for SSH access to the instance | string |
n/a | yes |
| networks | List of network names to attach the instance to | list(string) |
n/a | yes |
| security_groups | List of security group names to apply to the instance | list(string) |
["default"] |
no |
| instance_has_fip | Whether to assign a floating IP to the instance | bool |
false |
no |
| os_volume | Configuration for the primary OS volume | object({enable = bool, size = number}) |
{enable = false, size = 50} |
no |
| extra_volume | Whether to attach an additional volume to the instance | bool |
false |
no |
| extra_volume_size | Size in GB of the additional volume | number |
1 |
no |
| extra_volume2 | Whether to attach a second additional volume to the instance | bool |
false |
no |
| extra_volume2_size | Size in GB of the second additional volume | number |
1 |
no |
| cloudinit_userdata | User data for cloud-init to be passed to the instance | string |
null |
no |
| instance_metadata | Metadata to associate with the instance (key-value pairs) | map(string) |
null |
no |
| add_sfs_network | Shared File System network to add (if needed) | string |
null |
no |
| external_network_name | Name of the external network for floating IPs | string |
"external" |
no |
| tags | A map of tags to assign to all resources that support it | map(string) |
{} |
no |
Third-party components used in the working environment.
The following components will be included in the working environment:
| Component | Version | License | Home URL |
|---|---|---|---|
| terraform-provider-openstack | 1.53.0 | MPL-2.0 | https://github.com/terraform-provider-openstack/terraform-provider-openstack |
| Name | Description |
|---|---|
| instance-data | Comprehensive information about the created instance |
| volumes | Information about the attached volumes |
{
name = "app-name-instance-name-01"
id = "instance-id"
internal_ip = "192.168.1.10"
floating_ip = "203.0.113.10"
networks = [/* Network details */]
flavor_id = "flavor-id"
volumes = ["volume-id-1", "volume-id-2"]
access_address = "203.0.113.10" # or internal IP if no floating IP
}{
primary = "volume-id-primary" # if os_volume.enable = true
volume_1 = {
id = "volume-id-1"
name = "app_name_instance_name_01_volume"
size = 100
}
volume_2 = {
id = "volume-id-2"
name = "app_name_instance_name_01_volume2"
size = 50
}
}- Always specify appropriate security groups for your instances
- Use unique and descriptive names for instances to aid in identification
- Consider using OS volumes for production instances for improved performance and resilience
- Implement proper key management for your keypair_name
- Use cloud-init userdata for consistent instance initialization
This module supports tagging of OpenStack resources using the tags variable. Additionally, the module automatically adds the app_name as a tag to all resources that support tagging. This provides consistent identification across your OpenStack environment.
- Compute Instance: Tags are implemented as metadata key-value pairs
- Volumes: Tags are implemented as a list of string tags
- Floating IPs: Tags are implemented as a list of string tags
Example of how tags are applied:
tags = {
environment = "production"
project = "web-app"
}The above will result in:
- Compute instance metadata containing:
app_name,environment, andprojectkeys - Volumes and floating IPs tagged with:
app_name,environment, andprojecttags
This tagging approach makes it easier to filter, identify, and manage resources in your OpenStack environment.
All notable changes (i.e. fixes, features and breaking changes) are documented in the CHANGELOG.md.
Thanks for taking the time to join our community and start contributing! Please make sure to:
- Familiarize yourself with our Code of Conduct before contributing.
- See CONTRIBUTING.md for instructions on how to request or submit changes.