Skip to content

Commit

Permalink
Add EVS module (#89)
Browse files Browse the repository at this point in the history
Co-authored-by: Victor Getz <sd>
  • Loading branch information
victorgetz committed Jul 21, 2023
1 parent db0f239 commit f9cd6c9
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module "vpc" {
- [snat:](https://github.com/iits-consulting/terraform-opentelekomcloud-project-factory/tree/master/modules/snat) Public SNAT gateway to grant internet access from a VPC without shared SNAT.
- [vpn:](https://github.com/iits-consulting/terraform-opentelekomcloud-project-factory/tree/master/modules/vpn) Creates a VPN tunnel.
- [waf:](https://github.com/iits-consulting/terraform-opentelekomcloud-project-factory/tree/master/modules/waf) Create Web Application Firewall for a Domain
- [evs:](https://github.com/iits-consulting/terraform-opentelekomcloud-project-factory/tree/master/modules/evs) Create an encrypted Elastic Volume Service (EVS)

## Quickstart

Expand Down
55 changes: 55 additions & 0 deletions modules/evs/README.MD
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 |
26 changes: 26 additions & 0 deletions modules/evs/evs.tf
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 }
}
25 changes: 25 additions & 0 deletions modules/evs/variables.tf
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
}
7 changes: 7 additions & 0 deletions modules/evs/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
terraform {
required_providers {
opentelekomcloud = {
source = "opentelekomcloud/opentelekomcloud"
}
}
}

0 comments on commit f9cd6c9

Please sign in to comment.