Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rds #10

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

rds #10

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ override.tf.json
# Ignore CLI configuration files
.terraformrc
terraform.rc

.idea/**
6 changes: 3 additions & 3 deletions modules/dns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ dns_settings = {
vpc_id = "REWRITE_IN_LOCALS"
region = "REWRITE_IN_LOCALS"
tags = {}
recordsets = [
recordsets = [
{
subdomain = "cname"
type = "cname"
description = "cname record set"
ttl = 3600
records = ["server1.example.com."]
tags = {
tags = {
"Recordset" = "private_cname"
}
},
Expand All @@ -49,7 +49,7 @@ dns_settings = {

data "opentelekomcloud_identity_project_v3" "current" {}

data "opentelekomcloud_vpc_subnet_v1" "subnet" {
data "opentelekomcloud_vpc_subnet_v1" "subnet" {
name = "my-subnet"
}

Expand Down
8 changes: 8 additions & 0 deletions modules/rds/rds_backup/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "opentelekomcloud_rds_backup_v3" "test" {
for_each = var.rds_backup_settings

name = each.key
description = each.value["description"]
databases = each.value["databases"]
instance_id = each.value["instance_id"]
}
27 changes: 27 additions & 0 deletions modules/rds/rds_backup/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
output "rds_backup_id" {
value = try(opentelekomcloud_rds_backup_v3.this.*.id, "")
}

output "rds_backup_name" {
value = try(opentelekomcloud_rds_backup_v3.this.*.name, "")
}

output "rds_backup_description" {
value = try(opentelekomcloud_rds_backup_v3.this.*.description, "")
}

output "rds_backup_databases" {
value = try(opentelekomcloud_rds_backup_v3.this.*.databases, "")
}

output "rds_backup_status" {
value = try(opentelekomcloud_rds_backup_v3.this.*.status, "")
}

output "rds_backup_type" {
value = try(opentelekomcloud_rds_backup_v3.this.*.type, "")
}

output "rds_backup_begin_time" {
value = try(opentelekomcloud_rds_backup_v3.this.*.begin_time, "")
}
17 changes: 17 additions & 0 deletions modules/rds/rds_backup/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
variable "rds_backup_settings" {
default = {
/*Example:
#Here you set rds_backup name as key
rds_backup_name = {
description = "desc"
databases = ["db1", "db2"]
instance_id = "instance_id"
}
*/
}
type = map(object({
description = optional(string)
databases = optional(list(string))
instance_id = optional(string)
}))
}
10 changes: 10 additions & 0 deletions modules/rds/rds_backup/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 1.0"

required_providers {
opentelekomcloud = {
source = "opentelekomcloud/opentelekomcloud"
version = ">=1.34.4"
}
}
}
31 changes: 31 additions & 0 deletions modules/rds/rds_instance/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
resource "opentelekomcloud_rds_instance_v3" "this" {
count = var.create_rds ? 1 : 0

availability_zone = var.availability_zone
db {
password = var.db_password
type = var.db_type
version = var.db_version
port = var.db_port
}
name = "${var.prefix}_rds_instance"
security_group_id = var.secgroup_id
subnet_id = var.network_id
vpc_id = var.vpc_id
volume {
type = var.volume_type
size = var.volume_size
disk_encryption_id = var.volume_encryption_id
}
flavor = var.db_flavor
ha_replication_mode = var.ha_replication_mode

backup_strategy {
start_time = var.backup_start_time
keep_days = var.backup_keep_days
}

tags = var.tags

param_group_id = length(var.parametergroup_values) > 0 ? concat(opentelekomcloud_rds_parametergroup_v3.this.*.id)[0] : null
}
52 changes: 52 additions & 0 deletions modules/rds/rds_instance/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
output "rds_instance_id" {
value = opentelekomcloud_rds_instance_v3.this.*.id
}

output "rds_instance_name" {
value = opentelekomcloud_rds_instance_v3.this.*.name
}

output "rds_instance_status" {
value = opentelekomcloud_rds_instance_v3.this.*.status
}

output "rds_instance_availability_zone" {
value = opentelekomcloud_rds_instance_v3.this.*.availability_zone
}

output "rds_instance_volume_size" {
value = opentelekomcloud_rds_instance_v3.this.*.volume.0.size
}

output "rds_instance_volume_type" {
value = opentelekomcloud_rds_instance_v3.this.*.volume.0.type
}

output "rds_instance_volume_encryption_id" {
value = opentelekomcloud_rds_instance_v3.this.*.volume.0.disk_encryption_id
}

output "rds_private_ip" {
value = opentelekomcloud_rds_instance_v3.this.*.private_ip
}

output "rds_instance_port" {
value = opentelekomcloud_rds_instance_v3.this.*.db.0.port
}

output "rds_public_ip" {
value = try(opentelekomcloud_rds_instance_v3.this.*.public_ips, "")
}

output "rds_instance_nodes" {
value = opentelekomcloud_rds_instance_v3.this.*.nodes
}

output "rds_root_username" {
value = opentelekomcloud_rds_instance_v3.db_instance.db[0].user_name
}

output "rds_root_password" {
value = try(opentelekomcloud_rds_instance_v3.db_instance.db[0].password, "")
sensitive = true
}
Loading