-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Victor Getz <sd>
- Loading branch information
victorgetz
committed
Jul 21, 2023
1 parent
db0f239
commit f9cd6c9
Showing
5 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Terraform OpenTelekomCloud Module | ||
|
||
This is a Terraform module that provisions encrypted Elastic Volume Service (EVS) on OpenTelekomCloud. | ||
This module is capable of creating multiple EVS volumes using parameters for their names, specifications, and availability zones. | ||
|
||
|
||
### Usage example | ||
|
||
```hcl | ||
module "elasticsearch_volumes" { | ||
source = "registry.terraform.io/iits-consulting/project-factory/opentelekomcloud//modules/evs" | ||
volume_names = ["elasticsearch-${var.stage}-0","elasticsearch-${var.stage}-1"] | ||
availability_zones = [ "eu-de-02", "eu-de-03"] | ||
kms_key_prefix = "elasticsearch-${var.stage}" | ||
spec = { | ||
size = 200 | ||
volume_type = "SSD" | ||
device_type = "SCSI" | ||
} | ||
tags = local.tags | ||
} | ||
``` | ||
|
||
|
||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| terraform | >= 0.13 | | ||
| opentelekomcloud | * | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| opentelekomcloud | * | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|:----:|:-----:|:-----:| | ||
| volume_names | List of names for the volumes to be created | list(string) | n/a | yes | | ||
| tags | Common tag set for project resources | map(string) | {} | no | | ||
| spec | Volume specifications like size, volume type and device type | object | { size=20, volume_type="SSD", device_type="SCSI" } | no | | ||
| availability_zones | List of availability zones for the volumes | list(string) | ["eu-de-01"] | no | | ||
| kms_key_prefix | Prefix to be used for creating the kms key | string | n/a | yes | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| volumes | A map of created volumes where keys are volume names | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
resource "random_id" "volume_kms_id" { | ||
byte_length = 4 | ||
} | ||
|
||
resource "opentelekomcloud_kms_key_v1" "volume_kms_key" { | ||
key_alias = "${var.kms_key_prefix}-evs-key-${random_id.volume_kms_id.hex}" | ||
key_description = "Persistent volume encryption key for ${var.kms_key_prefix}" | ||
pending_days = 7 | ||
is_enabled = "true" | ||
} | ||
|
||
resource "opentelekomcloud_evs_volume_v3" "evs_volumes" { | ||
count = length(var.volume_names) | ||
name = var.volume_names[count.index] | ||
description = "${var.volume_names[count.index]} EVS volume" | ||
availability_zone = var.availability_zones[count.index % length(var.availability_zones)] | ||
size = var.spec.size | ||
volume_type = var.spec.volume_type | ||
device_type = var.spec.device_type | ||
tags = var.tags | ||
kms_id = opentelekomcloud_kms_key_v1.volume_kms_key.id | ||
} | ||
|
||
output "volumes" { | ||
value = { for volume in opentelekomcloud_evs_volume_v3.evs_volumes : volume.name => volume } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
variable "volume_names" { | ||
type = list(string) | ||
} | ||
|
||
variable "tags" { | ||
type = map(string) | ||
description = "Common tag set for project resources" | ||
default = {} | ||
} | ||
|
||
variable "spec" { | ||
default = { | ||
size = 20 | ||
volume_type = "SSD" | ||
device_type = "SCSI" | ||
} | ||
} | ||
|
||
variable "availability_zones" { | ||
default = ["eu-de-01"] | ||
} | ||
|
||
variable "kms_key_prefix" { | ||
type = string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
terraform { | ||
required_providers { | ||
opentelekomcloud = { | ||
source = "opentelekomcloud/opentelekomcloud" | ||
} | ||
} | ||
} |